Add openid-configuration just for jwks_uri (for jwt.io)

This commit is contained in:
Zoe Roux 2025-03-24 23:08:58 +01:00
parent 9dc1087273
commit 161e4943a1
No known key found for this signature in database
2 changed files with 11 additions and 2 deletions

View File

@ -74,7 +74,7 @@ func (h *Handler) CreateJwt(c echo.Context) error {
// @Produce json
// @Success 200 {object} jwk.Key
// @Router /.well-known/jwks.json [get]
func (h *Handler) GetInfo(c echo.Context) error {
func (h *Handler) GetJwks(c echo.Context) error {
key, err := jwk.New(h.config.JwtPublicKey)
if err != nil {
return err
@ -86,3 +86,11 @@ func (h *Handler) GetInfo(c echo.Context) error {
set.Add(key)
return c.JSON(200, set)
}
func (h *Handler) GetOidcConfig(c echo.Context) error {
return c.JSON(200, struct {
JwksUri string `json:"jwks_uri"`
}{
JwksUri: fmt.Sprintf("%s/.well-known/jwks.json", h.config.PublicUrl),
})
}

View File

@ -184,7 +184,8 @@ func main() {
r.DELETE("/sessions/:id", h.Logout)
g.GET("/jwt", h.CreateJwt)
e.GET("/.well-known/jwks.json", h.GetInfo)
e.GET("/.well-known/jwks.json", h.GetJwks)
e.GET("/.well-known/openid-configuration", h.GetOidcConfig)
g.GET("/swagger/*", echoSwagger.WrapHandler)