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.rb')
-rw-r--r--lib/gitlab/ci/jwt.rb25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/gitlab/ci/jwt.rb b/lib/gitlab/ci/jwt.rb
index a8943eadf4f..0870c74053a 100644
--- a/lib/gitlab/ci/jwt.rb
+++ b/lib/gitlab/ci/jwt.rb
@@ -45,7 +45,7 @@ module Gitlab
end
def custom_claims
- {
+ fields = {
namespace_id: namespace.id.to_s,
namespace_path: namespace.full_path,
project_id: project.id.to_s,
@@ -59,6 +59,15 @@ module Gitlab
ref_type: ref_type,
ref_protected: build.protected.to_s
}
+
+ if include_environment_claims?
+ fields.merge!(
+ environment: environment.name,
+ environment_protected: environment_protected?.to_s
+ )
+ end
+
+ fields
end
def key
@@ -102,6 +111,20 @@ module Gitlab
def ref_type
::Ci::BuildRunnerPresenter.new(build).ref_type
end
+
+ def environment
+ build.persisted_environment
+ end
+
+ def environment_protected?
+ false # Overridden in EE
+ end
+
+ def include_environment_claims?
+ Feature.enabled?(:ci_jwt_include_environment) && environment.present?
+ end
end
end
end
+
+Gitlab::Ci::Jwt.prepend_if_ee('::EE::Gitlab::Ci::Jwt')