-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add config for stringified hasura claims in JWT (fix #1176) #1538
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
Conversation
this is required, as some providers like AWS Cognito allows only strings in custom claims.
|
Review app for commit 2855566 deployed to Heroku: https://hge-ci-pull-1538.herokuapp.com |
docs/graphql/manual/auth/jwt.rst
Outdated
| "jwk_url": "<optional-url-to-refresh-jwks>", | ||
| "claims_namespace": "<optional-key-name-in-claims>" | ||
| "claims_namespace": "<optional-key-name-in-claims>", | ||
| "is_stringified": <optional-boolean> |
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.
claims_are_stringified_json?
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.
or claims_format? can be one of json/stringified_json. The default can be json.
|
|
||
| validateIsObject jVal = | ||
| parseObjectFromString isStrngfd jVal = | ||
| case jVal of |
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.
case (isStrngFd, jVal) of
(True, String x) -> string parsing logic
(True, _) -> "expecting a string when the format is stringified_json"
(False, Object o) -> return o
(False, _) -> "expecting a json object when the format is json"Something along those lines. More readable.
| (JCFJson, _) -> | ||
| throw400 JWTInvalidClaims "expecting a json object when claims_format is json" | ||
|
|
||
| strngfdErr = "Could not parse JSON string under: '" |
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.
Something simpler like: "expecting stringified json at" <> loc <> "but found: " <> v?
| instance Show JWTCtx where | ||
| show (JWTCtx _ nsM audM) = | ||
| show ["<IORef JWKSet>", show nsM, show audM] | ||
| show (JWTCtx _ nsM audM strfd) = |
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.
remove references to strfd, isstrngfd?
|
Review app https://hge-ci-pull-1538.herokuapp.com is deleted |
<!-- The PR description should answer 2 important questions: --> ### What Fix relationships to model aggregates V3_GIT_ORIGIN_REV_ID: e00c5d382f3429447920b41bb2854a8a88d0ac1a
Add support for AWS Cognito JWT
Add config option (
claims_format) to indicate if the hasura specific claims in JWT are stringified.This is required, as some providers like AWS Cognito allow only strings in custom claims.
Default :
json.When
stringified_json, Hasura will expect stringified hasura claims:{ "sub": "1234567890", "name": "John Doe", "admin": true, "iat": 1516239022, "https://hasura.io/jwt/claims": "{\"x-hasura-allowed-roles\":[\"editor\",\"user\",\"mod\"],\"x-hasura-default-role\":\"user\",\"x-hasura-user-id\":\"1234567890\",\"x-hasura-org-id\":\"123\",\"x-hasura-custom\":\"custom-value\"}" }What component does this PR affect?
Requires changes from other components? If yes, please mark the components:
Related Issue
#1176
Solution and Design
Type
Checklist: