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
e50eb47d
Commit
e50eb47d
authored
Mar 08, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix OAuth session code for Geo
parent
0a8cfbd5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
app/controllers/oauth/geo_auth_controller.rb
app/controllers/oauth/geo_auth_controller.rb
+1
-1
app/models/geo/oauth_session.rb
app/models/geo/oauth_session.rb
+4
-4
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+1
-1
No files found.
app/controllers/oauth/geo_auth_controller.rb
View file @
e50eb47d
...
@@ -23,7 +23,7 @@ class Oauth::GeoAuthController < ActionController::Base
...
@@ -23,7 +23,7 @@ class Oauth::GeoAuthController < ActionController::Base
token
=
client
.
auth_code
.
get_token
(
params
[
:code
],
redirect_uri:
oauth_geo_callback_url
).
token
token
=
client
.
auth_code
.
get_token
(
params
[
:code
],
redirect_uri:
oauth_geo_callback_url
).
token
@user_session
=
::
Geo
::
User
.
new
(
state:
params
[
:state
])
@user_session
=
Geo
::
OauthSession
.
new
(
state:
params
[
:state
])
remote_user
=
@user_session
.
authenticate
(
access_token:
token
)
remote_user
=
@user_session
.
authenticate
(
access_token:
token
)
user
=
User
.
find
(
remote_user
[
'id'
])
user
=
User
.
find
(
remote_user
[
'id'
])
...
...
app/models/geo/oauth_session.rb
View file @
e50eb47d
...
@@ -12,13 +12,13 @@ class Geo::OauthSession
...
@@ -12,13 +12,13 @@ class Geo::OauthSession
salt
,
hmac
,
return_to
=
state
.
split
(
':'
,
3
)
salt
,
hmac
,
return_to
=
state
.
split
(
':'
,
3
)
return
false
unless
return_to
return
false
unless
return_to
hmac
==
self
.
generate_oauth_hmac
(
salt
)
hmac
==
generate_oauth_hmac
(
salt
,
return_to
)
end
end
def
generate_oauth_state
def
generate_oauth_state
return
unless
return_to
return
unless
return_to
salt
=
generate_oauth_salt
salt
=
generate_oauth_salt
hmac
=
generate_oauth_hmac
(
salt
)
hmac
=
generate_oauth_hmac
(
salt
,
return_to
)
"
#{
salt
}
:
#{
hmac
}
:
#{
return_to
}
"
"
#{
salt
}
:
#{
hmac
}
:
#{
return_to
}
"
end
end
...
@@ -42,8 +42,8 @@ class Geo::OauthSession
...
@@ -42,8 +42,8 @@ class Geo::OauthSession
SecureRandom
.
hex
(
16
)
SecureRandom
.
hex
(
16
)
end
end
def
generate_oauth_hmac
(
salt
)
def
generate_oauth_hmac
(
salt
,
return_to
)
return
unless
return_to
return
false
unless
return_to
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
)
...
...
lib/gitlab/geo.rb
View file @
e50eb47d
...
@@ -41,7 +41,7 @@ module Gitlab
...
@@ -41,7 +41,7 @@ module Gitlab
end
end
def
self
.
oauth_authentication
def
self
.
oauth_authentication
return
false
unless
self
.
readonl
y?
return
false
unless
Gitlab
::
Geo
.
secondar
y?
Gitlab
::
Geo
.
current_node
.
oauth_application
Gitlab
::
Geo
.
current_node
.
oauth_application
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