-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: Handler to check azp claim #247
Conversation
http/middleware.go
Outdated
return nil | ||
} | ||
} | ||
|
||
// AuthorizedPartyFunc registers a handler that checks that the | ||
// 'azp' claim's value is included in the provided parties. | ||
func AuthorizedPartyFunc(parties ...string) func(string) bool { |
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.
As discussed in Slack, this personally confuses me.
Maybe a naming that conveys what it does (check containment in list) instead of a name that coincides with the param below.
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.
@yourtallness I made a couple of changes in a23a391
- Renamed the verification parameter from AuthorizedPartyFunc to AuthorizedPartyHandler
- Renamed the option helper in the middleware from AuthorizedPartyFunc to AuthorizedPartyMatches
Please let me know what you think, thanks!
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 is an improvement.
The ideal UX would probably automatically call the default matcher if no handler is provided, but I understand this may be impractical.
So, approving AFAIAC.
The JWT verification function accepts a handler that can be used to validate the 'azp' claim of the token. The WithHeaderAuthorization middleware accepts either a handler or a list of authorized parties that must contain the 'azp' claim.
a23a391
to
0e37cd0
Compare
The JWT verification function accepts a handler that can be used to validate the 'azp' claim of the token.
The WithHeaderAuthorization middleware accepts either a handler or a list of authorized parties that must contain the 'azp' claim.
You can use the option in two ways.