2021-05-04 22:06:05 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/valyala/fasthttp"
|
|
|
|
|
2021-08-11 01:04:35 +00:00
|
|
|
"github.com/authelia/authelia/v4/internal/middlewares"
|
|
|
|
"github.com/authelia/authelia/v4/internal/oidc"
|
2021-05-04 22:06:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func oidcWellKnown(ctx *middlewares.AutheliaCtx) {
|
2021-08-10 00:31:08 +00:00
|
|
|
issuer, err := ctx.ExternalRootURL()
|
2021-05-04 22:06:05 +00:00
|
|
|
if err != nil {
|
2021-08-10 00:31:08 +00:00
|
|
|
ctx.Logger.Errorf("Error occurred determining OpenID Connect issuer details: %+v", err)
|
2021-05-04 22:06:05 +00:00
|
|
|
ctx.Response.SetStatusCode(fasthttp.StatusBadRequest)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
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
|
|
|
wellKnown := oidc.WellKnownConfiguration{
|
|
|
|
Issuer: issuer,
|
2021-07-22 03:52:37 +00:00
|
|
|
JWKSURI: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectJWKs),
|
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
|
|
|
|
2021-07-22 03:52:37 +00:00
|
|
|
AuthorizationEndpoint: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectAuthorization),
|
|
|
|
TokenEndpoint: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectToken),
|
|
|
|
RevocationEndpoint: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectRevocation),
|
|
|
|
UserinfoEndpoint: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectUserinfo),
|
2021-11-11 03:41:49 +00:00
|
|
|
IntrospectionEndpoint: fmt.Sprintf("%s%s", issuer, pathOpenIDConnectIntrospection),
|
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
|
|
|
|
2021-07-10 04:56:33 +00:00
|
|
|
Algorithms: []string{"RS256"},
|
|
|
|
UserinfoAlgorithms: []string{"none", "RS256"},
|
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
|
|
|
|
|
|
|
SubjectTypesSupported: []string{
|
|
|
|
"public",
|
|
|
|
},
|
|
|
|
ResponseTypesSupported: []string{
|
|
|
|
"code",
|
|
|
|
"token",
|
|
|
|
"id_token",
|
|
|
|
"code token",
|
|
|
|
"code id_token",
|
|
|
|
"token id_token",
|
|
|
|
"code token id_token",
|
|
|
|
"none",
|
|
|
|
},
|
|
|
|
ResponseModesSupported: []string{
|
|
|
|
"form_post",
|
|
|
|
"query",
|
|
|
|
"fragment",
|
|
|
|
},
|
|
|
|
ScopesSupported: []string{
|
|
|
|
"offline_access",
|
2022-02-09 22:55:28 +00:00
|
|
|
oidc.ScopeOpenID,
|
|
|
|
oidc.ScopeProfile,
|
|
|
|
oidc.ScopeGroups,
|
|
|
|
oidc.ScopeEmail,
|
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
|
|
|
},
|
|
|
|
ClaimsSupported: []string{
|
|
|
|
"aud",
|
|
|
|
"exp",
|
|
|
|
"iat",
|
|
|
|
"iss",
|
|
|
|
"jti",
|
|
|
|
"rat",
|
|
|
|
"sub",
|
|
|
|
"auth_time",
|
|
|
|
"nonce",
|
2022-02-09 22:55:28 +00:00
|
|
|
oidc.ClaimEmail,
|
|
|
|
oidc.ClaimEmailVerified,
|
|
|
|
oidc.ClaimEmailAlts,
|
|
|
|
oidc.ClaimGroups,
|
|
|
|
oidc.ClaimPreferredUsername,
|
|
|
|
oidc.ClaimDisplayName,
|
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
|
|
|
},
|
|
|
|
|
|
|
|
RequestURIParameterSupported: false,
|
|
|
|
BackChannelLogoutSupported: false,
|
|
|
|
FrontChannelLogoutSupported: false,
|
|
|
|
BackChannelLogoutSessionSupported: false,
|
|
|
|
FrontChannelLogoutSessionSupported: false,
|
2021-05-04 22:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx.SetContentType("application/json")
|
|
|
|
|
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
|
|
|
if err := json.NewEncoder(ctx).Encode(wellKnown); err != nil {
|
2021-08-10 00:31:08 +00:00
|
|
|
ctx.Logger.Errorf("Error occurred in JSON encode: %+v", err)
|
2021-05-04 22:06:05 +00:00
|
|
|
// TODO: Determine if this is the appropriate error code here.
|
|
|
|
ctx.Response.SetStatusCode(fasthttp.StatusInternalServerError)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|