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

fix: add code_challenge_methods_supported to discovery endpoint #43

Merged
merged 2 commits into from Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/oidc/discovery.go
Expand Up @@ -20,5 +20,6 @@ type DiscoveryConfiguration struct {
SubjectTypesSupported []string `json:"subject_types_supported,omitempty"`
IDTokenSigningAlgValuesSupported []string `json:"id_token_signing_alg_values_supported,omitempty"`
TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported,omitempty"`
CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported,omitempty"`
ClaimsSupported []string `json:"claims_supported,omitempty"`
}
1 change: 1 addition & 0 deletions pkg/op/config.go
Expand Up @@ -16,6 +16,7 @@ type Configuration interface {
KeysEndpoint() Endpoint

AuthMethodPostSupported() bool
CodeMethodS256Supported() bool
}

func ValidateIssuer(issuer string) error {
Expand Down
7 changes: 7 additions & 0 deletions pkg/op/default_op.go
Expand Up @@ -26,6 +26,8 @@ const (
AuthMethodBasic AuthMethod = "client_secret_basic"
AuthMethodPost = "client_secret_post"
AuthMethodNone = "none"

CodeMethodS256 = "S256"
)

var (
Expand Down Expand Up @@ -58,6 +60,7 @@ type Config struct {
Issuer string
CryptoKey [32]byte
DefaultLogoutRedirectURI string
CodeMethodS256 bool
// ScopesSupported: oidc.SupportedScopes,
// ResponseTypesSupported: responseTypes,
// GrantTypesSupported: oidc.SupportedGrantTypes,
Expand Down Expand Up @@ -222,6 +225,10 @@ func (p *DefaultOP) AuthMethodPostSupported() bool {
return true //TODO: config
}

func (p *DefaultOP) CodeMethodS256Supported() bool {
return p.config.CodeMethodS256
}

func (p *DefaultOP) HttpHandler() http.Handler {
return p.http
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/op/discovery.go
Expand Up @@ -28,6 +28,7 @@ func CreateDiscoveryConfig(c Configuration, s Signer) *oidc.DiscoveryConfigurati
IDTokenSigningAlgValuesSupported: SigAlgorithms(s),
SubjectTypesSupported: SubjectTypes(c),
TokenEndpointAuthMethodsSupported: AuthMethods(c),
CodeChallengeMethodsSupported: CodeChallengeMethods(c),
}
}

Expand Down Expand Up @@ -117,3 +118,11 @@ func AuthMethods(c Configuration) []string {
}
return authMethods
}

func CodeChallengeMethods(c Configuration) []string {
codeMethods := make([]string, 0, 1)
if c.CodeMethodS256Supported() {
codeMethods = append(codeMethods, CodeMethodS256)
}
return codeMethods
}