Skip to content

Commit

Permalink
Drop authorizer wrapper
Browse files Browse the repository at this point in the history
The openshift authorizer was wrapping kube authorizer only to generate
Forbidden messages, but upstream already generate similar messages and we
cannot intercept and change those. So let's just stop duplicating errors
and use the upstream authorizer and error messages as is.

Signed-off-by: Simo Sorce <simo@redhat.com>
  • Loading branch information
simo5 committed Aug 7, 2018
1 parent fcf6cae commit 7da264d
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 453 deletions.
49 changes: 0 additions & 49 deletions pkg/authorization/authorizer/authorizer.go

This file was deleted.

12 changes: 8 additions & 4 deletions pkg/authorization/authorizer/browsersafe/authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestBrowserSafeAuthorizer(t *testing.T) {

expectedVerb string
expectedSubresource string
expectedReason string
}{
"non-resource": {
attributes: authorizer.AttributesRecord{ResourceRequest: false, Verb: "GET"},
Expand All @@ -29,15 +30,18 @@ func TestBrowserSafeAuthorizer(t *testing.T) {
attributes: authorizer.AttributesRecord{ResourceRequest: true, Verb: "get", Resource: "pods", Subresource: "proxy"},
expectedVerb: "get",
expectedSubresource: "unsafeproxy",
expectedReason: "proxy subresource changed to unsafeproxy",
},
"unsafe proxy verb": {
attributes: authorizer.AttributesRecord{ResourceRequest: true, Verb: "proxy", Resource: "nodes"},
expectedVerb: "unsafeproxy",
attributes: authorizer.AttributesRecord{ResourceRequest: true, Verb: "proxy", Resource: "nodes"},
expectedVerb: "unsafeproxy",
expectedReason: "proxy verb changed to unsafeproxy",
},
"unsafe proxy verb anonymous": {
attributes: authorizer.AttributesRecord{ResourceRequest: true, Verb: "proxy", Resource: "nodes",
User: &user.DefaultInfo{Name: "system:anonymous", Groups: []string{"system:unauthenticated"}}},
expectedVerb: "unsafeproxy",
expectedVerb: "unsafeproxy",
expectedReason: "proxy verb changed to unsafeproxy",
},

"proxy subresource authenticated": {
Expand All @@ -51,7 +55,7 @@ func TestBrowserSafeAuthorizer(t *testing.T) {
safeAuthorizer := NewBrowserSafeAuthorizer(delegateAuthorizer, "system:authenticated")

authorized, reason, err := safeAuthorizer.Authorize(tc.attributes)
if authorized == authorizer.DecisionAllow || len(reason) != 0 || err != nil {
if authorized == authorizer.DecisionAllow || reason != tc.expectedReason || err != nil {
t.Errorf("%s: unexpected output: %v %s %v", name, authorized, reason, err)
continue
}
Expand Down
10 changes: 0 additions & 10 deletions pkg/authorization/authorizer/interfaces.go

This file was deleted.

128 changes: 0 additions & 128 deletions pkg/authorization/authorizer/messages.go

This file was deleted.

Loading

0 comments on commit 7da264d

Please sign in to comment.