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

Support additional JWT algorithms #84

Closed
kevinbader opened this issue Jul 5, 2018 · 0 comments · Fixed by #85
Closed

Support additional JWT algorithms #84

kevinbader opened this issue Jul 5, 2018 · 0 comments · Fixed by #85
Assignees

Comments

@kevinbader
Copy link
Contributor

Currently

RIG supports hs256 only; the secret is read from JWT_SECRET_KEY.

Idea:

Joken, the library we're using for handling JWTs, supports more than just the HS* algorithms. The idea is to use the hs/rs/... functions found in signer.ex and support specifying the algorithm using an additional environment variable. For example:

JWT_ALG=HS256
JWT_KEY=my-symmetric-key

or

JWT_ALG=RS256
JWT_KEY=my-public-key

Basically, you'd do something along the lines of:

jwt_alg
|> String.downcase
|> case do
  "hs" <> _ = alg -> Signer.hs(alg, jwt_key)
  "rs" <> _ = alg -> Signer.rs(alg, jwt_key)
  ...
end

Additional thoughts

Joken does not support token encryption, which might be a future requirement. Here's a nice overview about JWT algorithms and what they're used for.

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

Successfully merging a pull request may close this issue.

2 participants