-
Notifications
You must be signed in to change notification settings - Fork 91
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
Allow users to retrieve JWT from a query and cookie with a specified name #89
base: master
Are you sure you want to change the base?
Allow users to retrieve JWT from a query and cookie with a specified name #89
Conversation
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.
LGTM.
However, could you think of a better name for the new functions? To me, With()
implies some with context
pkg.
I'm thinking jwtauth.TokenFromCookieByName("session")
or jwtauth.GetTokenFromCookie("session")
.
Thoughts?
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.
btw: there's a third function that's similar -- TokenFromHeader()
.
jwtauth.go
Outdated
@@ -251,10 +251,25 @@ func SetExpiryIn(claims map[string]interface{}, tm time.Duration) { | |||
claims["exp"] = ExpireIn(tm) | |||
} | |||
|
|||
const defaultCookieName = "jwt" |
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.
a single const (for cookie/header/query param) would be enough
to make it easier to understand the usage of of a function from the function name
Thanks for the review, and sorry for the delayed response. I changed the name of functions and cleaned up constants. It would be thankful if you check them again! Thanks! |
Fixes #88
TokenFromCookieWith
to retrieve jwt from a cookie with a name passed as an argument.TokenFromQueryWith
to retrieve jwt from a query with a name passed as an argument.How to Use