Skip to content
Snippets Groups Projects
Commit df973df8 authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Simplify JWT::RSAToken::kid

parent 715a8cfa
No related branches found
No related tags found
1 merge request!3787Added authentication service for docker registry
Pipeline #
Loading
@@ -29,10 +29,14 @@ module JWT
Loading
@@ -29,10 +29,14 @@ module JWT
end end
   
def kid def kid
fingerprint = Digest::SHA256.digest(public_key.to_der) # calculate sha256 from DER encoded ASN1
Base32.encode(fingerprint).split('').each_slice(4).each_with_object([]) do |slice, mem| kid = Digest::SHA256.digest(public_key.to_der)
mem << slice.join
end.join(':') # we encode only 30 bytes with base32
kid = Base32.encode(kid[0..29])
# insert colon every 4 characters
kid.scan(/.{4}/).join(':')
end end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment