|
|
|
@ -100,6 +100,7 @@ const ( |
|
|
|
errUnsupportedGrantType = "unsupported_grant_type" |
|
|
|
errUnsupportedGrantType = "unsupported_grant_type" |
|
|
|
errInvalidGrant = "invalid_grant" |
|
|
|
errInvalidGrant = "invalid_grant" |
|
|
|
errInvalidClient = "invalid_client" |
|
|
|
errInvalidClient = "invalid_client" |
|
|
|
|
|
|
|
errInvalidConnectorID = "invalid_connector_id" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
|
@ -391,6 +392,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq |
|
|
|
clientID := q.Get("client_id") |
|
|
|
clientID := q.Get("client_id") |
|
|
|
state := q.Get("state") |
|
|
|
state := q.Get("state") |
|
|
|
nonce := q.Get("nonce") |
|
|
|
nonce := q.Get("nonce") |
|
|
|
|
|
|
|
connectorID := q.Get("connector_id") |
|
|
|
// Some clients, like the old go-oidc, provide extra whitespace. Tolerate this.
|
|
|
|
// Some clients, like the old go-oidc, provide extra whitespace. Tolerate this.
|
|
|
|
scopes := strings.Fields(q.Get("scope")) |
|
|
|
scopes := strings.Fields(q.Get("scope")) |
|
|
|
responseTypes := strings.Fields(q.Get("response_type")) |
|
|
|
responseTypes := strings.Fields(q.Get("response_type")) |
|
|
|
@ -405,6 +407,16 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq |
|
|
|
return req, &authErr{"", "", errServerError, ""} |
|
|
|
return req, &authErr{"", "", errServerError, ""} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if connectorID != "" { |
|
|
|
|
|
|
|
connectors, err := s.storage.ListConnectors() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return req, &authErr{"", "", errServerError, "Unable to retrieve connectors"} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !validateConnectorID(connectors, connectorID) { |
|
|
|
|
|
|
|
return req, &authErr{"", "", errInvalidRequest, "Invalid ConnectorID"} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !validateRedirectURI(client, redirectURI) { |
|
|
|
if !validateRedirectURI(client, redirectURI) { |
|
|
|
description := fmt.Sprintf("Unregistered redirect_uri (%q).", redirectURI) |
|
|
|
description := fmt.Sprintf("Unregistered redirect_uri (%q).", redirectURI) |
|
|
|
return req, &authErr{"", "", errInvalidRequest, description} |
|
|
|
return req, &authErr{"", "", errInvalidRequest, description} |
|
|
|
@ -509,6 +521,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq |
|
|
|
Scopes: scopes, |
|
|
|
Scopes: scopes, |
|
|
|
RedirectURI: redirectURI, |
|
|
|
RedirectURI: redirectURI, |
|
|
|
ResponseTypes: responseTypes, |
|
|
|
ResponseTypes: responseTypes, |
|
|
|
|
|
|
|
ConnectorID: connectorID, |
|
|
|
}, nil |
|
|
|
}, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -568,6 +581,15 @@ func validateRedirectURI(client storage.Client, redirectURI string) bool { |
|
|
|
return err == nil && host == "localhost" |
|
|
|
return err == nil && host == "localhost" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func validateConnectorID(connectors []storage.Connector, connectorID string) bool { |
|
|
|
|
|
|
|
for _, c := range connectors { |
|
|
|
|
|
|
|
if c.ID == connectorID { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// storageKeySet implements the oidc.KeySet interface backed by Dex storage
|
|
|
|
// storageKeySet implements the oidc.KeySet interface backed by Dex storage
|
|
|
|
type storageKeySet struct { |
|
|
|
type storageKeySet struct { |
|
|
|
storage.Storage |
|
|
|
storage.Storage |
|
|
|
|