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

custom claims not working with JSONata array syntax #434

Closed
xmlking opened this issue Nov 8, 2023 · 3 comments
Closed

custom claims not working with JSONata array syntax #434

xmlking opened this issue Nov 8, 2023 · 3 comments
Labels

Comments

@xmlking
Copy link
Contributor

xmlking commented Nov 8, 2023

I am using custom claims / AUTH_JWT_CUSTOM_CLAIMS
As per this document, JSONata syntax should be supported.

This is Working

[[auth.session.accessToken.customClaims]]
key = 'org-id'
value = 'organizations[].organization'
{
  "https://hasura.io/jwt/claims": {
    "x-hasura-org-id": "{\"chinthagunta\",\"example\"}",
    "x-hasura-allowed-roles": [
      "me",
      "user",
      "manager"
    ],
    "x-hasura-default-role": "user",
    "x-hasura-user-id": "d3b12728-accf-4732-83ac-2e605341731c",
    "x-hasura-user-is-anonymous": "false"
  },
  "sub": "d3b12728-accf-4732-83ac-2e605341731c",
  "iat": 1699434443,
  "exp": 1699435343,
  "iss": "hasura-auth"
}

This is NOT Working

[[auth.session.accessToken.customClaims]]
key = 'org-id'
value = 'organizations[0].organization'
{
  "https://hasura.io/jwt/claims": {
    "x-hasura-allowed-roles": [
      "me",
      "user",
      "manager"
    ],
    "x-hasura-default-role": "user",
    "x-hasura-user-id": "d3b12728-accf-4732-83ac-2e605341731c",
    "x-hasura-user-is-anonymous": "false"
  },
  "sub": "d3b12728-accf-4732-83ac-2e605341731c",
  "iat": 1699434606,
  "exp": 1699435506,
  "iss": "hasura-auth"
}

hasura-auth logs

nhost-kit-auth-1  | {"level":"warn","message":"Invalid custom JWT GraphQL Query","request":"query ($userId: uuid!) { user (id: $userId) { organizations[0] { organization } } }"}
nhost-kit-auth-1  | {"level":"warn","message":"Invalid custom JWT GraphQL Query","request":"query ($userId: uuid!) { user (id: $userId) { organizations[0] { organization } } }"}
nhost-kit-auth-1  | {"level":"warn","message":"Invalid custom JWT GraphQL Query","request":"query ($userId: uuid!) { user (id: $userId) { organizations[0] { organization } } }
@dbarrosop
Copy link
Contributor

You are right, that documentation needs to be updated to mention that only . and [] are supported, not the full spec.

@dbarrosop
Copy link
Contributor

dbarrosop commented Nov 8, 2023

if you need to select only one in particular for some reason you can try adding a computed field and using that instead.

Copy link

stale bot commented May 6, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 6, 2024
@stale stale bot closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants