Skip to content

Commit

Permalink
Merge pull request #188 from zavan/fix-doorkeeper-jwt-compatibility
Browse files Browse the repository at this point in the history
Fix dookeeper-jwt compatibility
  • Loading branch information
nbulaj committed Feb 2, 2023
2 parents b268d28 + 1d7c03b commit 9de10c0
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def self.signing_key
else
OpenSSL::PKey.read(configuration.signing_key)
end
JWT::JWK.new(key)
::JWT::JWK.new(key)
end

def self.signing_key_normalized
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/id_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def as_json(*_)
end

def as_jws_token
JWT.encode(as_json,
::JWT.encode(as_json,
Doorkeeper::OpenidConnect.signing_key.keypair,
Doorkeeper::OpenidConnect.signing_algorithm.to_s,
{ kid: Doorkeeper::OpenidConnect.signing_key.kid }
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/jwt.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
::JWT.configuration.jwk.kid_generator_type = :rfc7638_thumbprint
2 changes: 1 addition & 1 deletion spec/lib/id_token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
it 'returns claims encoded as JWT' do
algorithms = [Doorkeeper::OpenidConnect.signing_algorithm.to_s]

data, headers = JWT.decode subject.as_jws_token, Doorkeeper::OpenidConnect.signing_key.keypair, true, { algorithms: algorithms }
data, headers = ::JWT.decode subject.as_jws_token, Doorkeeper::OpenidConnect.signing_key.keypair, true, { algorithms: algorithms }

expect(data.to_hash).to eq subject.as_json.stringify_keys
expect(headers["kid"]).to eq Doorkeeper::OpenidConnect.signing_key.kid
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/openid_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

describe '.signing_key' do
it 'returns the private key as JWK instance' do
expect(subject.signing_key).to be_a JWT::JWK::KeyBase
expect(subject.signing_key).to be_a ::JWT::JWK::KeyBase
expect(subject.signing_key.kid).to eq 'IqYwZo2cE6hsyhs48cU8QHH4GanKIx0S4Dc99kgTIMA'
end
end
Expand Down

0 comments on commit 9de10c0

Please sign in to comment.