2022-04-07 05:33:53 +00:00
|
|
|
package oidc
|
|
|
|
|
2023-03-06 03:58:50 +00:00
|
|
|
import (
|
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
|
|
)
|
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
// NewOpenIDConnectWellKnownConfiguration generates a new OpenIDConnectWellKnownConfiguration.
|
2023-04-13 10:58:18 +00:00
|
|
|
func NewOpenIDConnectWellKnownConfiguration(c *schema.OpenIDConnectConfiguration) (config OpenIDConnectWellKnownConfiguration) {
|
2022-04-07 05:33:53 +00:00
|
|
|
config = OpenIDConnectWellKnownConfiguration{
|
2023-04-13 10:58:18 +00:00
|
|
|
OAuth2WellKnownConfiguration: OAuth2WellKnownConfiguration{
|
|
|
|
CommonDiscoveryOptions: CommonDiscoveryOptions{
|
|
|
|
SubjectTypesSupported: []string{
|
|
|
|
SubjectTypePublic,
|
|
|
|
SubjectTypePairwise,
|
|
|
|
},
|
|
|
|
ResponseTypesSupported: []string{
|
|
|
|
ResponseTypeAuthorizationCodeFlow,
|
|
|
|
ResponseTypeImplicitFlowIDToken,
|
|
|
|
ResponseTypeImplicitFlowToken,
|
|
|
|
ResponseTypeImplicitFlowBoth,
|
|
|
|
ResponseTypeHybridFlowIDToken,
|
|
|
|
ResponseTypeHybridFlowToken,
|
|
|
|
ResponseTypeHybridFlowBoth,
|
|
|
|
},
|
|
|
|
GrantTypesSupported: []string{
|
|
|
|
GrantTypeAuthorizationCode,
|
|
|
|
GrantTypeImplicit,
|
|
|
|
GrantTypeRefreshToken,
|
|
|
|
},
|
|
|
|
ResponseModesSupported: []string{
|
|
|
|
ResponseModeFormPost,
|
|
|
|
ResponseModeQuery,
|
|
|
|
ResponseModeFragment,
|
|
|
|
},
|
|
|
|
ScopesSupported: []string{
|
|
|
|
ScopeOfflineAccess,
|
|
|
|
ScopeOpenID,
|
|
|
|
ScopeProfile,
|
|
|
|
ScopeGroups,
|
|
|
|
ScopeEmail,
|
|
|
|
},
|
|
|
|
ClaimsSupported: []string{
|
|
|
|
ClaimAuthenticationMethodsReference,
|
|
|
|
ClaimAudience,
|
|
|
|
ClaimAuthorizedParty,
|
|
|
|
ClaimClientIdentifier,
|
|
|
|
ClaimExpirationTime,
|
|
|
|
ClaimIssuedAt,
|
|
|
|
ClaimIssuer,
|
|
|
|
ClaimJWTID,
|
|
|
|
ClaimRequestedAt,
|
|
|
|
ClaimSubject,
|
|
|
|
ClaimAuthenticationTime,
|
|
|
|
ClaimNonce,
|
|
|
|
ClaimPreferredEmail,
|
|
|
|
ClaimEmailVerified,
|
|
|
|
ClaimEmailAlts,
|
|
|
|
ClaimGroups,
|
|
|
|
ClaimPreferredUsername,
|
|
|
|
ClaimFullName,
|
|
|
|
},
|
|
|
|
TokenEndpointAuthMethodsSupported: []string{
|
|
|
|
ClientAuthMethodClientSecretBasic,
|
|
|
|
ClientAuthMethodClientSecretPost,
|
2023-04-15 10:55:38 +00:00
|
|
|
ClientAuthMethodClientSecretJWT,
|
2023-04-13 10:58:18 +00:00
|
|
|
ClientAuthMethodNone,
|
|
|
|
},
|
2023-04-15 10:55:38 +00:00
|
|
|
TokenEndpointAuthSigningAlgValuesSupported: []string{
|
|
|
|
SigningAlgHMACUsingSHA256,
|
|
|
|
SigningAlgHMACUsingSHA384,
|
|
|
|
SigningAlgHMACUsingSHA512,
|
|
|
|
},
|
2022-04-07 05:33:53 +00:00
|
|
|
},
|
2023-04-13 10:58:18 +00:00
|
|
|
OAuth2DiscoveryOptions: OAuth2DiscoveryOptions{
|
|
|
|
CodeChallengeMethodsSupported: []string{
|
|
|
|
PKCEChallengeMethodSHA256,
|
|
|
|
},
|
2023-03-06 02:35:58 +00:00
|
|
|
},
|
2023-04-13 10:58:18 +00:00
|
|
|
OAuth2PushedAuthorizationDiscoveryOptions: &OAuth2PushedAuthorizationDiscoveryOptions{
|
|
|
|
RequirePushedAuthorizationRequests: c.PAR.Enforce,
|
2022-04-07 05:33:53 +00:00
|
|
|
},
|
|
|
|
},
|
2023-04-13 10:58:18 +00:00
|
|
|
|
2022-04-07 05:33:53 +00:00
|
|
|
OpenIDConnectDiscoveryOptions: OpenIDConnectDiscoveryOptions{
|
|
|
|
IDTokenSigningAlgValuesSupported: []string{
|
2023-04-15 10:55:38 +00:00
|
|
|
SigningAlgRSAUsingSHA256,
|
2022-04-07 05:33:53 +00:00
|
|
|
},
|
|
|
|
UserinfoSigningAlgValuesSupported: []string{
|
2023-04-15 10:55:38 +00:00
|
|
|
SigningAlgNone,
|
|
|
|
SigningAlgRSAUsingSHA256,
|
2022-04-07 05:33:53 +00:00
|
|
|
},
|
|
|
|
},
|
2023-04-13 10:58:18 +00:00
|
|
|
OpenIDConnectFrontChannelLogoutDiscoveryOptions: &OpenIDConnectFrontChannelLogoutDiscoveryOptions{},
|
|
|
|
OpenIDConnectBackChannelLogoutDiscoveryOptions: &OpenIDConnectBackChannelLogoutDiscoveryOptions{},
|
|
|
|
OpenIDConnectPromptCreateDiscoveryOptions: &OpenIDConnectPromptCreateDiscoveryOptions{
|
|
|
|
PromptValuesSupported: []string{
|
|
|
|
PromptNone,
|
|
|
|
PromptConsent,
|
|
|
|
},
|
2023-03-06 03:58:50 +00:00
|
|
|
},
|
2022-04-07 05:33:53 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if c.EnablePKCEPlainChallenge {
|
|
|
|
config.CodeChallengeMethodsSupported = append(config.CodeChallengeMethodsSupported, PKCEChallengeMethodPlain)
|
|
|
|
}
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the values of the OAuth2WellKnownConfiguration and return it as a new struct.
|
|
|
|
func (opts OAuth2WellKnownConfiguration) Copy() (optsCopy OAuth2WellKnownConfiguration) {
|
|
|
|
optsCopy = OAuth2WellKnownConfiguration{
|
|
|
|
CommonDiscoveryOptions: opts.CommonDiscoveryOptions,
|
|
|
|
OAuth2DiscoveryOptions: opts.OAuth2DiscoveryOptions,
|
|
|
|
}
|
2022-10-20 02:16:36 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if opts.OAuth2DeviceAuthorizationGrantDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2DeviceAuthorizationGrantDiscoveryOptions = &OAuth2DeviceAuthorizationGrantDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2DeviceAuthorizationGrantDiscoveryOptions = *opts.OAuth2DeviceAuthorizationGrantDiscoveryOptions
|
|
|
|
}
|
2022-10-20 02:16:36 +00:00
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if opts.OAuth2MutualTLSClientAuthenticationDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2MutualTLSClientAuthenticationDiscoveryOptions = &OAuth2MutualTLSClientAuthenticationDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2MutualTLSClientAuthenticationDiscoveryOptions = *opts.OAuth2MutualTLSClientAuthenticationDiscoveryOptions
|
2022-10-20 02:16:36 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if opts.OAuth2IssuerIdentificationDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2IssuerIdentificationDiscoveryOptions = &OAuth2IssuerIdentificationDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2IssuerIdentificationDiscoveryOptions = *opts.OAuth2IssuerIdentificationDiscoveryOptions
|
2022-04-07 05:33:53 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if opts.OAuth2JWTIntrospectionResponseDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2JWTIntrospectionResponseDiscoveryOptions = &OAuth2JWTIntrospectionResponseDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2JWTIntrospectionResponseDiscoveryOptions = *opts.OAuth2JWTIntrospectionResponseDiscoveryOptions
|
2022-04-07 05:33:53 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 10:58:18 +00:00
|
|
|
if opts.OAuth2JWTSecuredAuthorizationRequestDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2JWTSecuredAuthorizationRequestDiscoveryOptions = &OAuth2JWTSecuredAuthorizationRequestDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2JWTSecuredAuthorizationRequestDiscoveryOptions = *opts.OAuth2JWTSecuredAuthorizationRequestDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OAuth2PushedAuthorizationDiscoveryOptions != nil {
|
|
|
|
optsCopy.OAuth2PushedAuthorizationDiscoveryOptions = &OAuth2PushedAuthorizationDiscoveryOptions{}
|
|
|
|
*optsCopy.OAuth2PushedAuthorizationDiscoveryOptions = *opts.OAuth2PushedAuthorizationDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
return optsCopy
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the values of the OpenIDConnectWellKnownConfiguration and return it as a new struct.
|
|
|
|
func (opts OpenIDConnectWellKnownConfiguration) Copy() (optsCopy OpenIDConnectWellKnownConfiguration) {
|
|
|
|
optsCopy = OpenIDConnectWellKnownConfiguration{
|
|
|
|
OAuth2WellKnownConfiguration: opts.OAuth2WellKnownConfiguration.Copy(),
|
|
|
|
OpenIDConnectDiscoveryOptions: opts.OpenIDConnectDiscoveryOptions,
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectFrontChannelLogoutDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectFrontChannelLogoutDiscoveryOptions = &OpenIDConnectFrontChannelLogoutDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectFrontChannelLogoutDiscoveryOptions = *opts.OpenIDConnectFrontChannelLogoutDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectBackChannelLogoutDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectBackChannelLogoutDiscoveryOptions = &OpenIDConnectBackChannelLogoutDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectBackChannelLogoutDiscoveryOptions = *opts.OpenIDConnectBackChannelLogoutDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectSessionManagementDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectSessionManagementDiscoveryOptions = &OpenIDConnectSessionManagementDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectSessionManagementDiscoveryOptions = *opts.OpenIDConnectSessionManagementDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectRPInitiatedLogoutDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectRPInitiatedLogoutDiscoveryOptions = &OpenIDConnectRPInitiatedLogoutDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectRPInitiatedLogoutDiscoveryOptions = *opts.OpenIDConnectRPInitiatedLogoutDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectPromptCreateDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectPromptCreateDiscoveryOptions = &OpenIDConnectPromptCreateDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectPromptCreateDiscoveryOptions = *opts.OpenIDConnectPromptCreateDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectClientInitiatedBackChannelAuthFlowDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectClientInitiatedBackChannelAuthFlowDiscoveryOptions = &OpenIDConnectClientInitiatedBackChannelAuthFlowDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectClientInitiatedBackChannelAuthFlowDiscoveryOptions = *opts.OpenIDConnectClientInitiatedBackChannelAuthFlowDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDConnectJWTSecuredAuthorizationResponseModeDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDConnectJWTSecuredAuthorizationResponseModeDiscoveryOptions = &OpenIDConnectJWTSecuredAuthorizationResponseModeDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDConnectJWTSecuredAuthorizationResponseModeDiscoveryOptions = *opts.OpenIDConnectJWTSecuredAuthorizationResponseModeDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
if opts.OpenIDFederationDiscoveryOptions != nil {
|
|
|
|
optsCopy.OpenIDFederationDiscoveryOptions = &OpenIDFederationDiscoveryOptions{}
|
|
|
|
*optsCopy.OpenIDFederationDiscoveryOptions = *opts.OpenIDFederationDiscoveryOptions
|
|
|
|
}
|
|
|
|
|
|
|
|
return optsCopy
|
2022-04-07 05:33:53 +00:00
|
|
|
}
|