Skip to content

Commit

Permalink
fix: add code_challenge_methods_supported to discovery endpoint (#43)
Browse files Browse the repository at this point in the history
* fix: add code_challenge_methods_supported to discovery endpoint

* fix mock
  • Loading branch information
livio-a committed Aug 20, 2020
1 parent 5a8e699 commit 57cf8ee
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
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
}
14 changes: 14 additions & 0 deletions pkg/op/mock/configuration.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 57cf8ee

Please sign in to comment.