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
7bc9829e
Commit
7bc9829e
authored
Jan 14, 2020
by
Diego Louzán
Committed by
Bob Van Landuyt
Jan 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use POST for user session disable endpoints
User signout and admin mode disable use now POST instead of GET
parent
07dadce8
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
28 additions
and
11 deletions
+28
-11
app/views/errors/_footer.html.haml
app/views/errors/_footer.html.haml
+1
-1
app/views/layouts/header/_current_user_dropdown.html.haml
app/views/layouts/header/_current_user_dropdown.html.haml
+1
-1
app/views/layouts/nav/_dashboard.html.haml
app/views/layouts/nav/_dashboard.html.haml
+1
-1
changelogs/unreleased/refactor-session-disable-with-post.yml
changelogs/unreleased/refactor-session-disable-with-post.yml
+5
-0
config/initializers/8_devise.rb
config/initializers/8_devise.rb
+1
-1
config/routes/admin.rb
config/routes/admin.rb
+1
-1
spec/controllers/admin/sessions_controller_spec.rb
spec/controllers/admin/sessions_controller_spec.rb
+2
-2
spec/routing/admin_routing_spec.rb
spec/routing/admin_routing_spec.rb
+14
-0
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+2
-4
No files found.
app/views/errors/_footer.html.haml
View file @
7bc9829e
...
...
@@ -4,7 +4,7 @@
=
link_to
s_
(
'Nav|Home'
),
root_path
%li
-
if
current_user
=
link_to
s_
(
'Nav|Sign out and sign in with a different account'
),
destroy_user_session_path
=
link_to
s_
(
'Nav|Sign out and sign in with a different account'
),
destroy_user_session_path
,
method: :post
-
else
=
link_to
s_
(
'Nav|Sign In / Register'
),
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
%li
...
...
app/views/layouts/header/_current_user_dropdown.html.haml
View file @
7bc9829e
...
...
@@ -47,4 +47,4 @@
-
if
current_user_menu?
(
:sign_out
)
%li
.divider
%li
=
link_to
_
(
"Sign out"
),
destroy_user_session_path
,
class:
"sign-out-link"
,
data:
{
qa_selector:
'sign_out_link'
}
=
link_to
_
(
"Sign out"
),
destroy_user_session_path
,
method: :post
,
class:
"sign-out-link"
,
data:
{
qa_selector:
'sign_out_link'
}
app/views/layouts/nav/_dashboard.html.haml
View file @
7bc9829e
...
...
@@ -55,7 +55,7 @@
-
if
Feature
.
enabled?
(
:user_mode_in_session
)
-
if
header_link?
(
:admin_mode
)
=
nav_link
(
controller:
'admin/sessions'
)
do
=
link_to
destroy_admin_session_path
,
class:
'd-lg-none lock-open-icon'
do
=
link_to
destroy_admin_session_path
,
method: :post
,
class:
'd-lg-none lock-open-icon'
do
=
_
(
'Leave Admin Mode'
)
-
elsif
current_user
.
admin?
=
nav_link
(
controller:
'admin/sessions'
)
do
...
...
changelogs/unreleased/refactor-session-disable-with-post.yml
0 → 100644
View file @
7bc9829e
---
title
:
User signout and admin mode disable use now POST instead of GET
merge_request
:
22113
author
:
Diego Louzán
type
:
other
config/initializers/8_devise.rb
View file @
7bc9829e
...
...
@@ -203,7 +203,7 @@ Devise.setup do |config|
config
.
navigational_formats
=
[
:"*/*"
,
"*/*"
,
:html
,
:zip
]
# The default HTTP method used to sign out a resource. Default is :delete.
config
.
sign_out_via
=
:
ge
t
config
.
sign_out_via
=
:
pos
t
# ==> OmniAuth
# To configure a new OmniAuth provider copy and edit omniauth.rb.sample
...
...
config/routes/admin.rb
View file @
7bc9829e
...
...
@@ -24,7 +24,7 @@ namespace :admin do
end
resource
:session
,
only:
[
:new
,
:create
]
do
ge
t
'destroy'
,
action: :destroy
,
as: :destroy
pos
t
'destroy'
,
action: :destroy
,
as: :destroy
end
resource
:impersonation
,
only: :destroy
...
...
spec/controllers/admin/sessions_controller_spec.rb
View file @
7bc9829e
...
...
@@ -122,7 +122,7 @@ describe Admin::SessionsController, :do_not_mock_admin_mode do
describe
'#destroy'
do
context
'for regular users'
do
it
'shows error page'
do
ge
t
:destroy
pos
t
:destroy
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
controller
.
current_user_mode
.
admin_mode?
).
to
be
(
false
)
...
...
@@ -139,7 +139,7 @@ describe Admin::SessionsController, :do_not_mock_admin_mode do
post
:create
,
params:
{
password:
user
.
password
}
expect
(
controller
.
current_user_mode
.
admin_mode?
).
to
be
(
true
)
ge
t
:destroy
pos
t
:destroy
expect
(
response
).
to
have_gitlab_http_status
(
:found
)
expect
(
response
).
to
redirect_to
(
root_path
)
...
...
spec/routing/admin_routing_spec.rb
View file @
7bc9829e
...
...
@@ -161,3 +161,17 @@ describe Admin::GroupsController, "routing" do
expect
(
get
(
"/admin/groups/
#{
name
}
/edit"
)).
to
route_to
(
'admin/groups#edit'
,
id:
name
)
end
end
describe
Admin
::
SessionsController
,
"routing"
do
it
"to #new"
do
expect
(
get
(
"/admin/session/new"
)).
to
route_to
(
'admin/sessions#new'
)
end
it
"to #create"
do
expect
(
post
(
"/admin/session"
)).
to
route_to
(
'admin/sessions#create'
)
end
it
"to #destroy"
do
expect
(
post
(
"/admin/session/destroy"
)).
to
route_to
(
'admin/sessions#destroy'
)
end
end
spec/routing/routing_spec.rb
View file @
7bc9829e
...
...
@@ -256,10 +256,8 @@ describe "Authentication", "routing" do
expect
(
post
(
"/users/sign_in"
)).
to
route_to
(
'sessions#create'
)
end
# sign_out with GET instead of DELETE facilitates ad-hoc single-sign-out processes
# (https://gitlab.com/gitlab-org/gitlab-foss/issues/39708)
it
"GET /users/sign_out"
do
expect
(
get
(
"/users/sign_out"
)).
to
route_to
(
'sessions#destroy'
)
it
"POST /users/sign_out"
do
expect
(
post
(
"/users/sign_out"
)).
to
route_to
(
'sessions#destroy'
)
end
it
"POST /users/password"
do
...
...
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