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
c04f56d3
Commit
c04f56d3
authored
Nov 14, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs scaffold for encrypted token authenticatable
parent
ce22c7e1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletion
+21
-1
app/models/concerns/token_authenticatable_strategies/encrypted.rb
...ls/concerns/token_authenticatable_strategies/encrypted.rb
+2
-1
spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
...ncerns/token_authenticatable_strategies/encrypted_spec.rb
+19
-0
No files found.
app/models/concerns/token_authenticatable_strategies/encrypted.rb
View file @
c04f56d3
...
@@ -20,7 +20,8 @@ module TokenAuthenticatableStrategies
...
@@ -20,7 +20,8 @@ module TokenAuthenticatableStrategies
def
get_token
(
instance
)
def
get_token
(
instance
)
raw_token
=
instance
.
read_attribute
(
encrypted_field
)
raw_token
=
instance
.
read_attribute
(
encrypted_field
)
token
=
Gitlab
::
CryptoHelper
.
aes256_gcm_decrypt
(
raw_token
)
token
=
Gitlab
::
CryptoHelper
.
aes256_gcm_decrypt
(
raw_token
)
token
||=
fallback_strategy
.
get_token
(
instance
)
if
fallback?
token
||
(
fallback_strategy
.
get_token
(
instance
)
if
fallback?
)
end
end
def
set_token
(
instance
,
token
)
def
set_token
(
instance
,
token
)
...
...
spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
0 → 100644
View file @
c04f56d3
require
'spec_helper'
describe
TokenAuthenticatableStrategies
::
Encrypted
do
let
(
:model
)
{
double
(
:model
)
}
let
(
:options
)
{
{
fallback:
true
}
}
subject
do
described_class
.
new
(
model
,
'some_field'
,
options
)
end
describe
'#find_token_authenticatable'
do
end
describe
'#get_token'
do
end
describe
'#set_token'
do
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