Commit 509654b3 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Improve JWT::RSAToken::kid

parent e900ff97
...@@ -24,11 +24,13 @@ module JWT ...@@ -24,11 +24,13 @@ module JWT
@key ||= OpenSSL::PKey::RSA.new(key_data) @key ||= OpenSSL::PKey::RSA.new(key_data)
end end
def public_key
key.public_key
end
def kid def kid
sha256 = Digest::SHA256.new fingerprint = Digest::SHA256.digest(public_key.to_der)
sha256.update(key.public_key.to_der) Base32.encode(fingerprint).split('').each_slice(4).each_with_object([]) do |slice, mem|
payload = StringIO.new(sha256.digest).read(30)
Base32.encode(payload).split('').each_slice(4).each_with_object([]) do |slice, mem|
mem << slice.join mem << slice.join
end.join(':') end.join(':')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment