mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-12-12 11:46:02 +00:00
get base url from the config for wellknowhandler
This commit is contained in:
parent
1edfed91b5
commit
8db310ec06
2 changed files with 9 additions and 37 deletions
|
|
@ -42,31 +42,17 @@ func (p *asgardeoProvider) WellKnownHandler() http.HandlerFunc {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme := "http"
|
|
||||||
if r.TLS != nil {
|
|
||||||
scheme = "https"
|
|
||||||
}
|
|
||||||
if forwardedProto := r.Header.Get("X-Forwarded-Proto"); forwardedProto != "" {
|
|
||||||
scheme = forwardedProto
|
|
||||||
}
|
|
||||||
host := r.Host
|
|
||||||
if forwardedHost := r.Header.Get("X-Forwarded-Host"); forwardedHost != "" {
|
|
||||||
host = forwardedHost
|
|
||||||
}
|
|
||||||
|
|
||||||
baseURL := scheme + "://" + host
|
|
||||||
|
|
||||||
issuer := strings.TrimSuffix(p.cfg.AuthServerBaseURL, "/") + "/token"
|
issuer := strings.TrimSuffix(p.cfg.AuthServerBaseURL, "/") + "/token"
|
||||||
|
|
||||||
response := map[string]interface{}{
|
response := map[string]interface{}{
|
||||||
"issuer": issuer,
|
"issuer": issuer,
|
||||||
"authorization_endpoint": baseURL + "/authorize",
|
"authorization_endpoint": p.cfg.BaseURL + "/authorize",
|
||||||
"token_endpoint": baseURL + "/token",
|
"token_endpoint": p.cfg.BaseURL + "/token",
|
||||||
"jwks_uri": p.cfg.JWKSURL,
|
"jwks_uri": p.cfg.JWKSURL,
|
||||||
"response_types_supported": []string{"code"},
|
"response_types_supported": []string{"code"},
|
||||||
"grant_types_supported": []string{"authorization_code", "refresh_token"},
|
"grant_types_supported": []string{"authorization_code", "refresh_token"},
|
||||||
"token_endpoint_auth_methods_supported": []string{"client_secret_basic"},
|
"token_endpoint_auth_methods_supported": []string{"client_secret_basic"},
|
||||||
"registration_endpoint": baseURL + "/register",
|
"registration_endpoint": p.cfg.BaseURL + "/register",
|
||||||
"code_challenge_methods_supported": []string{"plain", "S256"},
|
"code_challenge_methods_supported": []string{"plain", "S256"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,31 +40,17 @@ func (p *defaultProvider) WellKnownHandler() http.HandlerFunc {
|
||||||
// Use configured response values
|
// Use configured response values
|
||||||
responseConfig := pathConfig.Response
|
responseConfig := pathConfig.Response
|
||||||
|
|
||||||
// Get current host for proxy endpoints
|
|
||||||
scheme := "http"
|
|
||||||
if r.TLS != nil {
|
|
||||||
scheme = "https"
|
|
||||||
}
|
|
||||||
if forwardedProto := r.Header.Get("X-Forwarded-Proto"); forwardedProto != "" {
|
|
||||||
scheme = forwardedProto
|
|
||||||
}
|
|
||||||
host := r.Host
|
|
||||||
if forwardedHost := r.Header.Get("X-Forwarded-Host"); forwardedHost != "" {
|
|
||||||
host = forwardedHost
|
|
||||||
}
|
|
||||||
baseURL := scheme + "://" + host
|
|
||||||
|
|
||||||
authorizationEndpoint := responseConfig.AuthorizationEndpoint
|
authorizationEndpoint := responseConfig.AuthorizationEndpoint
|
||||||
if authorizationEndpoint == "" {
|
if authorizationEndpoint == "" {
|
||||||
authorizationEndpoint = baseURL + "/authorize"
|
authorizationEndpoint = p.cfg.BaseURL + "/authorize"
|
||||||
}
|
}
|
||||||
tokenEndpoint := responseConfig.TokenEndpoint
|
tokenEndpoint := responseConfig.TokenEndpoint
|
||||||
if tokenEndpoint == "" {
|
if tokenEndpoint == "" {
|
||||||
tokenEndpoint = baseURL + "/token"
|
tokenEndpoint = p.cfg.BaseURL + "/token"
|
||||||
}
|
}
|
||||||
registraionEndpoint := responseConfig.RegistrationEndpoint
|
registrationEndpoint := responseConfig.RegistrationEndpoint
|
||||||
if registraionEndpoint == "" {
|
if registrationEndpoint == "" {
|
||||||
registraionEndpoint = baseURL + "/register"
|
registrationEndpoint = p.cfg.BaseURL + "/register"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build response from config
|
// Build response from config
|
||||||
|
|
@ -76,7 +62,7 @@ func (p *defaultProvider) WellKnownHandler() http.HandlerFunc {
|
||||||
"response_types_supported": responseConfig.ResponseTypesSupported,
|
"response_types_supported": responseConfig.ResponseTypesSupported,
|
||||||
"grant_types_supported": responseConfig.GrantTypesSupported,
|
"grant_types_supported": responseConfig.GrantTypesSupported,
|
||||||
"token_endpoint_auth_methods_supported": []string{"client_secret_basic"},
|
"token_endpoint_auth_methods_supported": []string{"client_secret_basic"},
|
||||||
"registration_endpoint": registraionEndpoint,
|
"registration_endpoint": registrationEndpoint,
|
||||||
"code_challenge_methods_supported": responseConfig.CodeChallengeMethodsSupported,
|
"code_challenge_methods_supported": responseConfig.CodeChallengeMethodsSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue