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

Enable asymmetric algorithms #253

Conversation

lauramosher
Copy link
Contributor

Description

Warden::JWTAuth added support for asymmetric algorithms, allowing the
specification of a separate decoding secret from the standard secret.

This, along with the (included) change from #250, fixes the "No verification key
available" error as well as enables support to allow folks to use Devise::JWT with an algorithm of their choosing, including an asymmetric algorithm if they so choose.

`Warden::JWTAuth` shipped a feature for Asymmetric algorithms which adds a
configuration setting for `decoding_secret`. By default, this is setting is
configured to use `secret` when it is not otherwise explicitly set.

On first encounter and my limited testing, I thought the default behavior
was not correctly working and submitted an issue on: waiting-for-dev/warden-jwt_auth#44

Upon further testing, however, it was clear the defaults were working as expected
in that repository. The issue turned out to be that the configuration was
being prematurely "cached" as nil before `secret` was ever set in devise-jwt.

Before:

Output of Devise::JWT.config
```
{
  secret: "keep-it-secret",
  ...
}
```

Output of Warden::JWTAuth.config
```
{
  secret: "keep-it-secret",
  decoding_secret: nil,
  ...
}
```

After:

Output of Devise::JWT.config
```
{
  secret: "keep-it-secret",
  ...
}
```

Output of Warden::JWTAuth.config
```
{
  secret: "keep-it-secret",
  decoding_secret: "keep-it-secret",
  ...
}
```

I'm not entirely sure the purpose the `.to_h` was serving in `self.jwt`;
however, all of the specs still pass without those lines, the configuration
looks correct / yielding the expected settings, and testing against the app
that prompted this deep dive is resolved with this change.
Warden::JWTAuth added support for asymmetric algorithms, allowing the
specification of a separate decoding secret from the standard secret.

This, along with the change from waiting-for-dev#250, fixes the "No verification key
available" error as well as allows folks to use Devise::JWT with
asymmetric algorithms if they so choose.
@waiting-for-dev
Copy link
Owner

Many thanks! 🙌

@waiting-for-dev
Copy link
Owner

Available on v0.10.0. Thanks again for your collaboration!

Eric-Guo added a commit to thape-cn/oauth2id that referenced this pull request Sep 16, 2022
@lauramosher lauramosher deleted the enable-asymmetric-algorithms branch October 28, 2022 02:31
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 this pull request may close these issues.

None yet

2 participants