-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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(auth): add jwt support in auth middleware #15152
Conversation
6297532
to
e5c8b69
Compare
6d78e96
to
ce63e39
Compare
ce63e39
to
03a33ba
Compare
03a33ba
to
2fb3904
Compare
See |
@GeorgeMac This seems to be failing IDPE compatibility. you may want top update IDPE as well. |
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.
Needs IDPE compatibility (fix stuff in IDPE to support it?)
2fb3904
to
f073c65
Compare
Cheers @docmerlin |
f073c65
to
7801394
Compare
7801394
to
2e16df1
Compare
I re-requested review and added @jademcgough to this review as I needed to rebase over some recent changes to the auth middleware and could do with a sanity check. After discussions with the compute team it was decided that permission based auth fits well with the JWT token. The Authorizer interface exposes both permission checking capabilities (via The change that just went in just made the authentication middleware dependent on the UserID returned by the Authorizer type. Now it has a lookup on the user ID to ensure the associated User is TL;DR I updated my change to lean on the validity of the user ID in order to decided whether or not to make a user lookup for activity. |
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.
I like this better. It feels cleaner than the previous implementation.
2e16df1
to
29bd61a
Compare
Closes #14972
This PR adds support for JWT authorization to the http auth middleware.
This uses the new
jsonweb
package authorizer types.When
Token
based authorization is used an attempt is first made to deserialize the payload as a JWT. If the token is well-formed, it is assumed that JWT based authorization is being attempted. The token is then validated and if successful the permission claims are passed down via the usual Authorizer on context strategy.Given the token is not a well-formed JWT, then it is regarded as a lookup token for an associated Authorization in the AuthorizationService and treated as such. The Authorization is looked up using the token payload as the key.
Currently there is no decision as to how to configure a signing key, so this PR just introduces the mechanisms required for that work in the future. Currently an attempt to use a JWT will result in a no key found error. The token parser's KeyStore must be replace with a key store which returns a valid signing key for a given key id if JWT support is to be enabled.
UPDATE:
This also now transforms each of ourAuthorizer
types into the newPermissionsAuthorizer
type which is anAuthorizer
which can returns its set of permissions. This is required to create a token from anAuthorizer
.