-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added "connector_id" to skip straight to a connector (similar to when len(connector) is 1. #1481
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,7 @@ const ( | |
errUnsupportedGrantType = "unsupported_grant_type" | ||
errInvalidGrant = "invalid_grant" | ||
errInvalidClient = "invalid_client" | ||
errInvalidConnectorID = "invalid_connector_id" | ||
) | ||
|
||
const ( | ||
|
@@ -391,6 +392,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq | |
clientID := q.Get("client_id") | ||
state := q.Get("state") | ||
nonce := q.Get("nonce") | ||
connectorID := q.Get("connector_id") | ||
// Some clients, like the old go-oidc, provide extra whitespace. Tolerate this. | ||
scopes := strings.Fields(q.Get("scope")) | ||
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, ""} | ||
} | ||
|
||
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"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a validate function. Added a second connector to the test server. Added test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All right.So I ended up duplicating newTestServer to have newTestServerMultipleConnectors. It seems that the code workflow tests may depend on having a single connector, so adding in a second connector in order to test broke all of that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This now tests for selecting a connector other than the first. |
||
} | ||
} | ||
|
||
if !validateRedirectURI(client, redirectURI) { | ||
description := fmt.Sprintf("Unregistered redirect_uri (%q).", redirectURI) | ||
return req, &authErr{"", "", errInvalidRequest, description} | ||
|
@@ -509,6 +521,7 @@ func (s *Server) parseAuthorizationRequest(r *http.Request) (req storage.AuthReq | |
Scopes: scopes, | ||
RedirectURI: redirectURI, | ||
ResponseTypes: responseTypes, | ||
ConnectorID: connectorID, | ||
}, nil | ||
} | ||
|
||
|
@@ -568,6 +581,15 @@ func validateRedirectURI(client storage.Client, redirectURI string) bool { | |
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 | ||
type storageKeySet struct { | ||
storage.Storage | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Should this return an error if
connector_id
was specified but doesn't match any?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I debated this myself. What could it ever do with an error other than break flow completely or just return to the index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but it's still better than 🙈ignoring it, isn't it? I'd propose calling
s.tokenErrHelper
, maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not change anything with respect to showBacklink (#1123), since the number of connectors doesn't actually change. It would need an additional test such as authReq.ConnectorID != "" to suppress the link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we'd actually want to suppress the link, would we? Maybe you'd like to use a different method...? 🤔