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
29bbf97e
Commit
29bbf97e
authored
Mar 10, 2022
by
John Mason
Committed by
Luke Duncalfe
Mar 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove feature flags for runner token prefix
Changelog: changed
parent
0cc6a229
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
120 deletions
+33
-120
app/models/concerns/runners_token_prefixable.rb
app/models/concerns/runners_token_prefixable.rb
+8
-0
app/models/group.rb
app/models/group.rb
+2
-11
app/models/project.rb
app/models/project.rb
+2
-11
config/feature_flags/development/groups_runners_token_prefix.yml
...feature_flags/development/groups_runners_token_prefix.yml
+0
-8
config/feature_flags/development/projects_runners_token_prefix.yml
...ature_flags/development/projects_runners_token_prefix.yml
+0
-8
spec/models/concerns/runners_token_prefixable_spec.rb
spec/models/concerns/runners_token_prefixable_spec.rb
+13
-0
spec/models/concerns/token_authenticatable_spec.rb
spec/models/concerns/token_authenticatable_spec.rb
+6
-29
spec/models/group_spec.rb
spec/models/group_spec.rb
+0
-8
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-10
spec/support/shared_examples/models/runners_token_prefix_shared_examples.rb
...d_examples/models/runners_token_prefix_shared_examples.rb
+0
-35
No files found.
app/models/concerns/runners_token_prefixable.rb
0 → 100644
View file @
29bbf97e
# frozen_string_literal: true
module
RunnersTokenPrefixable
# Prefix for runners_token which can be used to invalidate existing tokens.
# The value chosen here is GR (for Gitlab Runner) combined with the rotation
# date (20220225) decimal to hex encoded.
RUNNERS_TOKEN_PREFIX
=
'GR1348941'
end
app/models/group.rb
View file @
29bbf97e
...
...
@@ -22,11 +22,6 @@ class Group < Namespace
extend
::
Gitlab
::
Utils
::
Override
# Prefix for runners_token which can be used to invalidate existing tokens.
# The value chosen here is GR (for Gitlab Runner) combined with the rotation
# date (20220225) decimal to hex encoded.
RUNNERS_TOKEN_PREFIX
=
'GR1348941'
def
self
.
sti_name
'Group'
end
...
...
@@ -124,7 +119,7 @@ class Group < Namespace
add_authentication_token_field
:runners_token
,
encrypted:
->
{
Feature
.
enabled?
(
:groups_tokens_optional_encryption
,
default_enabled:
true
)
?
:optional
:
:required
},
prefix:
->
(
instance
)
{
instance
.
runners_token_prefix
}
prefix:
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
after_create
:post_create_hook
after_destroy
:post_destroy_hook
...
...
@@ -678,13 +673,9 @@ class Group < Namespace
ensure_runners_token!
end
def
runners_token_prefix
Feature
.
enabled?
(
:groups_runners_token_prefix
,
self
,
default_enabled: :yaml
)
?
RUNNERS_TOKEN_PREFIX
:
''
end
override
:format_runners_token
def
format_runners_token
(
token
)
"
#{
runners_token_prefix
}#{
token
}
"
"
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}#{
token
}
"
end
def
project_creation_level
...
...
app/models/project.rb
View file @
29bbf97e
...
...
@@ -90,11 +90,6 @@ class Project < ApplicationRecord
DEFAULT_SQUASH_COMMIT_TEMPLATE
=
'%{title}'
# Prefix for runners_token which can be used to invalidate existing tokens.
# The value chosen here is GR (for Gitlab Runner) combined with the rotation
# date (20220225) decimal to hex encoded.
RUNNERS_TOKEN_PREFIX
=
'GR1348941'
cache_markdown_field
:description
,
pipeline: :description
default_value_for
:packages_enabled
,
true
...
...
@@ -117,7 +112,7 @@ class Project < ApplicationRecord
add_authentication_token_field
:runners_token
,
encrypted:
->
{
Feature
.
enabled?
(
:projects_tokens_optional_encryption
,
default_enabled:
true
)
?
:optional
:
:required
},
prefix:
->
(
instance
)
{
instance
.
runners_token_prefix
}
prefix:
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
before_validation
:mark_remote_mirrors_for_removal
,
if:
->
{
RemoteMirror
.
table_exists?
}
...
...
@@ -1887,13 +1882,9 @@ class Project < ApplicationRecord
ensure_runners_token!
end
def
runners_token_prefix
Feature
.
enabled?
(
:projects_runners_token_prefix
,
self
,
default_enabled: :yaml
)
?
RUNNERS_TOKEN_PREFIX
:
''
end
override
:format_runners_token
def
format_runners_token
(
token
)
"
#{
runners_token_prefix
}#{
token
}
"
"
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}#{
token
}
"
end
def
pages_deployed?
...
...
config/feature_flags/development/groups_runners_token_prefix.yml
deleted
100644 → 0
View file @
0cc6a229
---
name
:
groups_runners_token_prefix
introduced_by_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/353805
milestone
:
'
14.9'
type
:
development
group
:
group::database
default_enabled
:
true
config/feature_flags/development/projects_runners_token_prefix.yml
deleted
100644 → 0
View file @
0cc6a229
---
name
:
projects_runners_token_prefix
introduced_by_url
:
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/353805
milestone
:
'
14.9'
type
:
development
group
:
group::database
default_enabled
:
true
spec/models/concerns/runners_token_prefixable_spec.rb
0 → 100644
View file @
29bbf97e
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
RunnersTokenPrefixable
do
describe
'runners token prefix'
do
subject
{
described_class
::
RUNNERS_TOKEN_PREFIX
}
it
'has the correct value'
do
expect
(
subject
).
to
eq
(
'GR1348941'
)
end
end
end
spec/models/concerns/token_authenticatable_spec.rb
View file @
29bbf97e
...
...
@@ -441,7 +441,7 @@ RSpec.shared_examples 'prefixed token rotation' do
context
'token is not set'
do
it
'generates a new token'
do
expect
(
subject
).
to
match
(
/^
#{
instance
.
class
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
subject
).
to
match
(
/^
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
instance
).
not_to
be_persisted
end
end
...
...
@@ -452,26 +452,14 @@ RSpec.shared_examples 'prefixed token rotation' do
end
it
'generates a new token'
do
expect
(
subject
).
to
match
(
/^
#{
instance
.
class
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
subject
).
to
match
(
/^
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
instance
).
not_to
be_persisted
end
context
'feature flag is disabled'
do
before
do
flag
=
"
#{
described_class
.
name
.
downcase
.
pluralize
}
_runners_token_prefix"
stub_feature_flags
(
flag
=>
false
)
end
it
'leaves the token unchanged'
do
expect
{
subject
}.
not_to
change
(
instance
,
:runners_token
)
expect
(
instance
).
not_to
be_persisted
end
end
end
context
'token is set and matches prefix'
do
before
do
instance
.
set_runners_token
(
instance
.
class
::
RUNNERS_TOKEN_PREFIX
+
'-abcdef'
)
instance
.
set_runners_token
(
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
+
'-abcdef'
)
end
it
'leaves the token unchanged'
do
...
...
@@ -486,7 +474,7 @@ RSpec.shared_examples 'prefixed token rotation' do
context
'token is not set'
do
it
'generates a new token'
do
expect
(
subject
).
to
match
(
/^
#{
instance
.
class
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
subject
).
to
match
(
/^
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
instance
).
to
be_persisted
end
end
...
...
@@ -497,25 +485,14 @@ RSpec.shared_examples 'prefixed token rotation' do
end
it
'generates a new token'
do
expect
(
subject
).
to
match
(
/^
#{
instance
.
class
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
subject
).
to
match
(
/^
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
/
)
expect
(
instance
).
to
be_persisted
end
context
'feature flag is disabled'
do
before
do
flag
=
"
#{
described_class
.
name
.
downcase
.
pluralize
}
_runners_token_prefix"
stub_feature_flags
(
flag
=>
false
)
end
it
'leaves the token unchanged'
do
expect
{
subject
}.
not_to
change
(
instance
,
:runners_token
)
end
end
end
context
'token is set and matches prefix'
do
before
do
instance
.
set_runners_token
(
instance
.
class
::
RUNNERS_TOKEN_PREFIX
+
'-abcdef'
)
instance
.
set_runners_token
(
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
+
'-abcdef'
)
instance
.
save!
end
...
...
spec/models/group_spec.rb
View file @
29bbf97e
...
...
@@ -3239,12 +3239,4 @@ RSpec.describe Group do
it_behaves_like
'no effective expiration interval'
end
end
describe
'#runners_token'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
subject
{
group
}
it_behaves_like
'it has a prefixable runners_token'
,
:groups_runners_token_prefix
end
end
spec/models/project_spec.rb
View file @
29bbf97e
...
...
@@ -813,8 +813,8 @@ RSpec.describe Project, factory_default: :keep do
end
it
'does not set an random token if one provided'
do
project
=
FactoryBot
.
create
(
:project
,
runners_token:
"
#{
Project
::
RUNNERS_TOKEN_PREFIX
}
my-token"
)
expect
(
project
.
runners_token
).
to
eq
(
"
#{
Project
::
RUNNERS_TOKEN_PREFIX
}
my-token"
)
project
=
FactoryBot
.
create
(
:project
,
runners_token:
"
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
my-token"
)
expect
(
project
.
runners_token
).
to
eq
(
"
#{
RunnersTokenPrefixable
::
RUNNERS_TOKEN_PREFIX
}
my-token"
)
end
end
...
...
@@ -8077,14 +8077,6 @@ RSpec.describe Project, factory_default: :keep do
end
end
describe
'#runners_token'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
subject
{
project
}
it_behaves_like
'it has a prefixable runners_token'
,
:projects_runners_token_prefix
end
private
def
finish_job
(
export_job
)
...
...
spec/support/shared_examples/models/runners_token_prefix_shared_examples.rb
deleted
100644 → 0
View file @
0cc6a229
# frozen_string_literal: true
RSpec
.
shared_examples
'it has a prefixable runners_token'
do
|
feature_flag
|
context
'feature flag enabled'
do
before
do
stub_feature_flags
(
feature_flag
=>
[
subject
])
end
describe
'#runners_token'
do
it
'has a runners_token_prefix'
do
expect
(
subject
.
runners_token_prefix
).
not_to
be_empty
end
it
'starts with the runners_token_prefix'
do
expect
(
subject
.
runners_token
).
to
start_with
(
subject
.
runners_token_prefix
)
end
end
end
context
'feature flag disabled'
do
before
do
stub_feature_flags
(
feature_flag
=>
false
)
end
describe
'#runners_token'
do
it
'does not have a runners_token_prefix'
do
expect
(
subject
.
runners_token_prefix
).
to
be_empty
end
it
'starts with the runners_token_prefix'
do
expect
(
subject
.
runners_token
).
to
start_with
(
subject
.
runners_token_prefix
)
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