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

Auth: Add OIDC identities to identity cache and extract identity provider groups #12827

Merged
merged 25 commits into from
Feb 12, 2024

Conversation

markylaing
Copy link
Contributor

This PR adds a new server configuration key oidc.groups_claim. If set, the value of this config key is:

  1. Added to the scope of the Authorization Code Flow (UI).
  2. Sent to the client as an X-LXD-OIDC-groups-claim header, to be added to the scope for the Device Authorization Grant Flow (CLI).
  3. The value of the claim represents the groups that the identity is a member of at the identity provider level. It is extracted from both identity tokens (UI) and access tokens (CLI) and is expected to be a string slice.
  4. Identity provider groups are added to the request context.
  5. Identity provider groups are forwarded to other cluster members in the X-LXD-forwarded-identity-provider-groups header. The value of this header is a JSON encoded string.
  6. Forwarded identity provider groups are also added to the request context.

#12816 must be merged first.

@markylaing markylaing self-assigned this Feb 6, 2024
@github-actions github-actions bot added Documentation Documentation needs updating API Changes to the REST API labels Feb 6, 2024
@tomponline tomponline changed the title Add OIDC identities to identity cache and extract identity provider groups Auth: Add OIDC identities to identity cache and extract identity provider groups Feb 8, 2024
@markylaing markylaing force-pushed the cache-oidc-identities branch 2 times, most recently from dfc9bb9 to 86eff12 Compare February 9, 2024 12:15
@markylaing markylaing marked this pull request as ready for review February 9, 2024 12:20
@markylaing
Copy link
Contributor Author

@tomponline this is ready for review now.

Also, do we prefer oidc.groups_claim or oidc.groups.claim for this config key?

@tomponline
Copy link
Member

oidc.groups.claim

I would say, as it allows us to use oidc.groups.foo later if needed

lxd/daemon.go Outdated Show resolved Hide resolved
lxd/daemon.go Outdated Show resolved Hide resolved
lxd/daemon.go Outdated Show resolved Hide resolved
lxd/cluster/connect.go Outdated Show resolved Hide resolved
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

A handful of nits/questions, overall looks great.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

Needs an API extension too please

lxd/daemon.go Outdated Show resolved Hide resolved
@markylaing
Copy link
Contributor Author

Needs an API extension too please

What would the extension be for? This doesn't add any functionality (yet). Or is it just because we're adding a new config key?

@tomponline
Copy link
Member

tomponline commented Feb 9, 2024

Needs an API extension too please

What would the extension be for? This doesn't add any functionality (yet). Or is it just because we're adding a new config key?

Yep the new config key is new functionality

@markylaing
Copy link
Contributor Author

Yep the new config key is new functionality

🤔 I suppose it is. You can set some config.

I'll update the PR on Monday and will add an API extension check in the client for adding this config key.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
This indicates to the client that it needs to request
the additional scope.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
AuthError implements xerrors.Wrapper so we can use that to inspect the
error instead of type assertion.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
@markylaing
Copy link
Contributor Author

@tomponline I've made the requested changes. I haven't checked for the oidc_groups_claim API extension when attempting to set this config key in the client because there doesn't seem to be any existing API extension checks for config keys.

Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

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

just an api extension commit change

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Signed-off-by: Mark Laing <mark.laing@canonical.com>
This is a false positive.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
@tomponline tomponline merged commit adfaa52 into canonical:main Feb 12, 2024
27 checks passed
markylaing added a commit to markylaing/lxd that referenced this pull request Feb 20, 2024
When the `oidc.groups.claim` config key was added in canonical#12827, the
logic governing optional configuration of the OIDC verifier was
incorrect. This caused the config expiry interval to be set to zero
if not passed in by the caller.

This caused the verifier to rotate the encryption keys of the relying party
on every call. These keys are used to encrypt the `state` and `pkce`
cookies that OIDC needs to work. As they had been rotated during the
OIDC flow, the callback handler to failed to decrypt the cookies, and so
login was failing.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
markylaing added a commit to markylaing/lxd that referenced this pull request Feb 20, 2024
When the `oidc.groups.claim` config key was added in canonical#12827, the
logic governing optional configuration of the OIDC verifier was
incorrect. This caused the config expiry interval to be set to zero
if not passed in by the caller.

This caused the verifier to rotate the encryption keys of the relying party
on every call. These keys are used to encrypt the `state` and `pkce`
cookies that OIDC needs to work. As they had been rotated during the
OIDC flow, the callback handler to failed to decrypt the cookies, and so
login was failing.

Signed-off-by: Mark Laing <mark.laing@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants