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

Support device auth flow #395

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions oidc/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ type Provider struct {
tokenURL string
userInfoURL string
jwksURL string
deviceAuthURL string
algorithms []string

// Raw claims returned by the server.
Expand Down Expand Up @@ -133,6 +134,7 @@ type providerJSON struct {
TokenURL string `json:"token_endpoint"`
JWKSURL string `json:"jwks_uri"`
UserInfoURL string `json:"userinfo_endpoint"`
DeviceAuthURL string `json:"device_authorization_endpoint"`
Algorithms []string `json:"id_token_signing_alg_values_supported"`
}

Expand Down Expand Up @@ -174,7 +176,9 @@ type ProviderConfig struct {
// verify issued ID tokens. This endpoint is polled as new keys are made
// available.
JWKSURL string

// DeviceAuthURL is the endpoint used by the provider to support the Oauth 2.0
// Device Authorization flow.
DeviceAuthURL string
// Algorithms, if provided, indicate a list of JWT algorithms allowed to sign
// ID tokens. If not provided, this defaults to the algorithms advertised by
// the JWK endpoint, then the set of algorithms supported by this package.
Expand All @@ -191,6 +195,7 @@ func (p *ProviderConfig) NewProvider(ctx context.Context) *Provider {
userInfoURL: p.UserInfoURL,
jwksURL: p.JWKSURL,
algorithms: p.Algorithms,
deviceAuthURL: p.DeviceAuthURL,
client: getClient(ctx),
}
}
Expand Down Expand Up @@ -245,6 +250,7 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
tokenURL: p.TokenURL,
userInfoURL: p.UserInfoURL,
jwksURL: p.JWKSURL,
deviceAuthURL: p.DeviceAuthURL,
algorithms: algs,
rawClaims: body,
client: getClient(ctx),
Expand Down Expand Up @@ -273,7 +279,7 @@ func (p *Provider) Claims(v interface{}) error {

// Endpoint returns the OAuth2 auth and token endpoints for the given provider.
func (p *Provider) Endpoint() oauth2.Endpoint {
return oauth2.Endpoint{AuthURL: p.authURL, TokenURL: p.tokenURL}
return oauth2.Endpoint{AuthURL: p.authURL, TokenURL: p.tokenURL, DeviceAuthURL: p.deviceAuthURL}
}

// UserInfoEndpoint returns the OpenID Connect userinfo endpoint for the given
Expand Down