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

Convert subjectchecker to use rbac.Subject #16286

Merged
merged 1 commit into from Sep 16, 2017

Conversation

simo5
Copy link
Contributor

@simo5 simo5 commented Sep 11, 2017

This also removes any distinction between System and regular User/Groups, as that distinction is gone with RBAC RoleBindings.

Fixes #16032
Fixes #16259

@simo5 simo5 requested a review from deads2k September 11, 2017 16:55
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 11, 2017
@simo5
Copy link
Contributor Author

simo5 commented Sep 11, 2017

@enj PTAL

@enj
Copy link
Contributor

enj commented Sep 11, 2017

I added #16259 as a fixed bug as well.

@simo5
Copy link
Contributor Author

simo5 commented Sep 11, 2017

@enj oh right, thanks!

@@ -18,7 +18,7 @@ import (
// SubjectChecker determines whether rolebindings on a subject (user, group, or
// service account) are allowed in a project.
type SubjectChecker interface {
Allowed(kapi.ObjectReference, *RoleBindingRestrictionContext) (bool, error)
Allowed(rbac.Subject, *RoleBindingRestrictionContext) (bool, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this should be Allowed(subject *rbac.Subject, ctx *RoleBindingRestrictionContext) (allowed bool, err error)

*rbac.Subject instead of rbac.Subject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes it impossible to pass in nil, and basically just maintaining the previous interface, not a hard reason, but also saw no reason to change it, Subjects are pretty small

@enj
Copy link
Contributor

enj commented Sep 11, 2017

LGTM just a minor thought.

/approve

@deads2k sanity check please.

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 11, 2017
@enj enj assigned deads2k and unassigned soltysh Sep 11, 2017
@simo5
Copy link
Contributor Author

simo5 commented Sep 11, 2017

/retest

@simo5
Copy link
Contributor Author

simo5 commented Sep 11, 2017

Flaked on #16273

@simo5
Copy link
Contributor Author

simo5 commented Sep 11, 2017

/retest

Miciah
Miciah previously requested changes Sep 12, 2017
@@ -167,7 +154,7 @@ func (checker UserSubjectChecker) Allowed(subject kapi.ObjectReference, ctx *Rol
}

// System users can match only by name.
if subject.Kind != authorizationapi.UserKind {
if subject.Kind != rbac.UserKind {
Copy link
Contributor

Choose a reason for hiding this comment

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

The entire if block and comment should be deleted. Its purpose was to skip checking groups and selectors for system users, but now it is redundant.

@@ -233,7 +219,7 @@ func (checker GroupSubjectChecker) Allowed(subject kapi.ObjectReference, ctx *Ro
}

// System groups can match only by name.
if subject.Kind != authorizationapi.GroupKind {
if subject.Kind != rbac.GroupKind {
Copy link
Contributor

Choose a reason for hiding this comment

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

This entire if block and comment are now redundant and should be deleted.

}

if subject.Kind != authorizationapi.UserKind {
func (ctx *RoleBindingRestrictionContext) labelSetForUser(subject rbac.Subject) (labels.Set, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are NotFoundErrors well tolerated by callers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seem like all errors are tolerated equally as they are all printed and gathered in a composed error

@deads2k
Copy link
Contributor

deads2k commented Sep 12, 2017

SystemUsers will fail user resource lookups. I think its fine since it fails tighter instead of looser, but there should probably be a test making sure that still works as expected.

@simo5
Copy link
Contributor Author

simo5 commented Sep 12, 2017

@deads2k can you propose a test that would check it ? (pseudo code is fine)

@simo5 simo5 dismissed Miciah’s stale review September 12, 2017 18:40

removed duplicate checks, thanks!

@deads2k
Copy link
Contributor

deads2k commented Sep 12, 2017

@deads2k can you propose a test that would check it ? (pseudo code is fine)

binding a user without any user object (like system:anything-here) should not fail admission if it is specifically listed as an allowed user. I don't remember what the code actually does, it may actually do that and only return the NotFoundError if it fails

This also removes any distinction between System and regular User/Groups,
as that distinction is gone with RBAC RoleBindings.

Signed-off-by: Simo Sorce <simo@redhat.com>
@simo5
Copy link
Contributor Author

simo5 commented Sep 15, 2017

@deads2k can you check if the additional test is ok and lgtm ?

@deads2k
Copy link
Contributor

deads2k commented Sep 15, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 15, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, enj, simo5

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@simo5
Copy link
Contributor Author

simo5 commented Sep 15, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 16384, 16327, 16199, 16286, 16378)

@openshift-merge-robot openshift-merge-robot merged commit 61099d2 into openshift:master Sep 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants