Skip to content

Commit 9a8d0df

Browse files
authored
feat: add .well-known/openid-configuration (#2197)
Adds the `.well-known/openid-configuration` endpoint that serves a static response pointing to the `.well-known/jwks.json` URL. It's important to also have this, as AWS JWT Authorizers require the OpenID discovery URL, not just the `jwks.json`. https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-jwt-authorizer.html
1 parent bca6626 commit 9a8d0df

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

internal/api/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ func NewAPIWithVersion(globalConfig *conf.GlobalConfiguration, db *storage.Conne
174174
}
175175

176176
r.Get("/health", api.HealthCheck)
177-
r.Get("/.well-known/jwks.json", api.Jwks)
177+
r.Get("/.well-known/jwks.json", api.WellKnownJwks)
178+
r.Get("/.well-known/openid-configuration", api.WellKnownOpenID)
178179

179180
if globalConfig.OAuthServer.Enabled {
180181
r.Get("/.well-known/oauth-authorization-server", api.oauthServer.OAuthServerMetadata)

internal/api/jwks.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type JwksResponse struct {
1111
Keys []jwk.Key `json:"keys"`
1212
}
1313

14-
func (a *API) Jwks(w http.ResponseWriter, r *http.Request) error {
14+
func (a *API) WellKnownJwks(w http.ResponseWriter, r *http.Request) error {
1515
config := a.config
1616
resp := JwksResponse{
1717
Keys: []jwk.Key{},
@@ -28,3 +28,19 @@ func (a *API) Jwks(w http.ResponseWriter, r *http.Request) error {
2828
w.Header().Set("Cache-Control", "public, max-age=600")
2929
return sendJSON(w, http.StatusOK, resp)
3030
}
31+
32+
type OpenIDConfigurationResponse struct {
33+
Issuer string `json:"issuer"`
34+
JWKSURL string `json:"jwks_uri"`
35+
}
36+
37+
func (a *API) WellKnownOpenID(w http.ResponseWriter, r *http.Request) error {
38+
config := a.config
39+
40+
w.Header().Set("Cache-Control", "public, max-age=600")
41+
42+
return sendJSON(w, http.StatusOK, OpenIDConfigurationResponse{
43+
Issuer: config.JWT.Issuer,
44+
JWKSURL: config.JWT.Issuer + "/.well-known/jwks.json",
45+
})
46+
}

0 commit comments

Comments
 (0)