diff options
Diffstat (limited to 'lib/gitlab/ci/jwt.rb')
-rw-r--r-- | lib/gitlab/ci/jwt.rb | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/lib/gitlab/ci/jwt.rb b/lib/gitlab/ci/jwt.rb index d82ca875e76..4ba7b4cc6e1 100644 --- a/lib/gitlab/ci/jwt.rb +++ b/lib/gitlab/ci/jwt.rb @@ -31,6 +31,11 @@ module Gitlab attr_reader :build, :ttl + delegate :project, :user, :pipeline, :runner, to: :build + delegate :source_ref, :source_ref_path, to: :pipeline + delegate :public_key, to: :key + delegate :namespace, to: :project + def reserved_claims now = Time.now.to_i @@ -53,11 +58,12 @@ module Gitlab user_id: user&.id.to_s, user_login: user&.username, user_email: user&.email, - pipeline_id: build.pipeline.id.to_s, - pipeline_source: build.pipeline.source.to_s, + pipeline_id: pipeline.id.to_s, + pipeline_source: pipeline.source.to_s, job_id: build.id.to_s, ref: source_ref, ref_type: ref_type, + ref_path: source_ref_path, ref_protected: build.protected.to_s } @@ -82,30 +88,10 @@ module Gitlab end end - def public_key - key.public_key - end - def kid public_key.to_jwk[:kid] end - def project - build.project - end - - def namespace - project.namespace - end - - def user - build.user - end - - def source_ref - build.pipeline.source_ref - end - def ref_type ::Ci::BuildRunnerPresenter.new(build).ref_type end |