Skip to content
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

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

LanceH
Copy link
Contributor

@LanceH LanceH commented Jul 8, 2019

This would allow a request to bypass to a specific provider by providing connector_id.

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! 🎉

  • Would you mind adding a test? And maybe a sentence somewhere explaining that this is a feature now?
  • Do you think this should interact with the "show back link" switch? It was introduced with show "back" link for password connectors #1123, and depends on len(connector)==1, too, if I remember correctly.

@@ -233,6 +233,15 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
return
}

if authReq.ConnectorID != "" {
for _, c := range connectors {
if c.ID == authReq.ConnectorID {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

Copy link
Contributor Author

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.

Copy link
Contributor

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...? 🤔

@srenatus
Copy link
Contributor

❔ Could you reset the commit's author to match your github user account? Just so the attribution works out well.

@LanceH
Copy link
Contributor Author

LanceH commented Jul 16, 2019

@srenatus I'm looking for a place to document this, but I can't find any mention of the index page of connectors in the workflow. Docs like "using-dex.md" just say, "Dex determines user's identity". Any ideas?

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments inline! thanks for bearing with me

if c.ID == connectorID {
break
}
return req, &authErr{"", "", errInvalidRequest, "Invalid ConnectorID"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this inside the for loop, it'll fail if there are more than one connectors, and the second one is the requested one. It would be nice if we had another test case for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now tests for selecting a connector other than the first.

server/oauth2.go Outdated Show resolved Hide resolved
@@ -233,6 +233,15 @@ func (s *Server) handleAuthorization(w http.ResponseWriter, r *http.Request) {
return
}

if authReq.ConnectorID != "" {
for _, c := range connectors {
if c.ID == authReq.ConnectorID {
Copy link
Contributor

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...? 🤔

@srenatus
Copy link
Contributor

@srenatus I'm looking for a place to document this, but I can't find any mention of the index page of connectors in the workflow. Docs like "using-dex.md" just say, "Dex determines user's identity". Any ideas?

Working code over documentation 😉 We could add a form field to example-app. I think that would be pretty neat. Let me know if you find this request just too annoying, and I'll pick up where you've left off.

At any rate, let's prepare to merge this -- would you mind squashing your commits? 😃

@LanceH LanceH force-pushed the master branch 2 times, most recently from 548d22e to df8d006 Compare July 22, 2019 14:39
@LanceH
Copy link
Contributor Author

LanceH commented Jul 22, 2019

Commits are squashed.

@@ -34,7 +34,7 @@ callback URL path:
( dex issuer URL )/callback/( connector id )?( url query )
```

For example, if dex is running at `https://auth.example.com/dex` and the connector
For example, if dex is running at `https:/0/auth.example.com/dex` and the connector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...hm?

Copy link
Contributor Author

@LanceH LanceH Jul 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@srenatus
Copy link
Contributor

Travis looks stuck...? @LanceH could you rebase upon master and f-push? 🤞 maybe it'll be picked up then.

@LanceH
Copy link
Contributor Author

LanceH commented Jul 22, 2019

Looks like Github had some outages, including this repo. I've kicked it off again.

Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🎉

@srenatus srenatus merged commit 421c26f into dexidp:master Jul 23, 2019
srenatus added a commit to srenatus/dex that referenced this pull request Jul 24, 2019
As a piece of "living documentation" for dexidp#1481.

Signed-off-by: Stephan Renatus <[email protected]>
mmrath pushed a commit to mmrath/dex that referenced this pull request Sep 2, 2019
Added "connector_id" to skip straight to a connector (similar to when len(connector) is 1.
mmrath pushed a commit to mmrath/dex that referenced this pull request Sep 2, 2019
As a piece of "living documentation" for dexidp#1481.

Signed-off-by: Stephan Renatus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants