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

Add UserInfo endpoint #1473

Merged
merged 11 commits into from
Jul 2, 2019
Merged

Add UserInfo endpoint #1473

merged 11 commits into from
Jul 2, 2019

Conversation

alindeman
Copy link
Contributor

This PR takes the great work in #1454, reworks it a bit to lean on oidc.Verifier for verification, and adds tests.

Fixes #376
Closes #1133
Closes #1201
Closes #1453
Closes #1454

@alindeman alindeman force-pushed the add-user-endpoint branch from 7592623 to 7970903 Compare June 20, 2019 17:30
@alindeman
Copy link
Contributor Author

/cc @srenatus @mdbraber @lstoll for review

@srenatus
Copy link
Contributor

I'll review this next week. Thanks for contributing! 😃 🎉

@alindeman alindeman force-pushed the add-user-endpoint branch from 7970903 to 46f5726 Compare June 22, 2019 17:18
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.

🎉 It's nice to see this come together, thanks for contributing. Some nitpicks/questions inside 😃

}
rawIDToken := auth[len(prefix):]

verifier := oidc.NewVerifier(s.issuerURL.String(), &storageKeySet{s.storage}, &oidc.Config{SkipClientIDCheck: true})
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a costly operation? (I.e., do we want to store and re-use oidc.NewVerifier? (I have no idea, genuine question.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not, as far as I can tell. The implementation is currently:

func NewVerifier(issuerURL string, keySet KeySet, config *Config) *IDTokenVerifier {
	return &IDTokenVerifier{keySet: keySet, config: config, issuer: issuerURL}
}

Somewhat notably, constructing an oidc.Provider is a relatively expensive operation, but we don't have a need to do that in non-test code.

{
name: "fetch userinfo",
handleToken: func(ctx context.Context, p *oidc.Provider, config *oauth2.Config, token *oauth2.Token) error {
_, err := p.UserInfo(ctx, config.TokenSource(ctx, token))
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Would it be worthwhile to assert something on the response?

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 went back and forth on it. Not many of the other tests do, but since it ended up being easy enough, I've added something in 840065f. Let me know what you think.

@alindeman
Copy link
Contributor Author

🎉 It's nice to see this come together, thanks for contributing. Some nitpicks/questions inside 😃

@srenatus Thanks for the review. Let me know if you'd like to see anything else addressed.

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.

😃 LGTM, one question plus another nitpick. @JoelSpeed @ericchiang What do you think?

@@ -6,7 +6,7 @@ require (
github.com/boltdb/bolt v1.3.1 // indirect
github.com/cockroachdb/cmux v0.0.0-20170110192607-30d10be49292 // indirect
github.com/coreos/etcd v3.2.9+incompatible
github.com/coreos/go-oidc v0.0.0-20170307191026-be73733bb8cc
github.com/coreos/go-oidc v2.0.0+incompatible
Copy link
Contributor

Choose a reason for hiding this comment

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

❓Is this a problem somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it mostly means this repository uses a v2 tag, but not in the native go mod way. In fact, it's not been converted to a go module yet at all (therefore incompatible).

I'm personally not concerned about it: it's pretty standard fare while the Go community converts things slowly to modules over time. If/when go-oidc becomes a module, we might have to update some imports, but otherwise shouldn't be a big deal.

@@ -151,6 +152,7 @@ type discovery struct {
Auth string `json:"authorization_endpoint"`
Token string `json:"token_endpoint"`
Keys string `json:"jwks_uri"`
UserInfo string `json:"userinfo_endpoint"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you expand this test case for the discovery json, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Done, 59b6595

@alindeman
Copy link
Contributor Author

Any reviewers have any additional feedback or requests to change things?

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

I've had a read through and this seems sensible, happy with it if @srenatus is happy all his comments are resolved?

@srenatus
Copy link
Contributor

srenatus commented Jul 1, 2019

If no one beats me to it, I'll merge this tomorrow and push a release tag

lstoll pushed a commit to pardot/deci that referenced this pull request Jul 1, 2019
lstoll pushed a commit to pardot/deci that referenced this pull request Jul 1, 2019
lstoll pushed a commit to pardot/deci that referenced this pull request Jul 1, 2019
@srenatus
Copy link
Contributor

srenatus commented Jul 2, 2019

I've considered another round-trip with the @alindeman for squashing commits, but... I don't think it matters that much. I'm going to push the big green button. 🚀

@srenatus srenatus merged commit 8b4dbb9 into dexidp:master Jul 2, 2019
@mdbraber
Copy link
Contributor

mdbraber commented Jul 2, 2019

@srenatus @alindeman @jackielii @JoelSpeed thanks for all the work getting this implemented!

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.

UserInfo endpoint
5 participants