-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
connector/oidc: expose oauth2.RegisterBrokenAuthHeaderProvider #860
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Authentication through an OpenID Connect provider | ||
|
||
## Overview | ||
|
||
Dex is able to use another OpenID Connect provider as an authentication source. When logging in, dex will redirect to the upstream provider and perform the necessary OAuth2 flows to determine the end users email, username, etc. More details on the OpenID Connect protocol can be found in [_An overview of OpenID Connect_][oidc-doc]. | ||
|
||
Prominent examples of OpenID Connect providers include Google Accounts, Salesforce, and Azure AD v2 ([not v1][azure-ad-v1]). | ||
|
||
## Caveats | ||
|
||
Many OpenID Connect providers implement different restrictions on refresh tokens. For example, Google will only issue the first login attempt a refresh token, then not return one after. Because of this, this connector does not refresh the id_token claims when a client of dex redeems a refresh token, which can result in stale user info. | ||
|
||
It's generally recommended to avoid using refresh tokens with the `oidc` connector. | ||
|
||
Progress on this caveat can be tracked in [issue #863][google-refreshing]. | ||
|
||
## Configuration | ||
|
||
```yaml | ||
connectors: | ||
- type: oidc | ||
id: google | ||
name: Google | ||
config: | ||
# Canonical URL of the provider, also used for configuration discovery. | ||
# This value MUST match the value returned in the provider config discovery. | ||
# | ||
# See: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig | ||
issuer: https://accounts.google.com | ||
|
||
# Connector config values starting with a "$" will read from the environment. | ||
clientID: $GOOGLE_CLIENT_ID | ||
clientSecret: $GOOGLE_CLIENT_SECRET | ||
|
||
# Dex's issuer URL + "/callback" | ||
redirectURI: http://127.0.0.1:5556/callback | ||
|
||
|
||
# Some providers require passing client_secret via POST parameters instead | ||
# of basic auth, despite the OAuth2 RFC discouraging it. Many of these | ||
# cases are caught internally, but some may need to uncommented the | ||
# following field. | ||
# | ||
# basicAuthUnsupported: true | ||
``` | ||
|
||
[oidc-doc]: openid-connect.md | ||
[google-refreshing]: https://github.com/coreos/dex/issues/863 | ||
[azure-ad-v1]: https://github.com/coreos/go-oidc/issues/133 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package oidc | ||
|
||
import "testing" | ||
|
||
func TestKnownBrokenAuthHeaderProvider(t *testing.T) { | ||
tests := []struct { | ||
issuerURL string | ||
expect bool | ||
}{ | ||
{"https://dev.oktapreview.com", true}, | ||
{"https://dev.okta.com", true}, | ||
{"https://okta.com", true}, | ||
{"https://dev.oktaaccounts.com", false}, | ||
{"https://accounts.google.com", false}, | ||
} | ||
|
||
for _, tc := range tests { | ||
got := knownBrokenAuthHeaderProvider(tc.issuerURL) | ||
if got != tc.expect { | ||
t.Errorf("knownBrokenAuthHeaderProvider(%q), want=%t, got=%t", tc.issuerURL, tc.expect, got) | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO implementing a known list of broken providers isn't a good idea. This list will grow and grow over time just like it has in oauth2 violating the open close principle.
I think it's better to rely on clear documentation in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conversely, not all IDPs have nice error messages like Okta so things could fail and operators will have no idea why... So I can see both sides of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can detect cases where someone will always have to set the
basicAuthUnsupported
flag then I think we should just avoid the overhead and do it automatically. These providers being weird shouldn't cost our users ease of use, and maintaining a list isn't that bad.