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

JWT verification fails with audience claim #955

Closed
russelldavies opened this issue Aug 27, 2017 · 12 comments
Closed

JWT verification fails with audience claim #955

russelldavies opened this issue Aug 27, 2017 · 12 comments

Comments

@russelldavies
Copy link
Contributor

russelldavies commented Aug 27, 2017

In the jose library if the aud claim is present in the JWT then during verification it validates this claim.

Currently, there is no way to disable this or set the audience claim so verification is unsuccessful. Specifically, the JWTNotInAudience message is generated during JWT verification.

@begriffs
Copy link
Member

Can you provide more information please, such as the http request and error message?

@russelldavies
Copy link
Contributor Author

@begriffs I accidentally tabbed and hit return and the form posted before I had a chance to finish typing. I've edited it now.

@begriffs
Copy link
Member

Oh man that sounds bad, so if aud is present then it just lets any claim through??

@russelldavies
Copy link
Contributor Author

Not at all, it just fails with a JWTNotInAudience error. In the defaultJWTValidationSettings unless the aud claim is set to what is in the JWT aud claim then the JWT is rejected.

So a solution is to either disable this check or to instruct the jose library what the audience to check should be, through the postgrest configuration file.

@willscripted
Copy link

willscripted commented Aug 30, 2017

^^ So,

if `aud`
  verify against value in pgrst-config

That sounds like it wouldn't break anything for existing deployments.

@begriffs
Copy link
Member

begriffs commented Sep 6, 2017

Yeah sounds straightforward. I'll open a PR to implement this.

@statik
Copy link
Contributor

statik commented Sep 15, 2017

I've managed to configure postgrest 0.4.3 with a JWK retrieved from keycloak, and specify a custom mapper in keycloak so that I can force a "role" claim to be included in the JWT to satisfy postgrest. However, I'm now running into the error JWTNotInAudience from postgrest. I have not been able to find any way to configure keycloak to leave the "aud" claim out of the JWT, so I think the workaround for Auth0 isn't viable for keycloak.

I'm pretty newbie to haskell but interested in helping with this if the PR is not already written as I have already invested a bunch of time figuring out keycloak and this seems to be the last missing piece to get postgrest working with keycloak.

statik added a commit to statik/postgrest that referenced this issue Sep 15, 2017
Signed-off-by: Elliot Murphy <[email protected]>
statik added a commit to statik/postgrest that referenced this issue Sep 26, 2017
Signed-off-by: Elliot Murphy <[email protected]>
@marsouin
Copy link

@statik this is great, I have the same issue, can I update Postgrest with your work?

@statik
Copy link
Contributor

statik commented Sep 26, 2017

@marsouin this was just merged to master an hour ago, I am currently running with a version I built from source until the next release comes out and it's working ok for me.

@marsouin
Copy link

Oh awesome! Any tips on building it? I'm very new to Haskell...

@russelldavies
Copy link
Contributor Author

@marsouin The build instructions cover this.

@russelldavies
Copy link
Contributor Author

I've created a pull request in the docs for this (PostgREST/postgrest-docs#106) so closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants