Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebase 1.9.0 beta.1 #17576

Merged
merged 78 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f0bb2b6
update glide.yaml
deads2k Dec 1, 2017
c671103
update glide.yaml for networking
deads2k Dec 7, 2017
07c6b99
glide.yaml: update ours dependencies
deads2k Dec 8, 2017
710998e
bump(*)
deads2k Dec 4, 2017
c8626b7
UPSTREAM: 57148: expose special storage locations
deads2k Dec 5, 2017
f3769c7
UPSTREAM: 57149: make quota reusable
deads2k Dec 5, 2017
123246b
UPSTREAM: <carry>: exclude some origin resources from quota
deads2k Dec 7, 2017
534c679
UPSTREAM: <drop>: add back PrintSuccess. remove when printing is fixed
deads2k Dec 6, 2017
ca1b85f
UPSTREAM: <drop>: skip controller metric error, drop once we run in a…
deads2k Dec 7, 2017
9ff7f3f
UPSTREAM: <drop>: skip scheduler configz error, drop once we run in a…
deads2k Dec 7, 2017
d34b354
UPSTREAM: <carry>: patch scheduler to apply defaults. drop once we r…
deads2k Dec 7, 2017
df449cc
UPSTREAM: <carry>: make wiring in kubeproxy easy until we sort out co…
deads2k Dec 8, 2017
f046a0b
UPSTREAM: 49312: allow the /version endpoint to pass through
deads2k Jul 20, 2017
3c7a135
UPSTREAM: openshift/api: 17: Rbac fix
deads2k Dec 8, 2017
3f45cdc
UPSTREAM: <drop>: remove usage of bad transport since only GKE routes
deads2k Dec 11, 2017
ee0f726
UPSTREAM: <carry>: keep set working on internal types
deads2k Dec 11, 2017
de36874
UPSTREAM: <drop>: enable beta APIs by default. fixed by several pulls…
deads2k Dec 11, 2017
64974bc
UPSTREAM: 56687: kube-apiserver: enable admissionregistration v1beta1…
deads2k Dec 11, 2017
bf64f2c
UPSTREAM: 57150: allow convert to default on a per object basis
juanvallejo Dec 8, 2017
cf235c2
UPSTREAM: <carry>: switch apply to use the legacyscheme so our types …
deads2k Dec 12, 2017
4bc612e
boring changes
deads2k Dec 4, 2017
66d94ff
skuznets: switch to golang 1.9
deads2k Dec 7, 2017
fc9b4e2
DISABLE ROUTER e2e tests! hopefully fix golang 1.9 before we merge a…
deads2k Dec 11, 2017
5b3859b
update generators
deads2k Dec 4, 2017
d1b5fe8
add secret reference
deads2k Dec 4, 2017
42a1e2c
update image type generation flags
deads2k Dec 4, 2017
d49083e
CreatedByAnnotation is gone, idling probably broke again
deads2k Dec 5, 2017
07e5313
image limit ranger plugin
deads2k Dec 5, 2017
ab033d4
explicitly stop running admission on some resources
deads2k Dec 5, 2017
32a0c9a
add admission validation for *some* special resources
deads2k Dec 5, 2017
27ad23a
NEEDS REVIEW: boring: docker client update
deads2k Dec 5, 2017
f490d38
update internal scale type for dc
deads2k Dec 5, 2017
2f11419
interesting: update the dc/scale integration test to use the generic …
deads2k Dec 7, 2017
b3fa18d
minimal lease reconciler change
deads2k Dec 5, 2017
22f0b91
remove deprecated dc rollback generator
deads2k Dec 5, 2017
0aedd29
QUOTA: refactor our use of quota
deads2k Dec 5, 2017
7f86e08
SEPARATE: needs picking to webconsole server when they rebase
deads2k Dec 5, 2017
99c59c6
interesting: use listener instead of bindport
deads2k Dec 5, 2017
afdcb87
jvallejo: printing debt to fix
deads2k Dec 6, 2017
2abedd5
SROSS: hack new start for hpa controller for https support
deads2k Dec 6, 2017
5d40a0f
weird: clusterresourceoverride admission with a fake limit ranger
deads2k Dec 6, 2017
4383cd7
admission wiring changes
deads2k Dec 6, 2017
7ffc267
SJENNING: node wiring changes
deads2k Dec 6, 2017
244afd3
DANW: update networking related code for rebase
deads2k Dec 4, 2017
30fe89a
update deletion strategies
deads2k Dec 11, 2017
de21f14
authorization changes
deads2k Dec 5, 2017
80cef2d
authorization: updates to bootstrap roles
deads2k Dec 11, 2017
a92560d
add roundtripping for aggregation rules
deads2k Dec 8, 2017
a1cef1f
apiserver default changes
deads2k Dec 8, 2017
8454d7d
etcd storage test updates
deads2k Dec 11, 2017
9344e48
BPAREES: simplify concurrent controller test
deads2k Dec 8, 2017
062ffb1
BPAREES: crio values seem half changed
deads2k Dec 11, 2017
93bd84a
router/f5: move test types into testing sub-pkg
sttts Dec 12, 2017
0089bbb
oc: simple
deads2k Dec 6, 2017
ad7d2fc
oc: interesting: handle switch to external types in printers and set
deads2k Dec 6, 2017
60d3fa9
oc: make printers work again - sortof
deads2k Dec 6, 2017
b15c3b6
oc: builder updates
deads2k Dec 6, 2017
1d18e82
oc: cluster up dockername parsing
deads2k Dec 7, 2017
31f33b0
oc: first round of fixes for test-cmd
juanvallejo Dec 7, 2017
2cf15a3
oc: break oc explain
deads2k Dec 11, 2017
ee8266b
oc: adm migrate isn't getting a full scheme. add missing types
deads2k Dec 12, 2017
bb2ecf0
oc: stop testing upstream shortcuts, we no longer statically include …
deads2k Dec 8, 2017
2db374f
oc: CLAYTON: using internal gives me external types
deads2k Dec 11, 2017
a4d2794
needs review: boring: change e2e status check
deads2k Dec 7, 2017
ebc468c
needs review: boring: ignore pod dns config for deployer pods
deads2k Dec 11, 2017
7256949
boring: needs review: update deletion so it never waits. Something c…
deads2k Dec 12, 2017
6c58566
boring: test updates
deads2k Dec 7, 2017
d4ee63c
generated
deads2k Dec 4, 2017
9e3ca9a
DANW: comments
deads2k Dec 12, 2017
6b39f30
separate kube controller informers in advance of splitting process
deads2k Dec 12, 2017
2fa3a79
BPAREES: don't pass unused streams to streamoptions because it hangs
deads2k Dec 12, 2017
d826d91
make migration printing work again
deads2k Dec 12, 2017
a783419
UPSTREAM: 57107: Check ns setup error during e2e
deads2k Dec 12, 2017
5c42201
make cluster quota admission wait for namespace to be present
deads2k Dec 12, 2017
b80c0d2
boring: update tsb e2e to exclude new events group
deads2k Dec 12, 2017
088b81d
update bootstrap role for router
deads2k Dec 12, 2017
cdc12ca
skip some networking tests that fail in the rebase
deads2k Dec 13, 2017
b374cbd
increase DC hook timeouts. indicates pod start latency problem and f…
deads2k Dec 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pkg/authorization/authorizer/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ func NewSubjectLocator(delegate authorizerrbac.SubjectLocator) SubjectLocator {
return &openshiftSubjectLocator{delegate: delegate}
}

func (a *openshiftAuthorizer) Authorize(attributes authorizer.Attributes) (bool, string, error) {
func (a *openshiftAuthorizer) Authorize(attributes authorizer.Attributes) (authorizer.Decision, string, error) {
if attributes.GetUser() == nil {
return false, "", errors.New("no user available on context")
return authorizer.DecisionDeny, "", errors.New("no user available on context")
Copy link
Contributor

@liggitt liggitt Dec 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mechanical change to return NoOpinion, not Deny (applies everywhere)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mechanical change to return NoOpinion, not Deny (applies everywhere)

done

}
allowed, delegateReason, err := a.delegate.Authorize(attributes)
if allowed {
return true, reason(attributes), nil
authorized, delegateReason, err := a.delegate.Authorize(attributes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return authorized, not convert it to Deny

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should return authorized, not convert it to Deny

done

if authorized == authorizer.DecisionAllow {
return authorizer.DecisionAllow, reason(attributes), nil
}
// errors are allowed to occur
if err != nil {
return false, "", err
return authorizer.DecisionDeny, "", err
}

denyReason, err := a.forbiddenMessageMaker.MakeMessage(attributes)
Expand All @@ -48,7 +48,7 @@ func (a *openshiftAuthorizer) Authorize(attributes authorizer.Attributes) (bool,
denyReason += ": " + delegateReason
}

return false, denyReason, nil
return authorizer.DecisionDeny, denyReason, nil
}

// GetAllowedSubjects returns the subjects it knows can perform the action.
Expand Down
2 changes: 1 addition & 1 deletion pkg/authorization/authorizer/browsersafe/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewBrowserSafeAuthorizer(delegate authorizer.Authorizer, authenticatedGroup
}
}

func (a *browserSafeAuthorizer) Authorize(attributes authorizer.Attributes) (bool, string, error) {
func (a *browserSafeAuthorizer) Authorize(attributes authorizer.Attributes) (authorizer.Decision, string, error) {
browserSafeAttributes := a.getBrowserSafeAttributes(attributes)
return a.delegate.Authorize(browserSafeAttributes)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/authorization/authorizer/browsersafe/authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestBrowserSafeAuthorizer(t *testing.T) {
safeAuthorizer := NewBrowserSafeAuthorizer(delegateAuthorizer, "system:authenticated")

authorized, reason, err := safeAuthorizer.Authorize(tc.attributes)
if authorized || len(reason) != 0 || err != nil {
if authorized == authorizer.DecisionAllow || len(reason) != 0 || err != nil {
t.Errorf("%s: unexpected output: %v %s %v", name, authorized, reason, err)
continue
}
Expand All @@ -69,7 +69,7 @@ type recordingAuthorizer struct {
attributes authorizer.Attributes
}

func (t *recordingAuthorizer) Authorize(a authorizer.Attributes) (authorized bool, reason string, err error) {
func (t *recordingAuthorizer) Authorize(a authorizer.Attributes) (authorized authorizer.Decision, reason string, err error) {
t.attributes = a
return false, "", nil
return authorizer.DecisionDeny, "", nil
}
6 changes: 3 additions & 3 deletions pkg/authorization/authorizer/scope/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ func NewAuthorizer(delegate authorizer.Authorizer, clusterRoleGetter rbaclisters
return &scopeAuthorizer{delegate: delegate, clusterRoleGetter: clusterRoleGetter, forbiddenMessageMaker: forbiddenMessageMaker}
}

func (a *scopeAuthorizer) Authorize(attributes authorizer.Attributes) (bool, string, error) {
func (a *scopeAuthorizer) Authorize(attributes authorizer.Attributes) (authorizer.Decision, string, error) {
user := attributes.GetUser()
if user == nil {
return false, "", fmt.Errorf("user missing from context")
return authorizer.DecisionDeny, "", fmt.Errorf("user missing from context")
}

scopes := user.GetExtra()[authorizationapi.ScopesKey]
Expand All @@ -52,5 +52,5 @@ func (a *scopeAuthorizer) Authorize(attributes authorizer.Attributes) (bool, str
denyReason = err.Error()
}

return false, fmt.Sprintf("scopes %v prevent this action; %v", scopes, denyReason), kerrors.NewAggregate(nonFatalErrors)
return authorizer.DecisionDeny, fmt.Sprintf("scopes %v prevent this action; %v", scopes, denyReason), kerrors.NewAggregate(nonFatalErrors)
}
9 changes: 6 additions & 3 deletions pkg/authorization/authorizer/scope/authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestAuthorize(t *testing.T) {
attributes kauthorizer.AttributesRecord
delegateAuthAllowed bool
expectedCalled bool
expectedAllowed bool
expectedAllowed kauthorizer.Decision
expectedErr string
expectedMsg string
}{
Expand Down Expand Up @@ -157,9 +157,12 @@ type fakeAuthorizer struct {
called bool
}

func (a *fakeAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (bool, string, error) {
func (a *fakeAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (kauthorizer.Decision, string, error) {
a.called = true
return a.allowed, "", nil
if a.allowed {
return kauthorizer.DecisionAllow, "", nil
}
return kauthorizer.DecisionDeny, "", nil
}

func (a *fakeAuthorizer) GetAllowedSubjects(attributes kauthorizer.Attributes) (sets.String, sets.String, error) {
Expand Down
22 changes: 11 additions & 11 deletions pkg/authorization/registry/localsubjectaccessreview/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ type subjectAccessTest struct {
}

type testAuthorizer struct {
allowed bool
allowed kauthorizer.Decision
reason string
err string

actualAttributes kauthorizer.Attributes
}

func (a *testAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (allowed bool, reason string, err error) {
func (a *testAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (authorized kauthorizer.Decision, reason string, err error) {
// allow the initial check for "can I run this SAR at all"
if passedAttributes.GetResource() == "localsubjectaccessreviews" {
return true, "", nil
return kauthorizer.DecisionAllow, "", nil
}

a.actualAttributes = passedAttributes
Expand All @@ -53,7 +53,7 @@ func (a *testAuthorizer) GetAllowedSubjects(passedAttributes kauthorizer.Attribu
func TestNoNamespace(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: false,
allowed: kauthorizer.DecisionDeny,
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Action: authorizationapi.Action{
Expand All @@ -72,7 +72,7 @@ func TestNoNamespace(t *testing.T) {

func TestConflictingNamespace(t *testing.T) {
authorizer := &testAuthorizer{
allowed: false,
allowed: kauthorizer.DecisionDeny,
}
reviewRequest := &authorizationapi.LocalSubjectAccessReview{
Action: authorizationapi.Action{
Expand All @@ -98,7 +98,7 @@ func TestConflictingNamespace(t *testing.T) {
func TestEmptyReturn(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: false,
allowed: kauthorizer.DecisionDeny,
reason: "because reasons",
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Expand All @@ -123,7 +123,7 @@ func TestEmptyReturn(t *testing.T) {
func TestNoErrors(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestErrors(t *testing.T) {
func TestRegularWithScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestRegularWithScopes(t *testing.T) {
func TestSelfWithDefaultScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Expand Down Expand Up @@ -228,7 +228,7 @@ func TestSelfWithDefaultScopes(t *testing.T) {
func TestSelfWithClearedScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.LocalSubjectAccessReview{
Expand Down Expand Up @@ -259,7 +259,7 @@ func (r *subjectAccessTest) runTest(t *testing.T) {

expectedResponse := &authorizationapi.SubjectAccessReviewResponse{
Namespace: r.reviewRequest.Action.Namespace,
Allowed: r.authorizer.allowed,
Allowed: r.authorizer.allowed == kauthorizer.DecisionAllow,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denied: r.authorizer.allowed == kauthorizer.DecisionDeny,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denied: r.authorizer.allowed == kauthorizer.DecisionDeny,

Not for our object.

Reason: r.authorizer.reason,
EvaluationError: r.authorizer.err,
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/authorization/registry/resourceaccessreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func (r *REST) isAllowed(user user.Info, rar *authorizationapi.ResourceAccessRev
Resource: "localresourceaccessreviews",
ResourceRequest: true,
}
allowed, reason, err := r.authorizer.Authorize(localRARAttributes)
authorized, reason, err := r.authorizer.Authorize(localRARAttributes)

if err != nil {
return kapierrors.NewForbidden(authorizationapi.Resource(localRARAttributes.GetResource()), localRARAttributes.GetName(), err)
}
if !allowed {
if authorized != kauthorizer.DecisionAllow {
forbiddenError := kapierrors.NewForbidden(authorizationapi.Resource(localRARAttributes.GetResource()), localRARAttributes.GetName(), errors.New("") /*discarded*/)
forbiddenError.ErrStatus.Message = reason
return forbiddenError
Expand Down
8 changes: 4 additions & 4 deletions pkg/authorization/registry/resourceaccessreview/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ type testAuthorizer struct {
actualAttributes kauthorizer.Attributes
}

func (a *testAuthorizer) Authorize(attributes kauthorizer.Attributes) (allowed bool, reason string, err error) {
func (a *testAuthorizer) Authorize(attributes kauthorizer.Attributes) (allowed kauthorizer.Decision, reason string, err error) {
// allow the initial check for "can I run this RAR at all"
if attributes.GetResource() == "localresourceaccessreviews" {
if len(a.deniedNamespaces) != 0 && a.deniedNamespaces.Has(attributes.GetNamespace()) {
return false, "denied initial check", nil
return kauthorizer.DecisionDeny, "denied initial check", nil
}

return true, "", nil
return kauthorizer.DecisionAllow, "", nil
}

return false, "", errors.New("unsupported")
return kauthorizer.DecisionDeny, "", errors.New("unsupported")
}
func (a *testAuthorizer) GetAllowedSubjects(passedAttributes kauthorizer.Attributes) (sets.String, sets.String, error) {
a.actualAttributes = passedAttributes
Expand Down
8 changes: 4 additions & 4 deletions pkg/authorization/registry/subjectaccessreview/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ rest.Validat
}

attributes := util.ToDefaultAuthorizationAttributes(userToCheck, subjectAccessReview.Action.Namespace, subjectAccessReview.Action)
allowed, reason, err := r.authorizer.Authorize(attributes)
authorized, reason, err := r.authorizer.Authorize(attributes)
response := &authorizationapi.SubjectAccessReviewResponse{
Namespace: subjectAccessReview.Action.Namespace,
Allowed: allowed,
Allowed: authorized == kauthorizer.DecisionAllow,
Reason: reason,
}
if err != nil {
Expand Down Expand Up @@ -144,12 +144,12 @@ func (r *REST) isAllowed(user user.Info, sar *authorizationapi.SubjectAccessRevi
}
}

allowed, reason, err := r.authorizer.Authorize(localSARAttributes)
authorized, reason, err := r.authorizer.Authorize(localSARAttributes)

if err != nil {
return kapierrors.NewForbidden(authorizationapi.Resource(localSARAttributes.GetResource()), localSARAttributes.GetName(), err)
}
if !allowed {
if authorized != kauthorizer.DecisionAllow {
forbiddenError := kapierrors.NewForbidden(authorizationapi.Resource(localSARAttributes.GetResource()), localSARAttributes.GetName(), errors.New("") /*discarded*/)
forbiddenError.ErrStatus.Message = reason
return forbiddenError
Expand Down
22 changes: 11 additions & 11 deletions pkg/authorization/registry/subjectaccessreview/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ type subjectAccessTest struct {
}

type testAuthorizer struct {
allowed bool
allowed kauthorizer.Decision
reason string
err string
deniedNamespaces sets.String

actualAttributes kauthorizer.Attributes
}

func (a *testAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (allowed bool, reason string, err error) {
func (a *testAuthorizer) Authorize(passedAttributes kauthorizer.Attributes) (allowed kauthorizer.Decision, reason string, err error) {
// allow the initial check for "can I run this SAR at all"
if passedAttributes.GetResource() == "localsubjectaccessreviews" {
if len(a.deniedNamespaces) != 0 && a.deniedNamespaces.Has(passedAttributes.GetNamespace()) {
return false, "denied initial check", nil
return kauthorizer.DecisionDeny, "denied initial check", nil
}

return true, "", nil
return kauthorizer.DecisionAllow, "", nil
}

a.actualAttributes = passedAttributes
Expand All @@ -58,7 +58,7 @@ func (a *testAuthorizer) GetAllowedSubjects(passedAttributes kauthorizer.Attribu
func TestDeniedNamespace(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: false,
allowed: kauthorizer.DecisionDeny,
err: "denied initial check",
deniedNamespaces: sets.NewString("foo"),
},
Expand All @@ -80,7 +80,7 @@ func TestDeniedNamespace(t *testing.T) {
func TestEmptyReturn(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: false,
allowed: kauthorizer.DecisionDeny,
reason: "because reasons",
},
reviewRequest: &authorizationapi.SubjectAccessReview{
Expand All @@ -104,7 +104,7 @@ func TestEmptyReturn(t *testing.T) {
func TestNoErrors(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.SubjectAccessReview{
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestErrors(t *testing.T) {
func TestRegularWithScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.SubjectAccessReview{
Expand Down Expand Up @@ -178,7 +178,7 @@ func TestRegularWithScopes(t *testing.T) {
func TestSelfWithDefaultScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.SubjectAccessReview{
Expand All @@ -205,7 +205,7 @@ func TestSelfWithDefaultScopes(t *testing.T) {
func TestSelfWithClearedScopes(t *testing.T) {
test := &subjectAccessTest{
authorizer: &testAuthorizer{
allowed: true,
allowed: kauthorizer.DecisionAllow,
reason: "because good things",
},
reviewRequest: &authorizationapi.SubjectAccessReview{
Expand Down Expand Up @@ -235,7 +235,7 @@ func (r *subjectAccessTest) runTest(t *testing.T) {

expectedResponse := &authorizationapi.SubjectAccessReviewResponse{
Namespace: r.reviewRequest.Action.Namespace,
Allowed: r.authorizer.allowed,
Allowed: r.authorizer.allowed == kauthorizer.DecisionAllow,
Reason: r.authorizer.reason,
EvaluationError: r.authorizer.err,
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/cmd/server/handlers/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (
"net/http"

restful "github.com/emicklei/go-restful"
"k8s.io/kubernetes/pkg/api/legacyscheme"

kapierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
kauthorizer "k8s.io/apiserver/pkg/authorization/authorizer"
coreapi "k8s.io/kubernetes/pkg/apis/core"
)

type bypassAuthorizer struct {
Expand All @@ -27,9 +29,9 @@ func NewBypassAuthorizer(auth kauthorizer.Authorizer, paths ...string) kauthoriz
return bypassAuthorizer{paths: sets.NewString(paths...), authorizer: auth}
}

func (a bypassAuthorizer) Authorize(attributes kauthorizer.Attributes) (allowed bool, reason string, err error) {
func (a bypassAuthorizer) Authorize(attributes kauthorizer.Attributes) (allowed kauthorizer.Decision, reason string, err error) {
if !attributes.IsResourceRequest() && a.paths.Has(attributes.GetPath()) {
return true, "always allowed", nil
return kauthorizer.DecisionAllow, "always allowed", nil
}
return a.authorizer.Authorize(attributes)
}
Expand Down Expand Up @@ -57,7 +59,7 @@ func Forbidden(reason string, attributes kauthorizer.Attributes, w http.Response
forbiddenError.ErrStatus.Message = reason

formatted := &bytes.Buffer{}
output, err := runtime.Encode(legacyscheme.Codecs.LegacyCodec(legacyscheme.SchemeGroupVersion), &forbiddenError.ErrStatus)
output, err := runtime.Encode(legacyscheme.Codecs.LegacyCodec(coreapi.SchemeGroupVersion), &forbiddenError.ErrStatus)
if err != nil {
fmt.Fprintf(formatted, "%s", forbiddenError.Error())
} else {
Expand Down
Loading