-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
jwt: iterate over roles #1536
Comments
Do you mean you'd like to search for a role name in the array? (PostgREST can only accept one role at a time) The |
Not sure if this is really follows the spec, but looks like the expression could be: role-claim-key=".realm_access{.roles == 'myrole'}[0]" |
Yes I have multiple roles in my array and I'd like to match one of them against postgresql or postgrest configuration. I wanted to try your proposal but actually, https://github.com/PostgREST/postgrest/blob/master/src/PostgREST/Parsers.hs#L259-L272 prevents the full usage of JSPath features:
I'm exploring an alternative with Keycloak to provide a single string to bypass the issue. However, I'll be happy to test any patch :) |
@michael-todorovic Yes, that was mostly a proposal. Not implemented for now. Though adding the capability looks reasonable since it follows jspath. I could help reviewing a PR If you'd like to give it a shot. Otherwise the single string role is your best bet for now. |
@michael-todorovic, I used a custom mapper to check that I had a specific role. I then added another claim according to the test. |
@Videl I would - yes please. |
@michael-todorovic It seems I have the some issues with Keycloak and multiple roles too. Did you ever solve your issue, to only provide a single role as you mentioned above...? Care to dig it up? Thanks |
Considering #2877, looks we also need prefix string comparison |
Would like a solution on this as well, same problem using auth0 as we cannot guarantee the order of the claims... |
Would ❤️ to see this too! Keycloak is a major OAuth provider and pretty much always comes with multiple roles. Should be solvable with some JSPath magic? For now I'm praying on Keycloak always putting the last added role first in the array.. |
I’m also facing the same issue when trying to work with JWTs through Microsoft Entra and I can’t guarantee the role order for all my users. My organization requires for this information to be managed through Entra app roles meaning that it will only show up in the roles array. Would really love to see a solution for this! |
@steve-chavez We could extend our Which of these do you think we should add to close this issue? |
I'd suggest string comparison operators would work as we'd be able to check substring if a claim exists within the key. Curious if others agree. |
@taimoorzaeem @mbwmbw1337 Yes, we would only need the string comparison operators for this issue. |
Also we need to test those work on an array. |
Environment
Description of issue
Hello,
I configured postgrest authentication through jwt with Keycloak and here is what I get for my roles in the jwt token:
In postgrest.conf, I have set
role-claim-key = ".realm_access.roles"
but postgrest takes it as a simple string and I getI tried to look at parsers.hs but I don't know haskell so I was unable to tell if it's feasible or not.
As
role1
exists in my DB, I got it working withrole-claim-key = ".realm_access.roles[0]"
but this not good enough for production as the list ordering may depend on the user.Do you have any clue how I can achieve this?
Thanks!
The text was updated successfully, but these errors were encountered: