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
cded1917
Commit
cded1917
authored
Nov 05, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Rubocop happy
parent
ed29dcaf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
7 deletions
+30
-7
ee/lib/gitlab/geo/oauth_session.rb
ee/lib/gitlab/geo/oauth_session.rb
+30
-7
No files found.
ee/lib/gitlab/geo/oauth_session.rb
View file @
cded1917
...
@@ -21,7 +21,8 @@ module Gitlab
...
@@ -21,7 +21,8 @@ module Gitlab
end
end
def
extract_logout_token
def
extract_logout_token
LogoutState
.
new
(
*
state
.
to_s
.
split
(
':'
,
3
)).
decode
salt
,
encrypted
,
return_to
=
state
.
to_s
.
split
(
':'
,
3
)
LogoutState
.
new
(
salt
,
encrypted
,
return_to
).
decode
end
end
def
get_oauth_state_return_to
def
get_oauth_state_return_to
...
@@ -49,7 +50,12 @@ module Gitlab
...
@@ -49,7 +50,12 @@ module Gitlab
private
private
class
LoginState
<
Struct
.
new
(
:salt
,
:return_to
)
class
LoginState
def
initialize
(
salt
,
return_to
)
@salt
=
salt
@return_to
=
return_to
end
def
valid?
(
hmac
)
def
valid?
(
hmac
)
return
false
unless
salt
&&
return_to
return
false
unless
salt
&&
return_to
...
@@ -64,14 +70,23 @@ module Gitlab
...
@@ -64,14 +70,23 @@ module Gitlab
private
private
attr_reader
:salt
,
:return_to
def
generate_hmac
def
generate_hmac
digest
=
OpenSSL
::
Digest
.
new
(
'sha256'
)
digest
=
OpenSSL
::
Digest
.
new
(
'sha256'
)
key
=
Gitlab
::
Application
.
secrets
.
secret_key_base
+
salt
key
=
Gitlab
::
Application
.
secrets
.
secret_key_base
+
salt
OpenSSL
::
HMAC
.
hexdigest
(
digest
,
key
,
return_to
)
OpenSSL
::
HMAC
.
hexdigest
(
digest
,
key
,
return_to
)
end
end
end
end
class
LogoutState
<
Struct
.
new
(
:salt
,
:token
,
:return_to
)
class
LogoutState
def
initialize
(
salt
,
token
,
return_to
)
@salt
=
salt
@token
=
token
@return_to
=
return_to
end
def
decode
def
decode
return
unless
salt
&&
token
return
unless
salt
&&
token
...
@@ -95,6 +110,8 @@ module Gitlab
...
@@ -95,6 +110,8 @@ module Gitlab
private
private
attr_reader
:salt
,
:token
,
:return_to
def
cipher
(
salt
,
operation
)
def
cipher
(
salt
,
operation
)
cipher
=
OpenSSL
::
Cipher
::
AES
.
new
(
128
,
:CBC
)
cipher
=
OpenSSL
::
Cipher
::
AES
.
new
(
128
,
:CBC
)
cipher
.
__send__
(
operation
)
# rubocop:disable GitlabSecurity/PublicSend
cipher
.
__send__
(
operation
)
# rubocop:disable GitlabSecurity/PublicSend
...
@@ -108,7 +125,11 @@ module Gitlab
...
@@ -108,7 +125,11 @@ module Gitlab
end
end
end
end
class
ReturnToLocation
<
Struct
.
new
(
:location
)
class
ReturnToLocation
def
initialize
(
location
)
@location
=
location
end
def
full_path
def
full_path
uri
=
parse_uri
(
location
)
uri
=
parse_uri
(
location
)
full_path_for_uri
(
uri
)
if
uri
full_path_for_uri
(
uri
)
if
uri
...
@@ -116,6 +137,8 @@ module Gitlab
...
@@ -116,6 +137,8 @@ module Gitlab
private
private
attr_reader
:location
def
parse_uri
(
location
)
def
parse_uri
(
location
)
location
&&
URI
.
parse
(
location
)
location
&&
URI
.
parse
(
location
)
rescue
URI
::
InvalidURIError
rescue
URI
::
InvalidURIError
...
@@ -129,11 +152,11 @@ module Gitlab
...
@@ -129,11 +152,11 @@ module Gitlab
end
end
def
oauth_salt
def
oauth_salt
@salt
||=
SecureRandom
.
hex
(
8
)
@
oauth_
salt
||=
SecureRandom
.
hex
(
8
)
end
end
def
oauth_client
def
oauth_client
@client
||=
begin
@
oauth_
client
||=
begin
::
OAuth2
::
Client
.
new
(
::
OAuth2
::
Client
.
new
(
oauth_app
.
uid
,
oauth_app
.
uid
,
oauth_app
.
secret
,
oauth_app
.
secret
,
...
...
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