2024-02-07 01:18:17 +00:00
|
|
|
package openid
|
|
|
|
|
2025-01-19 12:04:25 +00:00
|
|
|
import "github.com/1f349/lavender/url"
|
2024-02-07 01:18:17 +00:00
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Issuer string `json:"issuer"`
|
|
|
|
AuthorizationEndpoint string `json:"authorization_endpoint"`
|
|
|
|
TokenEndpoint string `json:"token_endpoint"`
|
|
|
|
UserInfoEndpoint string `json:"userinfo_endpoint"`
|
|
|
|
ResponseTypesSupported []string `json:"response_types_supported"`
|
|
|
|
ScopesSupported []string `json:"scopes_supported"`
|
|
|
|
ClaimsSupported []string `json:"claims_supported"`
|
|
|
|
GrantTypesSupported []string `json:"grant_types_supported"`
|
2024-07-27 21:46:58 +01:00
|
|
|
JwksUri string `json:"jwks_uri"`
|
2024-02-07 01:18:17 +00:00
|
|
|
}
|
|
|
|
|
2025-01-19 12:04:25 +00:00
|
|
|
func GenConfig(baseUrl *url.URL, scopes, claims []string) Config {
|
2024-02-07 01:18:17 +00:00
|
|
|
|
|
|
|
return Config{
|
2025-01-19 12:04:25 +00:00
|
|
|
Issuer: baseUrl.String(),
|
|
|
|
AuthorizationEndpoint: baseUrl.Resolve("authorize").String(),
|
|
|
|
TokenEndpoint: baseUrl.Resolve("token").String(),
|
|
|
|
UserInfoEndpoint: baseUrl.Resolve("userinfo").String(),
|
2024-02-07 01:18:17 +00:00
|
|
|
ResponseTypesSupported: []string{"code"},
|
|
|
|
ScopesSupported: scopes,
|
|
|
|
ClaimsSupported: claims,
|
|
|
|
GrantTypesSupported: []string{"authorization_code", "refresh_token"},
|
2025-01-19 12:04:25 +00:00
|
|
|
JwksUri: baseUrl.Resolve(".well-known/jwks.json").String(),
|
2024-02-07 01:18:17 +00:00
|
|
|
}
|
|
|
|
}
|