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

Remove json-jwt, migrate ruby-jwt #177

Merged
merged 2 commits into from
Dec 7, 2022

Conversation

kristof-mattei
Copy link
Contributor

@kristof-mattei kristof-mattei commented Nov 2, 2022

This ensures we're using the same libs as in doorkeeper-jwt.

@kristof-mattei kristof-mattei changed the title feat: remove json-jwt, migrate ruby-jwt Remove json-jwt, migrate ruby-jwt Nov 2, 2022
@kristof-mattei kristof-mattei marked this pull request as ready for review November 2, 2022 20:01
@phlegx
Copy link
Contributor

phlegx commented Nov 2, 2022

@kristof-mattei
Copy link
Contributor Author

@phlegx ha, seems like I could've saved myself some time.

Couple of things:

  1. I used the same thumbprint as the json-jwt gem, so less changes
  2. No need for the normalized method to slice the data, the export filters that all out for you

@phlegx
Copy link
Contributor

phlegx commented Nov 2, 2022

@kristof-mattei very nice! So we dont need to slice anymore. Great job.

@phlegx
Copy link
Contributor

phlegx commented Nov 2, 2022

@toupeira looks good. What do you think? Time to move to ruby-jwt.

CHANGELOG.md Outdated Show resolved Hide resolved
@toupeira
Copy link
Member

toupeira commented Dec 3, 2022

@kristof-mattei thanks for this contribution, and apologies for the delay!

This LGTM, but I'm not really active in this project anymore and currently even lack a dev setup to test out these changes in a real app 😅 I don't really expect any problems though.

@nbulaj could you give this a look too? 🙏

@toupeira toupeira requested a review from nbulaj December 3, 2022 15:12
Copy link
Member

@nbulaj nbulaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Just changelog entry is missed.
Hope it won't break existing app setups

@kristof-mattei
Copy link
Contributor Author

LGTM 👍

Just changelog entry is missed.

Hope it won't break existing app setups

I'll update the changelog later today. I'll also add the changes of some string to symbol.

In terms of impacting other apps: does this warrant a major bump?

@toupeira
Copy link
Member

toupeira commented Dec 5, 2022

In terms of impacting other apps: does this warrant a major bump?

@kristof-mattei @nbulaj probably not since nothing should break (or even change), but one method I used in the past is to cut a prerelease gem, and then do a proper release after a few weeks, or once a user confirmed it to be working.

Co-authored-by: Markus Koller <markus-koller@gmx.ch>
@kristof-mattei
Copy link
Contributor Author

kristof-mattei commented Dec 5, 2022

In terms of impacting other apps: does this warrant a major bump?

@kristof-mattei @nbulaj probably not since nothing should break (or even change), but one method I used in the past is to cut a prerelease gem, and then do a proper release after a few weeks, or once a user confirmed it to be working.

Do we consider the JWK object as public API? Or just the JSON output. If the former:

https://github.com/doorkeeper-gem/doorkeeper-openid_connect/pull/177/files#diff-ef96e398572c3741045bbd9d4de1a7ee7d3e2059638732dcdd17be0a4c33c6e2R23-R26

Notice how the keys when from strings to symbols (e.g. 'kty' to :kty) and some of the values went from symbols to strings (e.g. :RSA to 'RSA').

If we only consider the JSON output then the public API did not change. =

@nbulaj committed your recommendation. I just had to click 'commit suggestion' 😅

@nbulaj
Copy link
Member

nbulaj commented Dec 6, 2022

Do we consider the JWK object as public API? Or just the JSON output. If the former:

The problem could be if somebody relied on json-jwt under the hood (and done some configuring for it, or patched, or whatever). It;s super common case actually. Just like with Doorkeeper internals - I saw a lot of cases when somebody patched them and then we break some private API 😃

Anyway I think it's OK to bump a minor (not patch) version as we actually don't break public API, yes, so I hope upgrading the gem should be smooth. Thanks @kristof-mattei

@nbulaj nbulaj merged commit 6552659 into doorkeeper-gem:master Dec 7, 2022
@kristof-mattei kristof-mattei deleted the json-jwt-to-ruby-jwt branch February 1, 2023 18:03
zavan added a commit to zavan/doorkeeper-openid_connect that referenced this pull request Feb 2, 2023
doorkeeper-gem#177 was actually released with 1.8.4.
@zavan zavan mentioned this pull request Feb 2, 2023
stanhu added a commit to stanhu/doorkeeper-openid_connect that referenced this pull request Apr 13, 2023
The switch from the `json-jwt` to `jwt` gem in doorkeeper-gem#177 changed the
default `kid` generation from RFC 7638
(https://www.rfc-editor.org/rfc/rfc7638) to a format based on the
SHA256 digest of the key elements.

However, clients may fail if the the `kid` generated by `IdToken` does
not match a key listed in JWKS discovery endpoint, which may be
implemented by the application using RFC 7638-based `kid` values. To
restore the previous behavior, applications have to set a global
setting:

```
JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
```

However, relying on this global setting is not ideal since other keys
may depend on the legacy `kid` values.

In keeping with semantic versioning, restore the `kid` generation to
RFC 7638. Whether this should be customizable can be discussed later.

Closes doorkeeper-gem#193
stanhu added a commit to stanhu/doorkeeper-openid_connect that referenced this pull request May 5, 2023
The switch from the `json-jwt` to `jwt` gem in doorkeeper-gem#177 changed the
default `kid` generation from RFC 7638
(https://www.rfc-editor.org/rfc/rfc7638) to a format based on the
SHA256 digest of the key elements.

However, clients may fail if the the `kid` generated by `IdToken` does
not match a key listed in JWKS discovery endpoint, which may be
implemented by the application using RFC 7638-based `kid` values. To
restore the previous behavior, applications have to set a global
setting:

```
JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
```

However, relying on this global setting is not ideal since other keys
may depend on the legacy `kid` values.

In keeping with semantic versioning, restore the `kid` generation to
RFC 7638. Whether this should be customizable can be discussed later.

Closes doorkeeper-gem#193
stanhu added a commit to stanhu/doorkeeper-openid_connect that referenced this pull request May 10, 2023
The switch from the `json-jwt` to `jwt` gem in doorkeeper-gem#177 changed the
default `kid` generation from RFC 7638
(https://www.rfc-editor.org/rfc/rfc7638) to a format based on the
SHA256 digest of the key elements.

However, clients may fail if the the `kid` generated by `IdToken` does
not match a key listed in JWKS discovery endpoint, which may be
implemented by the application using RFC 7638-based `kid` values. To
restore the previous behavior, applications have to set a global
setting:

```
JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
```

However, relying on this global setting is not ideal since other keys
may depend on the legacy `kid` values.

In keeping with semantic versioning, restore the `kid` generation to
RFC 7638. Whether this should be customizable can be discussed later.

Closes doorkeeper-gem#193
stanhu added a commit to stanhu/doorkeeper-openid_connect that referenced this pull request May 10, 2023
The switch from the `json-jwt` to `jwt` gem in doorkeeper-gem#177 changed the
default `kid` generation from RFC 7638
(https://www.rfc-editor.org/rfc/rfc7638) to a format based on the
SHA256 digest of the key elements.

However, clients may fail if the the `kid` generated by `IdToken` does
not match a key listed in JWKS discovery endpoint, which may be
implemented by the application using RFC 7638-based `kid` values. To
restore the previous behavior, applications have to set a global
setting:

```
JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
```

However, relying on this global setting is not ideal since other keys
may depend on the legacy `kid` values.

In keeping with semantic versioning, restore the `kid` generation to
RFC 7638. Whether this should be customizable can be discussed later.

Closes doorkeeper-gem#193
@mschoenlaub
Copy link

mschoenlaub commented Sep 8, 2023

Just out of curiosity, @nbulaj, how did you come to the conclusion that a public method on the Doorkeeper::OpenidConnect module (basically the top-level module of the gem) is not part of the public interface?
I'm just retroactively trying to understand the reasoning process here.

I'm asking partially to make more informed decisions for my own private projects in relation to semantic versioning in the ruby community, but partially also because we got bitten by that today ;-)

To me, that's a bit like saying Doorkeeper::OpenidConnect.configure isn't part of the public API, but maybe I'm missing something.

Additionally, from an integrator's perspective the changelog entry

Replace json-jwt with ruby-jwt to align with doorkeeper-jwt

is not exactly helpful. It just rang a bell because that same commit had broken another thing which had a covering test (due to our dependency on json-jwt-specific behaviour there)

The problem could be if somebody relied on json-jwt under the hood

I agree that under the assumption that if stuff breaks only for upstreams directly, like our first case above, a minor (maybe even a patch) bump would be fine. But in this case the return value of Doorkeeper::OpenidConnect.signing_key_normalized changed in a backwards-incompatible way.
Again, that is a public method on the top-level module of the gem.

I am aware that this might sound a bit like a rant and that maintaining a highly popular library in one's free time is not at all an easy task. So definitely thanks for that.

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

5 participants