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

Add scopes to OIDC configuration #1796

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeremydonahue
Copy link

@jeremydonahue jeremydonahue commented Apr 10, 2024

This allows the CLI to retrieve custom scopes from the provider for use when performing the oauth exchange to generate a token. Custom scopes are useful, for example, when using the OIDC provider with Dex and Github in that it allows the preferred_username or federated_claims.user_id fields to be returned with the token for use in SSH certificate templates (ie. to identify a Github user via extensions:login@github.com).

Example usage:
ca.json:

{
    "type": "OIDC",
    ...
    "scopes": ["openid","email","profile","federated:id"]
}

SSH template:

	"extensions": {
	  "id@github.com": {{ toJson .Token.federated_claims.user_id }}
	}

This will be followed up with a corresponding PR for smallstep/cli that makes use of the feature... update: smallstep/cli#1150

Name of feature:

Custom scopes for OIDC providers.

Pain or issue this feature alleviates:

The inability to use step-ca for generating ssh certificates for github when using Dex as an OIDC provider (Dex is configured to use the Github connector).

Why is this important to the project (if not answered above):

Answered above.

Is there documentation on how to use this feature? If so, where?

No, because I could not find where to update https://smallstep.com/docs/step-ca. If you point me in the right direction, I will happily update the docs.

In what environments or workflows is this feature supported?

OIDC providers.

In what environments or workflows is this feature explicitly NOT supported (if any)?

Non-OIDC providers.

Supporting links/other PRs/issues:

PR that makes use of the feature in the step CLI: smallstep/cli#1150

This allows the CLI to retrieve custom scopes from the provider for use
when performing the oauth exchange to generate a token. Custom scopes
are useful, for example, when using the OIDC provider with Dex and
Github in that it allows the preferred_username or
federated_claims.user_id fields to be returned with the token for use in
SSH certificate templates (ie. to identify a Github user via
`extensions:login@github.com`).
@CLAassistant
Copy link

CLAassistant commented Apr 10, 2024

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the needs triage Waiting for discussion / prioritization by team label Apr 10, 2024
@jeremydonahue
Copy link
Author

Oh, one more note, I saw that the contributing guidelines say there should be an addition to the changelog, which I am happy to do, but I wasn't sure how to do that given that I imagine multiple features/bugfixes/etc will be included in one release.

jeremydonahue added a commit to jeremydonahue/cli that referenced this pull request Apr 10, 2024
This allows the provider to specify custom scopes that should be used
when generating OIDC tokens. This is useful when, for example, when
using the OIDC provider with Dex and Github in that it allows the
preferred_username or federated_claims.user_id fields to be returned
with the token for use in SSH certificate templates (ie. to identify a
Github user via extensions:login@github.com).

Note that this feature depends on
smallstep/certificates#1796 being merged to
provide the `Scopes` field on `providers.OIDC`.
jeremydonahue added a commit to jeremydonahue/cli that referenced this pull request Apr 10, 2024
This allows the provider to specify custom scopes that should be used
when generating OIDC tokens. This is useful when, for example, when
using the OIDC provider with Dex and Github in that it allows the
preferred_username or federated_claims.user_id fields to be returned
with the token for use in SSH certificate templates (ie. to identify a
Github user via extensions:login@github.com).

Note that this feature depends on
smallstep/certificates#1796 being merged to
provide the `Scopes` field on `providers.OIDC`.
@maraino
Copy link
Contributor

maraino commented Apr 16, 2024

Hi @jeremydonahue,

We will accept your contribution, but this PR and smallstep/cli#1150 are not complete, as they do not allow the configuration of the provisioners using a database or a linked CA.

Right now, I can think of:

We can work on the rest of the updates, but it might take some time. Or you can work on a more complete version.

As a current workaround, you can edit the $(step path)/config/defaults.json on the client side and add the scopes there as this:

{
  "...": "...",
  "scope": ["openid","email","profile","federated:id"]
}

@jeremydonahue
Copy link
Author

@maraino Hi, thanks for your response, and sorry for the delay (I was on vacation). I'm happy to update this to be more complete. However, I see that @jdoupe has already done so in their set of PRs. Would you still like me to do so here, or is that sufficient? Disclaimer: I have not reviewed their PRs closely.

@maraino
Copy link
Contributor

maraino commented Apr 29, 2024

@jeremydonahue I've seen that @jdoupe has added your contribution too, but I haven't had time to review them yet.

@jdoupe
Copy link

jdoupe commented Apr 29, 2024

@jeremydonahue - Sorry to have coopted your change. I'm not sure why I hadn't really thought to include that in my original thought anyway (I actually do, but long story ;) ), but definitely seemed like the "thing to do" since I was updating all the same pieces anyway.

@hslatman hslatman self-assigned this Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Waiting for discussion / prioritization by team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants