Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
df973df8
Commit
df973df8
authored
May 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify JWT::RSAToken::kid
parent
715a8cfa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
lib/jwt/rsa_token.rb
lib/jwt/rsa_token.rb
+8
-4
No files found.
lib/jwt/rsa_token.rb
View file @
df973df8
...
@@ -29,10 +29,14 @@ module JWT
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment