Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/ci/jwt_v2.rb')
-rw-r--r--lib/gitlab/ci/jwt_v2.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/ci/jwt_v2.rb b/lib/gitlab/ci/jwt_v2.rb
index 4e01688a955..cfefa79d9e0 100644
--- a/lib/gitlab/ci/jwt_v2.rb
+++ b/lib/gitlab/ci/jwt_v2.rb
@@ -3,13 +3,27 @@
module Gitlab
module Ci
class JwtV2 < Jwt
+ DEFAULT_AUD = Settings.gitlab.base_url
+
+ def self.for_build(build, aud: DEFAULT_AUD)
+ new(build, ttl: build.metadata_timeout, aud: aud).encoded
+ end
+
+ def initialize(build, ttl:, aud:)
+ super(build, ttl: ttl)
+
+ @aud = aud
+ end
+
private
+ attr_reader :aud
+
def reserved_claims
super.merge(
iss: Settings.gitlab.base_url,
sub: "project_path:#{project.full_path}:ref_type:#{ref_type}:ref:#{source_ref}",
- aud: Settings.gitlab.base_url
+ aud: aud
)
end
end