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

verify access tokens by checking getuserinfo during a token exchange #3031

Merged
merged 1 commit into from Aug 1, 2023

Conversation

seankhliao
Copy link
Contributor

Overview

Followup on #2806 for better access token handling.
verify access tokens by checking getuserinfo during a token exchange

What this PR does / why we need it

The provider.Verifier.Verify endpoint we were using only works with ID tokens. This isn't an issue with systems which use ID tokens as access tokens (e.g. dex), but for systems with opaque access tokens (e.g. Google / GCP), those access tokens could not be verified. Instead, check the access token against the getUserInfo endpoint.

Special notes for your reviewer

Does this PR introduce a user-facing change?

NONE

Copy link
Member

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

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

There is a question to discuss (the small one), and I also wonder wether a unit test can cover this improvement 🤔

connector/oidc/oidc.go Outdated Show resolved Hide resolved
connector/oidc/oidc.go Outdated Show resolved Hide resolved
connector/oidc/oidc.go Outdated Show resolved Hide resolved
@seankhliao seankhliao force-pushed the access-tokens-with-userinfo branch from daf59cd to b46d37f Compare July 6, 2023 18:17
The provider.Verifier.Verify endpoint we were using only works with ID
tokens. This isn't an issue with systems which use ID tokens as access
tokens (e.g. dex), but for systems with opaque access tokens (e.g.
Google / GCP), those access tokens could not be verified.
Instead, check the access token against the getUserInfo endpoint.

Co-authored-by: Maksim Nabokikh <max.nabokih@gmail.com>
Signed-off-by: Sean Liao <sean+git@liao.dev>
@seankhliao seankhliao force-pushed the access-tokens-with-userinfo branch from b46d37f to c2a7c62 Compare July 6, 2023 18:23
@seankhliao
Copy link
Contributor Author

Not sure which question you were referring to?
I've switched to a check ensuring getUserInfo is enabled.
I can test that getUserInfo needs to be set, not sure we can easily test actual opaque tokens.

@seankhliao seankhliao requested a review from nabokihms July 6, 2023 18:24
@nabokihms
Copy link
Member

nabokihms commented Jul 9, 2023

@seankhliao, it was the question about what you have already fixed. Now everything seems fine 👍
I will test the PR manually then and return with the feedback.

Copy link
Member

@nabokihms nabokihms left a comment

Choose a reason for hiding this comment

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

LGTM

@nabokihms nabokihms merged commit affd4d4 into dexidp:master Aug 1, 2023
9 checks passed
@seankhliao seankhliao deleted the access-tokens-with-userinfo branch August 1, 2023 08:57
palexster pushed a commit to palexster/dex that referenced this pull request Oct 4, 2023
…exidp#3031)

The provider.Verifier.Verify endpoint we were using only works with ID
tokens. This isn't an issue with systems which use ID tokens as access
tokens (e.g. dex), but for systems with opaque access tokens (e.g.
Google / GCP), those access tokens could not be verified.
Instead, check the access token against the getUserInfo endpoint.

Signed-off-by: Sean Liao <sean+git@liao.dev>
Co-authored-by: Maksim Nabokikh <max.nabokih@gmail.com>
michaelliau pushed a commit to FlockFreight/dex that referenced this pull request Oct 4, 2023
…exidp#3031)

The provider.Verifier.Verify endpoint we were using only works with ID
tokens. This isn't an issue with systems which use ID tokens as access
tokens (e.g. dex), but for systems with opaque access tokens (e.g.
Google / GCP), those access tokens could not be verified.
Instead, check the access token against the getUserInfo endpoint.

Signed-off-by: Sean Liao <sean+git@liao.dev>
Co-authored-by: Maksim Nabokikh <max.nabokih@gmail.com>
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.

None yet

2 participants