Skip to content

Convert subjectchecker to use rbac.Subject - #16286

Merged
openshift-merge-robot merged 1 commit into
openshift:masterfrom
simo5:subjectcheck
Sep 16, 2017
Merged

openshift-merge-robot merged 1 commit into
openshift:masterfrom
simo5:subjectcheck

Conversation

@simo5

@simo5 simo5 commented Sep 11, 2017 •

Copy link
Copy Markdown

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

simo5 commented Sep 11, 2017

Copy link
Copy Markdown
Author

@enj PTAL

@enj

enj commented Sep 11, 2017

Copy link
Copy Markdown
Contributor

I added #16259 as a fixed bug as well.

@simo5

simo5 commented Sep 11, 2017

Copy link
Copy Markdown
Author

@enj oh right, thanks!

// service account) are allowed in a project.
type SubjectChecker interface {
Allowed(kapi.ObjectReference, *RoleBindingRestrictionContext) (bool, error)
Allowed(rbac.Subject, *RoleBindingRestrictionContext) (bool, error)

Copy link
Copy Markdown
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
Copy Markdown
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

enj commented Sep 11, 2017

Copy link
Copy Markdown
Contributor

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

simo5 commented Sep 11, 2017

Copy link
Copy Markdown
Author

/retest

@simo5

simo5 commented Sep 11, 2017

Copy link
Copy Markdown
Author

Flaked on #16273

@simo5

simo5 commented Sep 11, 2017

Copy link
Copy Markdown
Author

/retest

Miciah
Miciah previously requested changes Sep 12, 2017

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

Copy link
Copy Markdown
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.


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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

deads2k commented Sep 12, 2017

Copy link
Copy Markdown
Contributor

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

simo5 commented Sep 12, 2017

Copy link
Copy Markdown
Author

@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

deads2k commented Sep 12, 2017

Copy link
Copy Markdown
Contributor

@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 <[email protected]>
@simo5

simo5 commented Sep 15, 2017

Copy link
Copy Markdown
Author

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

@deads2k

deads2k commented Sep 15, 2017

Copy link
Copy Markdown
Contributor

/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
Copy Markdown
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.

Details 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

simo5 commented Sep 15, 2017

Copy link
Copy Markdown
Author

/retest

@openshift-merge-robot

Copy link
Copy Markdown
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.

9 participants