diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-14 18:23:55 -0500 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-05-14 18:23:55 -0500 |
commit | f63b6fc297b876e26b93c12ca510148d18d58ec2 (patch) | |
tree | 1d1fecab4031baf1fb65cb8176c47c40af8b5c62 /lib | |
parent | 5c19476286eb63325cbae7b1a21966e55712f367 (diff) | |
parent | f4f9184a01bc7442411bbcffd9b6a86784fa5f53 (diff) | |
download | gitlab-ce-f63b6fc297b876e26b93c12ca510148d18d58ec2.tar.gz |
Merge branch 'docker-registry' into docker-registry-view
Diffstat (limited to 'lib')
-rw-r--r-- | lib/json_web_token/rsa_token.rb (renamed from lib/jwt/rsa_token.rb) | 14 | ||||
-rw-r--r-- | lib/json_web_token/token.rb (renamed from lib/jwt/token.rb) | 2 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/jwt/rsa_token.rb b/lib/json_web_token/rsa_token.rb index 4de89bf0d37..d6d6af7089c 100644 --- a/lib/jwt/rsa_token.rb +++ b/lib/json_web_token/rsa_token.rb @@ -1,4 +1,4 @@ -module JWT +module JSONWebToken class RSAToken < Token attr_reader :key_file @@ -29,10 +29,14 @@ module JWT end def kid - fingerprint = Digest::SHA256.digest(public_key.to_der) - Base32.encode(fingerprint).split('').each_slice(4).each_with_object([]) do |slice, mem| - mem << slice.join - end.join(':') + # calculate sha256 from DER encoded ASN1 + kid = Digest::SHA256.digest(public_key.to_der) + + # 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 diff --git a/lib/jwt/token.rb b/lib/json_web_token/token.rb index f13abf2b71f..5b67715b0b2 100644 --- a/lib/jwt/token.rb +++ b/lib/json_web_token/token.rb @@ -1,4 +1,4 @@ -module JWT +module JSONWebToken class Token attr_accessor :issuer, :subject, :audience, :id attr_accessor :issued_at, :not_before, :expire_time |