Use op.SupportedClaims instead of interface

This commit is contained in:
snow flurry 2023-12-05 11:09:53 -08:00
parent 3bb48f7cba
commit 22758c3fce
5 changed files with 9 additions and 31 deletions

View file

@ -47,7 +47,6 @@ type Configuration interface {
RequestObjectSupported() bool
RequestObjectSigningAlgorithmsSupported() []string
SupportedClaims() []string
SupportedUILocales() []language.Tag
DeviceAuthorization() DeviceAuthorizationConfig
}

View file

@ -57,7 +57,7 @@ func CreateDiscoveryConfig(ctx context.Context, config Configuration, storage Di
IntrospectionEndpointAuthMethodsSupported: AuthMethodsIntrospectionEndpoint(config),
RevocationEndpointAuthSigningAlgValuesSupported: RevocationSigAlgorithms(config),
RevocationEndpointAuthMethodsSupported: AuthMethodsRevocationEndpoint(config),
ClaimsSupported: config.SupportedClaims(),
ClaimsSupported: SupportedClaims(config),
CodeChallengeMethodsSupported: CodeChallengeMethods(config),
UILocalesSupported: config.SupportedUILocales(),
RequestParameterSupported: config.RequestObjectSupported(),
@ -88,7 +88,7 @@ func createDiscoveryConfigV2(ctx context.Context, config Configuration, storage
IntrospectionEndpointAuthMethodsSupported: AuthMethodsIntrospectionEndpoint(config),
RevocationEndpointAuthSigningAlgValuesSupported: RevocationSigAlgorithms(config),
RevocationEndpointAuthMethodsSupported: AuthMethodsRevocationEndpoint(config),
ClaimsSupported: config.SupportedClaims(),
ClaimsSupported: SupportedClaims(config),
CodeChallengeMethodsSupported: CodeChallengeMethods(config),
UILocalesSupported: config.SupportedUILocales(),
RequestParameterSupported: config.RequestObjectSupported(),
@ -213,7 +213,12 @@ func AuthMethodsRevocationEndpoint(c Configuration) []oidc.AuthMethod {
}
func SupportedClaims(c Configuration) []string {
return c.SupportedClaims()
provider, ok := c.(*Provider)
if ok && provider.config.SupportedClaims != nil {
return provider.config.SupportedClaims
}
return DefaultSupportedClaims
}
func CodeChallengeMethods(c Configuration) []oidc.CodeChallengeMethod {

View file

@ -544,11 +544,7 @@ func TestSupportedClaims(t *testing.T) {
}{
{
"scopes",
args{func() op.Configuration {
m := mock.NewMockConfiguration(gomock.NewController(t))
m.EXPECT().SupportedClaims().Return(op.DefaultSupportedClaims)
return m
}()},
args{},
[]string{
"sub",
"aud",

View file

@ -358,20 +358,6 @@ func (mr *MockConfigurationMockRecorder) RevocationEndpointSigningAlgorithmsSupp
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevocationEndpointSigningAlgorithmsSupported", reflect.TypeOf((*MockConfiguration)(nil).RevocationEndpointSigningAlgorithmsSupported))
}
// SupportedClaims mocks base method.
func (m *MockConfiguration) SupportedClaims() []string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SupportedClaims")
ret0, _ := ret[0].([]string)
return ret0
}
// SupportedClaims indicates an expected call of SupportedClaims.
func (mr *MockConfigurationMockRecorder) SupportedClaims() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SupportedClaims", reflect.TypeOf((*MockConfiguration)(nil).SupportedClaims))
}
// SupportedUILocales mocks base method.
func (m *MockConfiguration) SupportedUILocales() []language.Tag {
m.ctrl.T.Helper()

View file

@ -414,14 +414,6 @@ func (o *Provider) RequestObjectSigningAlgorithmsSupported() []string {
return []string{"RS256"}
}
func (o *Provider) SupportedClaims() []string {
if o.config.SupportedClaims == nil {
return DefaultSupportedClaims
} else {
return o.config.SupportedClaims
}
}
func (o *Provider) SupportedUILocales() []language.Tag {
return o.config.SupportedUILocales
}