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

plugin/pkg/auth/authenticator/token/oidc: get groups from custom claim #21001

Merged
merged 1 commit into from
Feb 14, 2016

Conversation

ericchiang
Copy link
Contributor

This PR provides functionality that allows the current OpenID Connect plugin to optionally read user group membership from a custom JWT claim.

OpenID Connect permits custom claims as part of ID Tokens (document here). And this allows Kubernetes aware OpenID Connect providers to produce ID Tokens with group information.

cc: @erictune, @philips, @bobbyrullo

@k8s-bot
Copy link

k8s-bot commented Feb 10, 2016

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

1 similar comment
@k8s-bot
Copy link

k8s-bot commented Feb 10, 2016

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

@k8s-github-robot
Copy link

Labelling this PR as size/L

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 10, 2016
@brendandburns
Copy link
Contributor

reassigning to @erictune because auth.

@liggitt may also be interested.

info := &user.DefaultInfo{Name: username}

if a.groupsClaim != "" {
groups, ok, err := claims.StringsClaim(a.groupsClaim)
Copy link
Member

Choose a reason for hiding this comment

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

how does this handle a missing claim? I'd expect that to result in an empty groups list, not an auth error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only error scenario is when the claim is not an array of strings.

{}                               // No groups claim, no error.
{"groups": ["group1", "group2"]} // Good response, no error.
{"groups": "group1"}             // Malformed groups claim, this causes an error.

Idea being that if authn sees a custom groups claim, it's particular about how that claim is formatted.

We could just log an error and continue though, either way.

Copy link
Member

Choose a reason for hiding this comment

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

ah, ok, didn't dig into StringsClaim

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah sorry it's not super obvious. I'll add a comment.

@@ -165,6 +166,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.OIDCUsernameClaim, "oidc-username-claim", "sub", ""+
"The OpenID claim to use as the user name. Note that claims other than the default ('sub') is not "+
"guaranteed to be unique and immutable. This flag is experimental, please see the authentication documentation for further details.")
fs.StringVar(&s.OIDCGroupsClaim, "oidc-groups-claim", "", "If provided, the name of a custom OpenID Connect claim for specifying user groups. The claim value is expected to be an array of strings. This flag is experimental, please see the authentication documentation for further details.")
Copy link
Member

Choose a reason for hiding this comment

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

I take it that Dex is going to be the only IdP that implements this at first?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Keycloak would support this via the "group membership" client mapper as well ... Definitely worth a mention :-)

Copy link
Member

Choose a reason for hiding this comment

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

@erictune any chance you could lobby with Eric Sachs to have GApps support it? Right now you need to call the Directory API to obtain group membership information...

@erictune
Copy link
Member

lgtm

@erictune erictune added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 12, 2016
@k8s-github-robot
Copy link

@k8s-bot ok to test
@k8s-bot test this

pr builder appears to be missing, activating due to 'lgtm' label.

@k8s-bot
Copy link

k8s-bot commented Feb 12, 2016

GCE e2e test build/test passed for commit 92d37d5.

@k8s-github-robot
Copy link

The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?

@erictune
Copy link
Member

add to whitelist

@erictune
Copy link
Member

@k8s-merge-robot add-to-whitelist

@k8s-bot
Copy link

k8s-bot commented Feb 13, 2016

GCE e2e test build/test passed for commit 92d37d5.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Feb 14, 2016

GCE e2e test build/test passed for commit 92d37d5.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Feb 14, 2016

GCE e2e test build/test passed for commit 92d37d5.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

k8s-github-robot pushed a commit that referenced this pull request Feb 14, 2016
@k8s-github-robot k8s-github-robot merged commit 43fb544 into kubernetes:master Feb 14, 2016
@erictune erictune added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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

10 participants