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

switch to upstream impersonation #16155

Merged

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Sep 5, 2017

This switches us onto the upstream impersonation filter. That means a couple noteworthy things:

  1. we no longer have separate permissions for impersonating system users (just like upstream)
  2. if you granted powers for particular systemusers, you need to add to your role.
  3. we no longer auto-add known openshift groups. You can specify --as-groups if you need the power. Our examples are users granted powers as users.

@openshift/sig-security
@liggitt as we discussed.

impersonation no longer applies group information automatically, so you may need to use `--as-groups` and now all users and groups are authorized against "users" or "groups", not "systemusers" or "systemgroups", so you may need to update roles

@deads2k deads2k assigned enj and simo5 Sep 5, 2017
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 5, 2017
@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 5, 2017
@simo5
Copy link
Contributor

simo5 commented Sep 5, 2017

Is this going to cause upgrade issues on existing clusters ?

@enj
Copy link
Contributor

enj commented Sep 5, 2017

we no longer have separate permissions for impersonating system users (just like upstream)

I liked having the distinction, but it is probably is not worth the cost to maintain / be different than kube.

if you granted powers for particular systemusers, you need to add to your role.

This is a breaking change, so I assume we need to have something to reconcile this?

we no longer auto-add known openshift groups. You can specify --as-groups if you need the power. Our examples are users granted powers as users.

This is probably going to annoy / break people in general. Some specific issues I can see are the differences between user foo does a can-i vs user bar impersonating user foo does a can-i. Basically, the more you use groups, the more confusing this change will be.


With all of that said, impersonation is a very powerful and rarely used (by normal users) feature. So we may be able to get away with this. But I feel like we did not have release notes around this in 3.6, so it seems out of place to have such drastic changes.

@deads2k
Copy link
Contributor Author

deads2k commented Sep 5, 2017

This is a breaking change, so I assume we need to have something to reconcile this?

This pull adds the permission for the stock roles (only one). I suspect it's extremely uncommon. If you wanted to make a migration tool it would be possible.

Is this going to cause upgrade issues on existing clusters ?

It's possible, though fairly unlikely. It's an advanced use-case, it's not recommended for normal operation other than sudoer (which will still work), and no users can do it by default.

With all of that said, impersonation is a very powerful and rarely used (by normal users) feature. So we may be able to get away with this. But I feel like we did not have release notes around this in 3.6, so it seems out of place to have such drastic changes.

We will do it at some point, it's just a question of when you pull off the bandaid. Now seems as good a time as any. The CLI already has the updates required to describe what needs changing.

@liggitt
Copy link
Contributor

liggitt commented Sep 5, 2017

The release where we switch to upstream RBAC objects is a sensible time to make this change as well, given that upstream bindings don't have system users and system groups. I think the benefit of consistency with upstream and the limited impact make this a reasonable time to make the switch. We should still document it well in the release notes.

@enj
Copy link
Contributor

enj commented Sep 6, 2017

@smarterclayton @pweil- @eparis any comments?

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

+1 on my end

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 6, 2017
@@ -13,7 +13,7 @@ os::test::junit::declare_suite_start "cmd/quota"

os::test::junit::declare_suite_start "cmd/quota/clusterquota"

os::cmd::expect_success 'oc new-project quota-foo --as=deads'
os::cmd::expect_success 'oc new-project quota-foo --as=deads --as-group=system:authenticated --as-group=system:authenticated:oauth'
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 is probably the most painful part of the switch. We have a non-standard group applied to our oauth users and we use it only for project requests.

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

I added the translation for the existing scope headers and opened #16175 to fix our hardcoded clients to work against both openshift and kube.

@@ -924,6 +932,11 @@ func GetOpenshiftBootstrapClusterRoleBindings() []rbac.ClusterRoleBinding {
newOriginClusterBinding(MasterRoleBindingName, MasterRoleName).
Groups(MastersGroup).
BindingOrDie(),
// Everyone should be able to add a scope to their impersonation request. It is purely tightening.
// This does not grant access to impersonate in general, only tighten if you already have permission.
newOriginClusterBinding(ScopeImpersonationRoleName, ScopeImpersonationRoleName).
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use rbac.NewClusterBinding directly since do not need the origin wrapper.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just use rbac.NewClusterBinding directly since do not need the origin wrapper.

This just matches the others around it

Copy link
Contributor

Choose a reason for hiding this comment

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

We already use rbac.NewClusterBinding in the places where the role and binding have the same name (there is at least one like that near the bottom).

// TranslateLegacyScopeImpersonation is a filter that will translates user scope impersonation for openshift into the equivalent kube headers.
func TranslateLegacyScopeImpersonation(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
for _, scope := range req.Header[authenticationapi.ImpersonateUserScopeHeader] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete the original headers when you are done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Delete the original headers when you are done?

I was going for as little mutation as possible. I could if you really want though.

Copy link
Contributor

Choose a reason for hiding this comment

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

as little mutation as possible

Sounds reasonable enough to me.

@enj
Copy link
Contributor

enj commented Sep 6, 2017

I think in regards to dropping groups in impersonation, there is not much we can do to make the transition better. Since it will be annoying no matter when we do it, 3.7 seems a reasonable time as any (with the appropriate release notes).


In regards to the system[users|groups] distinction we could:

In 3.7:

  1. Do everything is this PR
  2. Have good 3.7 release notes around the deprecation of using system[users|groups] in impersonation {cluster}roles
  3. Extend newAuthorizationAttributeBuilder with another RequestInfoResolver that automatically converts systemusers to users and systemgroups to groups if the verb is impersonate

In 3.8:

  1. We drop the new RequestInfoResolver
  2. We drop the constants for system[users|groups], and completely remove the concept from the API (conversion, roles, etc)
  3. We add a 3.8 ansible pre-upgrade check (so 3.7 to 3.8) that fails the upgrade if any impersonation {cluster}roles exist that reference system[users|groups]

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

In 3.8:

We drop the new RequestInfoResolver
We drop the constants for system[users|groups], and completely remove the concept from the API (conversion, roles, etc)
We add a 3.8 ansible pre-upgrade check (so 3.7 to 3.8) that fails the upgrade if any impersonation {cluster}roles exist that reference system[users|groups]

Why wouldn't we pull the bandaid off all at once. Doing it like this is likely to break people once for the "no auto groups" change in 3.7 and again for the "you forgot to change your role" in 3.8.

I wouldn't recommend doing the ansible pre-upgrade check since tightening rules hasn't been done in the field yet.

@enj
Copy link
Contributor

enj commented Sep 6, 2017

Why wouldn't we pull the bandaid off all at once. Doing it like this is likely to break people once for the "no auto groups" change in 3.7 and again for the "you forgot to change your role" in 3.8.

If we want to break people as little as possible, then a new permanent RequestInfoResolver seems appropriate.

I wouldn't recommend doing the ansible pre-upgrade check since tightening rules hasn't been done in the field yet.

We could make the check smarter by only failing if system[users|groups] exist without the matching [users|groups].

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

If we want to break people as little as possible, then a new permanent RequestInfoResolver seems appropriate.

But that's not what you'll be doing. Say a year from now we're running on top of kube. You'll break them all again right there. This change isn't about us tweaking things for our special snowflake to make it prettier. It's about getting rid of the snowflake entirely.

@deads2k
Copy link
Contributor Author

deads2k commented Sep 6, 2017

Extend newAuthorizationAttributeBuilder with another RequestInfoResolver that automatically converts systemusers to users and systemgroups to groups if the verb is impersonate

What would this do anyway? The old rules are going to grant powers to systemusers, so this would be stomping the wrong direction. Doing it in the reverse direction would break every existing users rule. It doesn't seem like it works.

@enj
Copy link
Contributor

enj commented Sep 6, 2017

What would this do anyway? The old rules are going to grant powers to systemusers, so this would be stomping the wrong direction. Doing it in the reverse direction would break every existing users rule. It doesn't seem like it works.

My head hurts.


@deads2k has convinced me on IRC that this is the way to go.

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@deads2k deads2k added lgtm Indicates that a PR is ready to be merged. and removed lgtm Indicates that a PR is ready to be merged. labels Sep 6, 2017
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 16098, 16155)

openshift-merge-robot added a commit that referenced this pull request Sep 7, 2017
Automatic merge from submit-queue (batch tested with PRs 16098, 16155)

switch to upstream impersonation

This switches us onto the upstream impersonation filter.  That means a couple noteworthy things:

 1. we no longer have separate permissions for impersonating system users (just like upstream)
 2. if you granted powers for particular systemusers, you need to add to your role.
 3. we no longer auto-add known openshift groups.  You can specify --as-groups if you need the power.  Our examples are users granted powers as users.

@openshift/sig-security 
@liggitt as we discussed.

```release-note
impersonation no longer applies group information automatically, so you may need to use `--as-groups` and now all users and groups are authorized against "users" or "groups", not "systemusers" or "systemgroups", so you may need to update roles
```
@openshift-merge-robot openshift-merge-robot merged commit 664f7ea into openshift:master Sep 7, 2017
@deads2k deads2k deleted the server-41-impersonation branch January 24, 2018 14:33
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. needs-api-review size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants