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 *WithClaims methods to jwt middleware for more advanced usage. #488

Merged
merged 4 commits into from
Mar 16, 2017

Conversation

cam-stitt
Copy link
Contributor

I started migrating our existing JWT layer to go-kit's version however I was not able to complete the process. We implement a custom jwt.Claims object and need to be able to add middleware layers that use this.

This PR adds some new exported middlewares that allow for advanced claim types.

@cam-stitt
Copy link
Contributor Author

I'm happy with the state of this PR. Would appreciate a review 👍

@peterbourgon
Copy link
Member

I don't have enough context or knowledge of JWT to properly review the semantics here, but the code looks good. Unless @briankassouf wants to object, I'll merge in 48h.

t.Fatal("Claims were not passed into context correctly")
}
if !stdCl.VerifyAudience("go-kit", true) {
t.Fatal("JWT jwt.StandardClaims.Audience did not match: expecting %s got %s", standardClaims.Audience, stdCl.Audience)
Copy link
Member

Choose a reason for hiding this comment

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

t.Fatalf

@basvanbeek
Copy link
Member

basvanbeek commented Mar 15, 2017

Only one little t.Fatalf but for the rest LGTM.

I do have one potential addition for the middleware_test in highlighting the typical practice of embedding a jwt.StandardClaims struct to create a custom claims type.

I've taken the liberty to add onto this PR and code can be seen here:

master...basvanbeek:jwt-claims

@briankassouf
Copy link
Contributor

This change looks good to me!

@peterbourgon peterbourgon merged commit c9c7219 into go-kit:master Mar 16, 2017
@peterbourgon
Copy link
Member

Thanks @cam-stitt and everyone!

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.

4 participants