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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a174be9e
Commit
a174be9e
authored
Feb 11, 2021
by
Tiger
Committed by
Tiger Watson
Feb 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag for environment details in CI JWT
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53431
parent
4d2cd304
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
9 deletions
+25
-9
changelogs/unreleased/294440-add-environment-details-to-jwt.yml
...logs/unreleased/294440-add-environment-details-to-jwt.yml
+0
-5
config/feature_flags/development/ci_jwt_include_environment.yml
.../feature_flags/development/ci_jwt_include_environment.yml
+8
-0
doc/ci/examples/authenticating-with-hashicorp-vault/index.md
doc/ci/examples/authenticating-with-hashicorp-vault/index.md
+1
-3
lib/gitlab/ci/jwt.rb
lib/gitlab/ci/jwt.rb
+5
-1
spec/lib/gitlab/ci/jwt_spec.rb
spec/lib/gitlab/ci/jwt_spec.rb
+11
-0
No files found.
changelogs/unreleased/294440-add-environment-details-to-jwt.yml
deleted
100644 → 0
View file @
4d2cd304
---
title
:
Add environment to custom JWT claims
merge_request
:
53431
author
:
type
:
added
config/feature_flags/development/ci_jwt_include_environment.yml
0 → 100644
View file @
a174be9e
---
name
:
ci_jwt_include_environment
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53431
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/321206
milestone
:
'
13.9'
type
:
development
group
:
group::configure
default_enabled
:
false
doc/ci/examples/authenticating-with-hashicorp-vault/index.md
View file @
a174be9e
...
@@ -53,9 +53,7 @@ The JWT's payload looks like this:
...
@@ -53,9 +53,7 @@ The JWT's payload looks like this:
"job_id"
:
"1212"
,
#
"job_id"
:
"1212"
,
#
"ref"
:
"auto-deploy-2020-04-01"
,
#
Git
ref
for
this
job
"ref"
:
"auto-deploy-2020-04-01"
,
#
Git
ref
for
this
job
"ref_type"
:
"branch"
,
#
Git
ref
type
,
branch
or
tag
"ref_type"
:
"branch"
,
#
Git
ref
type
,
branch
or
tag
"ref_protected"
:
"true"
,
#
true
if
this
git
ref
is
protected
,
false
otherwise
"ref_protected"
:
"true"
#
true
if
this
git
ref
is
protected
,
false
otherwise
"environment"
:
"production"
,
#
Environment
this
job
deploys
to
,
if
present
"environment_protected"
:
"true"
#
true
if
deployed
environment
is
protected
,
false
otherwise
}
}
```
```
...
...
lib/gitlab/ci/jwt.rb
View file @
a174be9e
...
@@ -60,7 +60,7 @@ module Gitlab
...
@@ -60,7 +60,7 @@ module Gitlab
ref_protected:
build
.
protected
.
to_s
ref_protected:
build
.
protected
.
to_s
}
}
if
environment
.
present
?
if
include_environment_claims
?
fields
.
merge!
(
fields
.
merge!
(
environment:
environment
.
name
,
environment:
environment
.
name
,
environment_protected:
environment_protected?
.
to_s
environment_protected:
environment_protected?
.
to_s
...
@@ -119,6 +119,10 @@ module Gitlab
...
@@ -119,6 +119,10 @@ module Gitlab
def
environment_protected?
def
environment_protected?
false
# Overridden in EE
false
# Overridden in EE
end
end
def
include_environment_claims?
Feature
.
enabled?
(
:ci_jwt_include_environment
)
&&
environment
.
present?
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/jwt_spec.rb
View file @
a174be9e
...
@@ -114,6 +114,17 @@ RSpec.describe Gitlab::Ci::Jwt do
...
@@ -114,6 +114,17 @@ RSpec.describe Gitlab::Ci::Jwt do
expect
(
payload
[
:environment
]).
to
eq
(
'production'
)
expect
(
payload
[
:environment
]).
to
eq
(
'production'
)
expect
(
payload
[
:environment_protected
]).
to
eq
(
'false'
)
expect
(
payload
[
:environment_protected
]).
to
eq
(
'false'
)
end
end
context
':ci_jwt_include_environment feature flag is disabled'
do
before
do
stub_feature_flags
(
ci_jwt_include_environment:
false
)
end
it
'does not include environment attributes'
do
expect
(
payload
).
not_to
have_key
(
:environment
)
expect
(
payload
).
not_to
have_key
(
:environment_protected
)
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