2021-05-04 22:06:05 +00:00
|
|
|
package oidc
|
|
|
|
|
|
|
|
import (
|
2022-04-07 06:13:01 +00:00
|
|
|
"net/url"
|
2021-05-04 22:06:05 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-03-04 03:09:27 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2021-05-04 22:06:05 +00:00
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
2021-05-04 22:06:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOpenIDConnectProvider_NewOpenIDConnectProvider_NotConfigured(t *testing.T) {
|
2023-01-07 20:04:06 +00:00
|
|
|
provider, err := NewOpenIDConnectProvider(nil, nil, nil)
|
2021-05-04 22:06:05 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Nil(t, provider)
|
2021-05-04 22:06:05 +00:00
|
|
|
}
|
|
|
|
|
2022-04-07 06:13:01 +00:00
|
|
|
func TestNewOpenIDConnectProvider_ShouldEnableOptionalDiscoveryValues(t *testing.T) {
|
|
|
|
provider, err := NewOpenIDConnectProvider(&schema.OpenIDConnectConfiguration{
|
2022-10-02 02:07:40 +00:00
|
|
|
IssuerCertificateChain: schema.X509CertificateChain{},
|
2023-04-15 10:55:38 +00:00
|
|
|
IssuerPrivateKey: MustParseRSAPrivateKey(exampleIssuerPrivateKey),
|
2022-04-07 06:13:01 +00:00
|
|
|
EnablePKCEPlainChallenge: true,
|
2023-04-13 10:58:18 +00:00
|
|
|
HMACSecret: badhmac,
|
2022-04-07 06:13:01 +00:00
|
|
|
Clients: []schema.OpenIDConnectClientConfiguration{
|
|
|
|
{
|
2023-04-13 10:58:18 +00:00
|
|
|
ID: myclient,
|
|
|
|
Secret: MustDecodeSecret(badsecret),
|
|
|
|
SectorIdentifier: url.URL{Host: examplecomsid},
|
|
|
|
Policy: onefactor,
|
2022-04-07 06:13:01 +00:00
|
|
|
RedirectURIs: []string{
|
2023-04-13 10:58:18 +00:00
|
|
|
examplecom,
|
2022-04-07 06:13:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-07 20:04:06 +00:00
|
|
|
}, nil, nil)
|
2022-04-07 06:13:01 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
disco := provider.GetOpenIDConnectWellKnownConfiguration(examplecom)
|
2022-04-07 06:13:01 +00:00
|
|
|
|
|
|
|
assert.Len(t, disco.SubjectTypesSupported, 2)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePublic)
|
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePairwise)
|
2022-04-07 06:13:01 +00:00
|
|
|
|
|
|
|
assert.Len(t, disco.CodeChallengeMethodsSupported, 2)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.CodeChallengeMethodsSupported, PKCEChallengeMethodSHA256)
|
|
|
|
assert.Contains(t, disco.CodeChallengeMethodsSupported, PKCEChallengeMethodSHA256)
|
2022-04-07 06:13:01 +00:00
|
|
|
}
|
|
|
|
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
func TestOpenIDConnectProvider_NewOpenIDConnectProvider_GoodConfiguration(t *testing.T) {
|
|
|
|
provider, err := NewOpenIDConnectProvider(&schema.OpenIDConnectConfiguration{
|
2022-10-02 02:07:40 +00:00
|
|
|
IssuerCertificateChain: schema.X509CertificateChain{},
|
2023-04-15 10:55:38 +00:00
|
|
|
IssuerPrivateKey: MustParseRSAPrivateKey(exampleIssuerPrivateKey),
|
2023-04-13 10:58:18 +00:00
|
|
|
HMACSecret: badhmac,
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
Clients: []schema.OpenIDConnectClientConfiguration{
|
|
|
|
{
|
|
|
|
ID: "a-client",
|
2022-10-20 03:21:45 +00:00
|
|
|
Secret: MustDecodeSecret("$plaintext$a-client-secret"),
|
2023-04-13 10:58:18 +00:00
|
|
|
Policy: onefactor,
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
RedirectURIs: []string{
|
|
|
|
"https://google.com",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: "b-client",
|
|
|
|
Description: "Normal Description",
|
2022-10-20 03:21:45 +00:00
|
|
|
Secret: MustDecodeSecret("$plaintext$b-client-secret"),
|
2023-04-13 10:58:18 +00:00
|
|
|
Policy: twofactor,
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
RedirectURIs: []string{
|
|
|
|
"https://google.com",
|
|
|
|
},
|
|
|
|
Scopes: []string{
|
2022-10-20 02:16:36 +00:00
|
|
|
ScopeGroups,
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
},
|
|
|
|
GrantTypes: []string{
|
2022-10-20 02:16:36 +00:00
|
|
|
GrantTypeRefreshToken,
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
},
|
|
|
|
ResponseTypes: []string{
|
|
|
|
"token",
|
|
|
|
"code",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-07 20:04:06 +00:00
|
|
|
}, nil, nil)
|
2021-05-04 22:06:05 +00:00
|
|
|
|
feat(oidc): add additional config options, accurate token times, and refactoring (#1991)
* This gives admins more control over their OIDC installation exposing options that had defaults before. Things like lifespans for authorize codes, access tokens, id tokens, refresh tokens, a option to enable the debug client messages, minimum parameter entropy. It also allows admins to configure the response modes.
* Additionally this records specific values about a users session indicating when they performed a specific authz factor so this is represented in the token accurately.
* Lastly we also implemented a OIDC key manager which calculates the kid for jwk's using the SHA1 digest instead of being static, or more specifically the first 7 chars. As per https://datatracker.ietf.org/doc/html/draft-ietf-jose-json-web-key#section-8.1.1 the kid should not exceed 8 chars. While it's allowed to exceed 8 chars, it must only be done so with a compelling reason, which we do not have.
2021-07-03 23:44:30 +00:00
|
|
|
assert.NotNil(t, provider)
|
2021-05-04 22:06:05 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
func TestOpenIDConnectProvider_NewOpenIDConnectProvider_GetOpenIDConnectWellKnownConfiguration(t *testing.T) {
|
|
|
|
provider, err := NewOpenIDConnectProvider(&schema.OpenIDConnectConfiguration{
|
2022-10-02 02:07:40 +00:00
|
|
|
IssuerCertificateChain: schema.X509CertificateChain{},
|
2023-04-15 10:55:38 +00:00
|
|
|
IssuerPrivateKey: MustParseRSAPrivateKey(exampleIssuerPrivateKey),
|
2022-10-02 02:07:40 +00:00
|
|
|
HMACSecret: "asbdhaaskmdlkamdklasmdlkams",
|
2022-03-04 03:09:27 +00:00
|
|
|
Clients: []schema.OpenIDConnectClientConfiguration{
|
|
|
|
{
|
|
|
|
ID: "a-client",
|
2022-10-20 03:21:45 +00:00
|
|
|
Secret: MustDecodeSecret("$plaintext$a-client-secret"),
|
2023-04-13 10:58:18 +00:00
|
|
|
Policy: onefactor,
|
2022-03-04 03:09:27 +00:00
|
|
|
RedirectURIs: []string{
|
|
|
|
"https://google.com",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-07 20:04:06 +00:00
|
|
|
}, nil, nil)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
disco := provider.GetOpenIDConnectWellKnownConfiguration(examplecom)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Equal(t, examplecom, disco.Issuer)
|
2022-04-07 00:58:51 +00:00
|
|
|
assert.Equal(t, "https://example.com/jwks.json", disco.JWKSURI)
|
2022-03-04 03:09:27 +00:00
|
|
|
assert.Equal(t, "https://example.com/api/oidc/authorization", disco.AuthorizationEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/token", disco.TokenEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/userinfo", disco.UserinfoEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/introspection", disco.IntrospectionEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/revocation", disco.RevocationEndpoint)
|
|
|
|
assert.Equal(t, "", disco.RegistrationEndpoint)
|
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
assert.Len(t, disco.CodeChallengeMethodsSupported, 1)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.CodeChallengeMethodsSupported, PKCEChallengeMethodSHA256)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.Len(t, disco.ScopesSupported, 5)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeOpenID)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeOfflineAccess)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeProfile)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeGroups)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeEmail)
|
|
|
|
|
|
|
|
assert.Len(t, disco.ResponseModesSupported, 3)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeFormPost)
|
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeQuery)
|
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeFragment)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Len(t, disco.SubjectTypesSupported, 2)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePublic)
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePairwise)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Len(t, disco.ResponseTypesSupported, 7)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeAuthorizationCodeFlow)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowIDToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowBoth)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowIDToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowBoth)
|
|
|
|
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Len(t, disco.TokenEndpointAuthMethodsSupported, 4)
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretBasic)
|
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretPost)
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretJWT)
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodNone)
|
|
|
|
|
|
|
|
assert.Len(t, disco.GrantTypesSupported, 3)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeAuthorizationCode)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeRefreshToken)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeImplicit)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.Len(t, disco.IDTokenSigningAlgValuesSupported, 1)
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Contains(t, disco.IDTokenSigningAlgValuesSupported, SigningAlgRSAUsingSHA256)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.Len(t, disco.UserinfoSigningAlgValuesSupported, 2)
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Contains(t, disco.UserinfoSigningAlgValuesSupported, SigningAlgRSAUsingSHA256)
|
|
|
|
assert.Contains(t, disco.UserinfoSigningAlgValuesSupported, SigningAlgNone)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Len(t, disco.RequestObjectSigningAlgValuesSupported, 0)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2022-04-09 06:55:24 +00:00
|
|
|
assert.Len(t, disco.ClaimsSupported, 18)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthenticationMethodsReference)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAudience)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthorizedParty)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimClientIdentifier)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimExpirationTime)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimIssuedAt)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimIssuer)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimJWTID)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimRequestedAt)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimSubject)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthenticationTime)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimNonce)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimPreferredEmail)
|
2022-03-04 03:09:27 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimEmailVerified)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimEmailAlts)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimGroups)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimPreferredUsername)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimFullName)
|
2022-03-04 03:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOpenIDConnectProvider_NewOpenIDConnectProvider_GetOAuth2WellKnownConfiguration(t *testing.T) {
|
|
|
|
provider, err := NewOpenIDConnectProvider(&schema.OpenIDConnectConfiguration{
|
2022-10-02 02:07:40 +00:00
|
|
|
IssuerCertificateChain: schema.X509CertificateChain{},
|
2023-04-15 10:55:38 +00:00
|
|
|
IssuerPrivateKey: MustParseRSAPrivateKey(exampleIssuerPrivateKey),
|
2022-10-02 02:07:40 +00:00
|
|
|
HMACSecret: "asbdhaaskmdlkamdklasmdlkams",
|
2022-03-04 03:09:27 +00:00
|
|
|
Clients: []schema.OpenIDConnectClientConfiguration{
|
|
|
|
{
|
|
|
|
ID: "a-client",
|
2022-10-20 03:21:45 +00:00
|
|
|
Secret: MustDecodeSecret("$plaintext$a-client-secret"),
|
2023-04-13 10:58:18 +00:00
|
|
|
Policy: onefactor,
|
2022-03-04 03:09:27 +00:00
|
|
|
RedirectURIs: []string{
|
|
|
|
"https://google.com",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-07 20:04:06 +00:00
|
|
|
}, nil, nil)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
disco := provider.GetOAuth2WellKnownConfiguration(examplecom)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Equal(t, examplecom, disco.Issuer)
|
2022-04-07 00:58:51 +00:00
|
|
|
assert.Equal(t, "https://example.com/jwks.json", disco.JWKSURI)
|
2022-03-04 03:09:27 +00:00
|
|
|
assert.Equal(t, "https://example.com/api/oidc/authorization", disco.AuthorizationEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/token", disco.TokenEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/introspection", disco.IntrospectionEndpoint)
|
|
|
|
assert.Equal(t, "https://example.com/api/oidc/revocation", disco.RevocationEndpoint)
|
|
|
|
assert.Equal(t, "", disco.RegistrationEndpoint)
|
|
|
|
|
|
|
|
require.Len(t, disco.CodeChallengeMethodsSupported, 1)
|
|
|
|
assert.Equal(t, "S256", disco.CodeChallengeMethodsSupported[0])
|
|
|
|
|
|
|
|
assert.Len(t, disco.ScopesSupported, 5)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeOpenID)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeOfflineAccess)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeProfile)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeGroups)
|
|
|
|
assert.Contains(t, disco.ScopesSupported, ScopeEmail)
|
|
|
|
|
|
|
|
assert.Len(t, disco.ResponseModesSupported, 3)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeFormPost)
|
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeQuery)
|
|
|
|
assert.Contains(t, disco.ResponseModesSupported, ResponseModeFragment)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Len(t, disco.SubjectTypesSupported, 2)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePublic)
|
2023-04-13 10:58:18 +00:00
|
|
|
assert.Contains(t, disco.SubjectTypesSupported, SubjectTypePairwise)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Len(t, disco.ResponseTypesSupported, 7)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeAuthorizationCodeFlow)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowIDToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeImplicitFlowBoth)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowIDToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowToken)
|
|
|
|
assert.Contains(t, disco.ResponseTypesSupported, ResponseTypeHybridFlowBoth)
|
|
|
|
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Len(t, disco.TokenEndpointAuthMethodsSupported, 4)
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretBasic)
|
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretPost)
|
2023-04-15 10:55:38 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodClientSecretJWT)
|
2023-03-06 02:35:58 +00:00
|
|
|
assert.Contains(t, disco.TokenEndpointAuthMethodsSupported, ClientAuthMethodNone)
|
|
|
|
|
|
|
|
assert.Len(t, disco.GrantTypesSupported, 3)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeAuthorizationCode)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeRefreshToken)
|
|
|
|
assert.Contains(t, disco.GrantTypesSupported, GrantTypeImplicit)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
2022-04-09 06:55:24 +00:00
|
|
|
assert.Len(t, disco.ClaimsSupported, 18)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthenticationMethodsReference)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAudience)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthorizedParty)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimClientIdentifier)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimExpirationTime)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimIssuedAt)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimIssuer)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimJWTID)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimRequestedAt)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimSubject)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimAuthenticationTime)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimNonce)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimPreferredEmail)
|
2022-03-04 03:09:27 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimEmailVerified)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimEmailAlts)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimGroups)
|
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimPreferredUsername)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Contains(t, disco.ClaimsSupported, ClaimFullName)
|
2022-03-04 03:09:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestOpenIDConnectProvider_NewOpenIDConnectProvider_GetOpenIDConnectWellKnownConfigurationWithPlainPKCE(t *testing.T) {
|
|
|
|
provider, err := NewOpenIDConnectProvider(&schema.OpenIDConnectConfiguration{
|
2022-10-02 02:07:40 +00:00
|
|
|
IssuerCertificateChain: schema.X509CertificateChain{},
|
2023-04-15 10:55:38 +00:00
|
|
|
IssuerPrivateKey: MustParseRSAPrivateKey(exampleIssuerPrivateKey),
|
2022-03-04 03:09:27 +00:00
|
|
|
HMACSecret: "asbdhaaskmdlkamdklasmdlkams",
|
|
|
|
EnablePKCEPlainChallenge: true,
|
|
|
|
Clients: []schema.OpenIDConnectClientConfiguration{
|
|
|
|
{
|
|
|
|
ID: "a-client",
|
2022-10-20 03:21:45 +00:00
|
|
|
Secret: MustDecodeSecret("$plaintext$a-client-secret"),
|
2023-04-13 10:58:18 +00:00
|
|
|
Policy: onefactor,
|
2022-03-04 03:09:27 +00:00
|
|
|
RedirectURIs: []string{
|
|
|
|
"https://google.com",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-01-07 20:04:06 +00:00
|
|
|
}, nil, nil)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
disco := provider.GetOpenIDConnectWellKnownConfiguration(examplecom)
|
2022-03-04 03:09:27 +00:00
|
|
|
|
|
|
|
require.Len(t, disco.CodeChallengeMethodsSupported, 2)
|
2022-10-20 02:16:36 +00:00
|
|
|
assert.Equal(t, PKCEChallengeMethodSHA256, disco.CodeChallengeMethodsSupported[0])
|
|
|
|
assert.Equal(t, PKCEChallengeMethodPlain, disco.CodeChallengeMethodsSupported[1])
|
2022-03-04 03:09:27 +00:00
|
|
|
}
|