Support jwks.json according OIDC stranded

This commit is contained in:
2024-11-23 13:07:49 +08:00
parent ca9bd7ac14
commit bf733da247
5 changed files with 31 additions and 11 deletions

View File

@ -6,6 +6,7 @@ import (
func MapAPIs(app *fiber.App, baseURL string) {
app.Get("/.well-known/openid-configuration", getOidcConfiguration)
app.Get("/.well-known/jwks", getJwk)
api := app.Group(baseURL).Name("API")
{

View File

@ -2,7 +2,7 @@ package api
import (
"fmt"
"git.solsynth.dev/hypernet/passport/pkg/internal/services"
"github.com/gofiber/fiber/v2"
"github.com/spf13/viper"
)
@ -22,5 +22,14 @@ func getOidcConfiguration(c *fiber.Ctx) error {
"token_endpoint_auth_methods_supported": []string{"client_secret_post"},
"id_token_signing_alg_values_supported": []string{"HS512"},
"token_endpoint_auth_signing_alg_values_supported": []string{"HS512"},
"jwks_uri": fmt.Sprintf("%s/.well-known/jwks", basepath),
})
}
func getJwk(c *fiber.Ctx) error {
return c.JSON(fiber.Map{
"keys": []fiber.Map{
services.EReader.BuildJwk(viper.GetString("id")),
},
})
}