Skip to content

Commit d330775

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#53273 from mikedanese/authtristate
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. add support for short-circuit deny in union authorizer This change has no behavioral changes. Fixes kubernetes#51862 ```release-note Add support for the webhook authorizer to make a Deny decision that short-circuits the union authorizer and immediately returns Deny. ```
2 parents ef8746a + 90d551a commit d330775

File tree

52 files changed

+684
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+684
-450
lines changed

api/openapi-spec/swagger.json

Lines changed: 10 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/authorization.k8s.io_v1.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/authorization.k8s.io_v1beta1.json

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api-reference/authorization.k8s.io/v1/definitions.html

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api-reference/authorization.k8s.io/v1beta1/definitions.html

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/authorization/types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,13 @@ type SelfSubjectAccessReviewSpec struct {
140140

141141
// SubjectAccessReviewStatus
142142
type SubjectAccessReviewStatus struct {
143-
// Allowed is required. True if the action would be allowed, false otherwise.
143+
// Allowed is required. True if the action would be allowed, false otherwise.
144144
Allowed bool
145+
// Denied is optional. True if the action would be denied, otherwise
146+
// false. If both allowed is false and denied is false, then the
147+
// authorizer has no opinion on whether to authorize the action. Denied
148+
// may not be true if Allowed is true.
149+
Denied bool
145150
// Reason is optional. It indicates why a request was allowed or denied.
146151
Reason string
147152
// EvaluationError is an indication that some error occurred during the authorization check.

pkg/apis/authorization/v1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/authorization/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/auth/authorizer/abac/abac.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ func resourceMatches(p abac.Policy, a authorizer.Attributes) bool {
221221
}
222222

223223
// Authorizer implements authorizer.Authorize
224-
func (pl policyList) Authorize(a authorizer.Attributes) (bool, string, error) {
224+
func (pl policyList) Authorize(a authorizer.Attributes) (authorizer.Decision, string, error) {
225225
for _, p := range pl {
226226
if matches(*p, a) {
227-
return true, "", nil
227+
return authorizer.DecisionAllow, "", nil
228228
}
229229
}
230-
return false, "No policy matched.", nil
230+
return authorizer.DecisionNoOpinion, "No policy matched.", nil
231231
// TODO: Benchmark how much time policy matching takes with a medium size
232232
// policy file, compared to other steps such as encoding/decoding.
233233
// Then, add Caching only if needed.

0 commit comments

Comments
 (0)