Class: Gitlab::Ci::Jwt
- Inherits:
-
Object
- Object
- Gitlab::Ci::Jwt
- Defined in:
- lib/gitlab/ci/jwt.rb
Direct Known Subclasses
Constant Summary collapse
- NOT_BEFORE_TIME =
5
- DEFAULT_EXPIRE_TIME =
60 * 5
- NoSigningKeyError =
Class.new(StandardError)
Class Method Summary collapse
Instance Method Summary collapse
- #encoded ⇒ Object
-
#initialize(build, ttl:) ⇒ Jwt
constructor
A new instance of Jwt.
- #payload ⇒ Object
Constructor Details
#initialize(build, ttl:) ⇒ Jwt
Returns a new instance of Jwt.
15 16 17 18 |
# File 'lib/gitlab/ci/jwt.rb', line 15 def initialize(build, ttl:) @build = build @ttl = ttl end |
Class Method Details
.for_build(build) ⇒ Object
11 12 13 |
# File 'lib/gitlab/ci/jwt.rb', line 11 def self.for_build(build) self.new(build, ttl: build.).encoded end |
Instance Method Details
#encoded ⇒ Object
24 25 26 27 28 |
# File 'lib/gitlab/ci/jwt.rb', line 24 def encoded headers = { kid: kid, typ: 'JWT' } JWT.encode(payload, key, 'RS256', headers) end |
#payload ⇒ Object
20 21 22 |
# File 'lib/gitlab/ci/jwt.rb', line 20 def payload custom_claims.merge(reserved_claims) end |