-
Notifications
You must be signed in to change notification settings - Fork 116
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
kid
value in headers in different format after upgrading from 1.8.3 to 1.8.5
#193
Comments
kid
value in headers invalid after upgrading from 1.8.3 to 1.8.5kid
value in headers in different format ater upgrading from 1.8.3 to 1.8.5
kid
value in headers in different format ater upgrading from 1.8.3 to 1.8.5kid
value in headers in different format after upgrading from 1.8.3 to 1.8.5
The issue here is that with the switch to #177, the It's not obvious that applications need to set the generator to make the JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint This broke our application because we overrode There is a I think v1.8.x of this gem should default to the RFC7638 behavior: diff --git a/lib/doorkeeper/openid_connect.rb b/lib/doorkeeper/openid_connect.rb
index b2bca97..d20642e 100644
--- a/lib/doorkeeper/openid_connect.rb
+++ b/lib/doorkeeper/openid_connect.rb
@@ -48,7 +48,7 @@ module Doorkeeper
else
OpenSSL::PKey.read(configuration.signing_key)
end
- ::JWT::JWK.new(key)
+ ::JWT::JWK.new(key, { kid_generator: JWT::JWK::Thumbprint })
end
def self.signing_key_normalized I'm not sure if this needs to be customized. What do you think @nbulaj @kristof-mattei? |
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
#194 does this. |
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
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
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
This may not be an issue for everyone but I wanted to post an issue warning to others who are upgrading or might be facing an issue with the upgrade as this upgrade (
1.8.3
->1.8.5
) caused an authentication incident for my team today.Source of the problem
The root of the issue is this pull request: #177
This was called out as a potential issue in the PR itself by @nbulaj .
Specifically, this line of code.
The OpenID kid is an opaque value that is supposed to identify public keys.
json-jwt
andruby-jwt
implement the kid slightly differently:kid
format for json-jwt (used by1.8.3
)kid
format for ruby-jwt (used by1.8.5
)Normally
doorkeeper-openid_connect
manages both the generation of an OpenID token and the endpoint that allows clients to discover the public keys.In our application, however, we override
Doorkeeper::OpenidConnect::DiscoveryController
and for the JWK output in our controller we use callto_jwk
, which usesjson-jwt
NOTruby-jwt
Because our override of
Doorkeeper::OpenidConnect::DiscoveryController
assumes that thekid
format will be the format used byjson-jwt
, an upgrade to doorkeeper-openid_connect1.8.5
resulted in an incident for us because any service that validates the signature of a JWT using thekid
header value against thekid
in our keys discovery endpoint will raise an error (because thekid
s do not match).What I actually see
Screenshot of a (test) decoded JWT generated with
1.8.5
:What I expect to see
The
kid
should match thekid
value of my JWK#kid in my discovery keys endpoint ("OcGcrSBrUtT8mNNNkm1eofXGmOgM4SQtqFgFT8BCszU"
)Screenshot of a (test) decoded JWT generated with
1.8.3
:The text was updated successfully, but these errors were encountered: