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

scoped tokens #8393

Merged
merged 2 commits into from
May 10, 2016
Merged

scoped tokens #8393

merged 2 commits into from
May 10, 2016

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Apr 6, 2016

This demonstrates how scopes could be attached to a user token and then filtered by an authorizer that wraps our existing authorizer. It creates:

  1. special:whoami - call users/~ to prove identity
  2. special:access-check - call self-SARs to check access of the user (not the token)
  3. clusterrole:<clusterrole name>:<namespace to allow the cluster role, * means all> - allows access based on cluster role rules, but only within the specified namespace. (I might make that a comma-delimited list.)

If we like the general approach, I can finish off the list:

  • unit tests
  • integration tests that create scoped tokens

And do the followups:

@pweil- @liggitt @smarterclayton
@jwforres @jimmidyson @stefwalter you guys knew people who were looking to get openshift API tokens to perform actions for a user, right?

@smarterclayton
Copy link
Contributor

Aren't there scope names defined in oauth that we have to support as well?
Do we need aliases for them?

On Wed, Apr 6, 2016 at 4:05 PM, David Eads [email protected] wrote:

This demonstrates how scopes could be attached to a user and then filtered
by an authorizer that wraps our existing authorizer. It creates:

  1. special:whoami - call users/~ to prove identity
  2. special:access-check - call self-SARs to check access of the user
    (not the token)
  3. clusterrole::<namespace to allow the cluster
    role, * means all> - allows access based on cluster role rules, but
    only within the specified namespace. (I might make that a comma-delimited
    list.)

If we like the general approach, I can finish off the list:

  • unit tests
  • integration tests that create scoped tokens

And do the followups:

  • make SARs scope aware
  • make TSARs for checking a token
  • add the other two scope types (namespace-wide and cluster-wide
    explicit)

@pweil- https://github.com/pweil- @liggitt https://github.com/liggitt
@smarterclayton https://github.com/smarterclayton
@jwforres https://github.com/jwforres @jimmidyson
https://github.com/jimmidyson @stefwalter
https://github.com/stefwalter you guys knew people who were looking to

get openshift API tokens to perform actions for a user, right?

You can view, comment on, or merge this pull request online at:

#8393
Commit Summary

  • add scope authorizer
  • UPSTREAM: 23574: add user.Info.GetExtra

File Changes

Patch Links:


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8393

@smarterclayton
Copy link
Contributor

Also, Peter the Great is not amused.

On Wed, Apr 6, 2016 at 4:48 PM, Clayton Coleman [email protected] wrote:

Aren't there scope names defined in oauth that we have to support as
well? Do we need aliases for them?

On Wed, Apr 6, 2016 at 4:05 PM, David Eads [email protected]
wrote:

This demonstrates how scopes could be attached to a user and then
filtered by an authorizer that wraps our existing authorizer. It creates:

  1. special:whoami - call users/~ to prove identity
  2. special:access-check - call self-SARs to check access of the user
    (not the token)
  3. clusterrole::<namespace to allow the cluster
    role, * means all> - allows access based on cluster role rules, but
    only within the specified namespace. (I might make that a comma-delimited
    list.)

If we like the general approach, I can finish off the list:

  • unit tests
  • integration tests that create scoped tokens

And do the followups:

  • make SARs scope aware
  • make TSARs for checking a token
  • add the other two scope types (namespace-wide and cluster-wide
    explicit)

@pweil- https://github.com/pweil- @liggitt https://github.com/liggitt
@smarterclayton https://github.com/smarterclayton
@jwforres https://github.com/jwforres @jimmidyson
https://github.com/jimmidyson @stefwalter
https://github.com/stefwalter you guys knew people who were looking to

get openshift API tokens to perform actions for a user, right?

You can view, comment on, or merge this pull request online at:

#8393
Commit Summary

  • add scope authorizer
  • UPSTREAM: 23574: add user.Info.GetExtra

File Changes

Patch Links:


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#8393

@liggitt
Copy link
Contributor

liggitt commented Apr 6, 2016

There are standard scopes in OIDC (https://openid.net/specs/openid-connect-basic-1_0.html#Scopes)

@deads2k
Copy link
Contributor Author

deads2k commented Apr 6, 2016

I'll need to reread the openid bits. I thought those were used by a client to request certain claims be provided. The user was still asked, but the token held the information, not any lasting access. If the access does have to be provided, chances are we need new endpoints to match the spec format, right?

func (a *scopeAuthorizer) Authorize(ctx kapi.Context, passedAttributes defaultauthorizer.AuthorizationAttributes) (bool, string, error) {
user, exists := kapi.UserFrom(ctx)
if !exists {
return false, "", fmt.Errorf("no user")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest a more descriptive error message here if there's any risk of it ending up at an API caller.

@stefwalter
Copy link
Contributor

@deads2k The main use case that registry users needed is a long lived token that they can plug into 'docker login'. That is, not have to run a docker login command with a new token every 24 hours.

Would we need the registry container need to be modified to do a special access check?

CC @aweiteka I believe this is about the long lived tokens you wanted earlier.

@deads2k
Copy link
Contributor Author

deads2k commented Apr 7, 2016

Would we need the registry container need to be modified to do a special access check?

This would allow a user to provide a token that is only good for manipulating images instead of trusting the registry with all their access, including things like modifying group membership as an example. This is also something we'd want for a user created token flow, but doesn't provide one in and of itself.

@deads2k
Copy link
Contributor Author

deads2k commented Apr 7, 2016

There are standard scopes in OIDC (https://openid.net/specs/openid-connect-basic-1_0.html#Scopes)

Yeah, we don't need to add those yet. This structure doesn't preclude them from working, but for now we aren't close to being an openID provider. If we want to be, that should be a separate objective.

@aweiteka
Copy link
Contributor

aweiteka commented Apr 7, 2016

This would allow a user to provide a token that is only good for manipulating images

The docker push/pull API commands are ultimately what I'm looking for supporting so this subset of permissions or access control sounds like it could satisfy that.

@deads2k
Copy link
Contributor Author

deads2k commented Apr 26, 2016

@openshift/api-review this is on my next list. Do we like the shape of these? It's basically, <category>:<category-specific-format>, which initial support for curated scopes and cluster-role scopes applied to a namespace.

@smarterclayton
Copy link
Contributor

If we supported OIDC in the future - those would be category-less?


tokens := strings.SplitN(scope, ":", 2)
if len(tokens) != 2 {
return nil, fmt.Errorf("bad format for %v", scope)
Copy link
Contributor

Choose a reason for hiding this comment

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

"bad format for scope %v" so I can find it when I have to debug it

@deads2k deads2k changed the title [POC] scoped tokens scoped tokens Apr 27, 2016
@deads2k
Copy link
Contributor Author

deads2k commented Apr 27, 2016

comments addressed, upstream pick update, tests written.

This is ready for review.

@liggitt you or a delegating victim?

@deads2k
Copy link
Contributor Author

deads2k commented Apr 28, 2016

[test]

@brianwcook
Copy link

what happens if you login using a long lived token when you have openid connect provider enabled?
You get a token and then the provider shuts off your account. Is this accounted for?

@deads2k
Copy link
Contributor Author

deads2k commented Apr 28, 2016

what happens if you login using a long lived token when you have openid connect provider enabled?

The cluster-admin determines the maximum token lifespan, so they determine long-livedness. Right now, there is no re-authentication check required for the lifespan of the token. I think its 24 hours by default.

This pull doesn't make the problem any better or worse.

@deads2k
Copy link
Contributor Author

deads2k commented Apr 29, 2016

@smarterclayton this blocks oauth exposure. How's the API?

@smarterclayton
Copy link
Contributor

I've seen worse. Approved.

@deads2k
Copy link
Contributor Author

deads2k commented Apr 29, 2016

I've seen worse. Approved.

I feel like I should find the movie review translating tool they use for commercials. :)

@pweil- got a reviewer in mind?

@pweil-
Copy link

pweil- commented Apr 29, 2016

@liggitt and @sgallagher PTAL and give a 👍 or 👎

// API discovery/negotiation
"/api", "/api/*",
"/apis", "/apis/*",
"/oapi", "/oapi/*",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make constants out of it, there's a TODO in master.go to have that prefix being configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we make constants out of it, there's a TODO in master.go to have that prefix being configurable.

done

@soltysh
Copy link
Contributor

soltysh commented Apr 29, 2016

@deads2k with yours and @liggitt explanation yesterday during planning and some time with your code I was able to grasp the idea. Thanks 🍺

SpecialIndicator = "special:"
ClusterRoleIndicator = "clusterrole:"
ClusterWideIndicator = "clusterwide:"
NamespaceWideIndicator = "namespace:"
Copy link
Contributor

@liggitt liggitt May 3, 2016

Choose a reason for hiding this comment

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

need to make sure we limit ourselves to valid characters for scopes (these are fine, just pointing it out)

  • no quote, no backslash, no space
  • colon, alphanumeric characters, comma is ok (full list of allowed chars is %x21 / %x23-5B / %x5D-7E)

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 3, 2016
@deads2k
Copy link
Contributor Author

deads2k commented May 4, 2016

So if I make a constant and eliminate the "special:" prefix (I still think we're likely to regret that some day. Unscoped things always cause problems eventually.), I'll get a merge?

@liggitt
Copy link
Contributor

liggitt commented May 5, 2016

I'm ok with the approach. possible name adjustments:

specific scopes:

user:info
user:check-access

parameterized scopes:

role:<cluster role>:<effective namespace>
role:<cluster role>:*

eventually:

user:create-token
user:request-project
local-role:<role>:<namespace>

followups:

  • tighten clusterrole/role name validation to the set of characters allowed in scope names? may not be possible... failing validation on one role would prevent the entire policy from being persisted
  • expand scope evaluator interface to provide human descriptions for scopes (used in grant flow)
  • expand scope evaluator interface to provide validation (used when requesting scopes or validating a user-created token)
  • prevent escalating resources from being included by default:
    • remove *, secrets, oauthtokens, oauthauthorizationtokens, etc
  • decide how a scope that grants a role including escalating resources would be specified

@deads2k
Copy link
Contributor Author

deads2k commented May 5, 2016

I'm ok with the approach. possible name adjustments:

Ok, those look fine.

@sgallagher all comments so far are minor and I'll take care of them tomorrow. Do you have anything structural?

@deads2k
Copy link
Contributor Author

deads2k commented May 9, 2016

comments address [merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented May 9, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/5860/) (Image: devenv-rhel7_4149)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2016
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to a85a7c6

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/3704/)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to a85a7c6

@openshift-bot openshift-bot merged commit 25f92f3 into openshift:master May 10, 2016
@deads2k deads2k deleted the scopes branch September 6, 2016 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants