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
388e07e1
Commit
388e07e1
authored
Aug 30, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix rubocop offense
parent
b05f4a56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
10 deletions
+10
-10
app/controllers/oauth/geo_auth_controller.rb
app/controllers/oauth/geo_auth_controller.rb
+2
-2
lib/gitlab/geo/oauth_session.rb
lib/gitlab/geo/oauth_session.rb
+1
-1
spec/controllers/oauth/geo_auth_controller_spec.rb
spec/controllers/oauth/geo_auth_controller_spec.rb
+2
-2
spec/lib/gitlab/geo/oauth_session_spec.rb
spec/lib/gitlab/geo/oauth_session_spec.rb
+5
-5
No files found.
app/controllers/oauth/geo_auth_controller.rb
View file @
388e07e1
...
...
@@ -4,7 +4,7 @@ class Oauth::GeoAuthController < ActionController::Base
def
auth
oauth
=
Gitlab
::
Geo
::
OauthSession
.
new
(
state:
params
[
:state
])
unless
oauth
.
is_
oauth_state_valid?
unless
oauth
.
oauth_state_valid?
redirect_to
root_url
return
end
...
...
@@ -14,7 +14,7 @@ class Oauth::GeoAuthController < ActionController::Base
def
callback
oauth
=
Gitlab
::
Geo
::
OauthSession
.
new
(
state:
params
[
:state
])
unless
oauth
.
is_
oauth_state_valid?
unless
oauth
.
oauth_state_valid?
redirect_to
new_user_session_path
return
end
...
...
lib/gitlab/geo/oauth_session.rb
View file @
388e07e1
...
...
@@ -7,7 +7,7 @@ module Gitlab
attr_accessor
:state
attr_accessor
:return_to
def
is_
oauth_state_valid?
def
oauth_state_valid?
return
false
unless
state
salt
,
hmac
,
return_to
=
state
.
split
(
':'
,
3
)
...
...
spec/controllers/oauth/geo_auth_controller_spec.rb
View file @
388e07e1
...
...
@@ -16,7 +16,7 @@ describe Oauth::GeoAuthController do
let
(
:primary_node_oauth_endpoint
)
{
Gitlab
::
Geo
::
OauthSession
.
new
.
authorize_url
(
redirect_uri:
oauth_geo_callback_url
,
state:
auth_state
)
}
it
'redirects to root_url when state is invalid'
do
allow_any_instance_of
(
Gitlab
::
Geo
::
OauthSession
).
to
receive
(
:
is_
oauth_state_valid?
)
{
false
}
allow_any_instance_of
(
Gitlab
::
Geo
::
OauthSession
).
to
receive
(
:oauth_state_valid?
)
{
false
}
get
:auth
,
state:
auth_state
expect
(
response
).
to
redirect_to
(
root_url
)
...
...
@@ -40,7 +40,7 @@ describe Oauth::GeoAuthController do
end
it
'redirects to login screen if state is invalid'
do
allow_any_instance_of
(
Gitlab
::
Geo
::
OauthSession
).
to
receive
(
:
is_
oauth_state_valid?
)
{
false
}
allow_any_instance_of
(
Gitlab
::
Geo
::
OauthSession
).
to
receive
(
:oauth_state_valid?
)
{
false
}
get
:callback
,
state:
callback_state
expect
(
response
).
to
redirect_to
(
new_user_session_path
)
...
...
spec/lib/gitlab/geo/oauth_session_spec.rb
View file @
388e07e1
...
...
@@ -14,24 +14,24 @@ describe Gitlab::Geo::OauthSession do
allow
(
subject
).
to
receive
(
:primary_node_url
)
{
'http://localhost:3001/'
}
end
describe
'#
is_
oauth_state_valid?'
do
describe
'#oauth_state_valid?'
do
it
'returns false when state is not present'
do
expect
(
subject
.
is_
oauth_state_valid?
).
to
be_falsey
expect
(
subject
.
oauth_state_valid?
).
to
be_falsey
end
it
'returns false when return_to cannot be retrieved'
do
subject
.
state
=
'invalidstate'
expect
(
subject
.
is_
oauth_state_valid?
).
to
be_falsey
expect
(
subject
.
oauth_state_valid?
).
to
be_falsey
end
it
'returns false when hmac does not match'
do
subject
.
state
=
dummy_state
expect
(
subject
.
is_
oauth_state_valid?
).
to
be_falsey
expect
(
subject
.
oauth_state_valid?
).
to
be_falsey
end
it
'returns true when hmac matches generated one'
do
subject
.
state
=
valid_state
expect
(
subject
.
is_
oauth_state_valid?
).
to
be_truthy
expect
(
subject
.
oauth_state_valid?
).
to
be_truthy
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