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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
fe4b5c98
Commit
fe4b5c98
authored
Dec 03, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix token encrypted strategy when migrating data
parent
0f5073d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
app/models/concerns/token_authenticatable_strategies/encrypted.rb
...ls/concerns/token_authenticatable_strategies/encrypted.rb
+7
-1
spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
...ncerns/token_authenticatable_strategies/encrypted_spec.rb
+17
-0
No files found.
app/models/concerns/token_authenticatable_strategies/encrypted.rb
View file @
fe4b5c98
...
@@ -19,11 +19,17 @@ module TokenAuthenticatableStrategies
...
@@ -19,11 +19,17 @@ module TokenAuthenticatableStrategies
.
find_by
(
encrypted_field
=>
encrypted_value
)
.
find_by
(
encrypted_field
=>
encrypted_value
)
end
end
if
migrating?
||
fallback
?
if
fallback?
||
migrating
?
token_authenticatable
||=
fallback_strategy
token_authenticatable
||=
fallback_strategy
.
find_token_authenticatable
(
token
)
.
find_token_authenticatable
(
token
)
end
end
if
migrating?
encrypted_value
=
Gitlab
::
CryptoHelper
.
aes256_gcm_encrypt
(
token
)
token_authenticatable
||=
relation
(
unscoped
)
.
find_by
(
encrypted_field
=>
encrypted_value
)
end
token_authenticatable
token_authenticatable
end
end
...
...
spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
View file @
fe4b5c98
...
@@ -66,9 +66,26 @@ describe TokenAuthenticatableStrategies::Encrypted do
...
@@ -66,9 +66,26 @@ describe TokenAuthenticatableStrategies::Encrypted do
.
with
(
'some_field'
=>
'my-value'
)
.
with
(
'some_field'
=>
'my-value'
)
.
and_return
(
nil
)
.
and_return
(
nil
)
allow
(
model
).
to
receive
(
:find_by
)
.
with
(
'some_field_encrypted'
=>
encrypted
)
.
and_return
(
nil
)
expect
(
subject
.
find_token_authenticatable
(
'my-value'
))
expect
(
subject
.
find_token_authenticatable
(
'my-value'
))
.
to
be_nil
.
to
be_nil
end
end
it
'finds by encrypted value if cleartext is not present'
do
allow
(
model
).
to
receive
(
:find_by
)
.
with
(
'some_field'
=>
'my-value'
)
.
and_return
(
nil
)
allow
(
model
).
to
receive
(
:find_by
)
.
with
(
'some_field_encrypted'
=>
encrypted
)
.
and_return
(
'encrypted resource'
)
expect
(
subject
.
find_token_authenticatable
(
'my-value'
))
.
to
eq
'encrypted resource'
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