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

Consider recommending verification and decoding of JWTs in two separate steps #8

Open
anderseknert opened this issue May 27, 2022 · 2 comments

Comments

@anderseknert
Copy link
Member

Although documented, even experienced users get confused by the default constraints (aud in particular) provided by io.jwt.decode_verify. I think we might want to consider recommending verifying and decoding as a two-step process, i.e.

Avoid

claims := payload {
    [valid, _, payload] := io.jwt.decode_verify("my_jwt_token", {"cert": "my certificate"})
    valid
}

Prefer

claims := payload {
    io.jwt.verify_rs256("my_jwt_token", "my certificate")
    [_, payload, _] := io.jwt.decode("my_jwt_token")
}
@srenatus
Copy link
Member

I generally agree, but we should also give examples of checking the nbf/exp, aud etc criteria from rego, then, maybe? Or at least call out the difference, and that you can't replace snippet 1 with snippet 2 and expect everything to be the same.

@anderseknert
Copy link
Member Author

Yes, or even better, provide a library for that purpose :)

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

No branches or pull requests

2 participants