|
@@ -3,6 +3,7 @@ package sso
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"net/http"
|
|
"net/http"
|
|
|
|
+ "strings"
|
|
)
|
|
)
|
|
|
|
|
|
type OpenIDConfiguration struct {
|
|
type OpenIDConfiguration struct {
|
|
@@ -17,12 +18,19 @@ type OpenIDConfiguration struct {
|
|
}
|
|
}
|
|
|
|
|
|
func (h *SSOHandler) HandleDiscoveryRequest(w http.ResponseWriter, r *http.Request) {
|
|
func (h *SSOHandler) HandleDiscoveryRequest(w http.ResponseWriter, r *http.Request) {
|
|
|
|
+
|
|
|
|
+ //Prepend https:// if not present
|
|
|
|
+ authBaseURL := h.Config.AuthURL
|
|
|
|
+ if !strings.HasPrefix(authBaseURL, "http://") && !strings.HasPrefix(authBaseURL, "https://") {
|
|
|
|
+ authBaseURL = "https://" + authBaseURL
|
|
|
|
+ }
|
|
|
|
+
|
|
//Handle the discovery request
|
|
//Handle the discovery request
|
|
discovery := OpenIDConfiguration{
|
|
discovery := OpenIDConfiguration{
|
|
- Issuer: "https://" + h.Config.AuthURL,
|
|
|
|
- AuthorizationEndpoint: "https://" + h.Config.AuthURL + "/oauth2/auth",
|
|
|
|
- TokenEndpoint: "https://" + h.Config.AuthURL + "/oauth2/token",
|
|
|
|
- JwksUri: "https://" + h.Config.AuthURL + "/jwks.json",
|
|
|
|
|
|
+ Issuer: authBaseURL,
|
|
|
|
+ AuthorizationEndpoint: authBaseURL + "/oauth2/authorize",
|
|
|
|
+ TokenEndpoint: authBaseURL + "/oauth2/token",
|
|
|
|
+ JwksUri: authBaseURL + "/jwks.json",
|
|
ResponseTypesSupported: []string{"code", "token"},
|
|
ResponseTypesSupported: []string{"code", "token"},
|
|
SubjectTypesSupported: []string{"public"},
|
|
SubjectTypesSupported: []string{"public"},
|
|
IDTokenSigningAlgValuesSupported: []string{
|
|
IDTokenSigningAlgValuesSupported: []string{
|
|
@@ -45,5 +53,6 @@ func (h *SSOHandler) HandleDiscoveryRequest(w http.ResponseWriter, r *http.Reque
|
|
|
|
|
|
//Write the response
|
|
//Write the response
|
|
js, _ := json.Marshal(discovery)
|
|
js, _ := json.Marshal(discovery)
|
|
|
|
+ w.Header().Set("Content-Type", "application/json")
|
|
w.Write(js)
|
|
w.Write(js)
|
|
}
|
|
}
|