Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
go-sso
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
id
go-sso
Commits
28fcb558
Commit
28fcb558
authored
Mar 20, 2020
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle the double-logout case more cleanly
Do not attempt to call backends (keystore) with empty usernames.
parent
f3fd32c0
Pipeline
#6151
passed with stages
in 3 minutes and 39 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
server/http.go
server/http.go
+6
-4
server/login/login.go
server/login/login.go
+4
-2
No files found.
server/http.go
View file @
28fcb558
...
@@ -330,6 +330,10 @@ type logoutServiceInfo struct {
...
@@ -330,6 +330,10 @@ type logoutServiceInfo struct {
// Logout handler. We generate a page that triggers child logout
// Logout handler. We generate a page that triggers child logout
// requests to all the services the user is logged in to.
// requests to all the services the user is logged in to.
//
// Unauthenticated requests to /logout will fall through to this
// handler, but auth.Username will be empty in that case. We are
// still going to show the logout page to avoid confusion.
func
(
h
*
Server
)
handleLogout
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
h
*
Server
)
handleLogout
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
auth
,
ok
:=
login
.
GetAuth
(
req
.
Context
())
auth
,
ok
:=
login
.
GetAuth
(
req
.
Context
())
if
!
ok
{
if
!
ok
{
...
@@ -337,8 +341,6 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request) {
...
@@ -337,8 +341,6 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request) {
return
return
}
}
//
var
svcs
[]
logoutServiceInfo
var
svcs
[]
logoutServiceInfo
for
_
,
svc
:=
range
auth
.
Services
{
for
_
,
svc
:=
range
auth
.
Services
{
svcs
=
append
(
svcs
,
logoutServiceInfo
{
svcs
=
append
(
svcs
,
logoutServiceInfo
{
...
@@ -354,8 +356,8 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request) {
...
@@ -354,8 +356,8 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request) {
"IncludeLogoutScripts"
:
true
,
"IncludeLogoutScripts"
:
true
,
}
}
// Close the keystore.
// Close the keystore
(only if the session had a valid username)
.
if
h
.
keystore
!=
nil
{
if
h
.
keystore
!=
nil
&&
auth
.
Username
!=
""
{
var
shard
string
var
shard
string
if
auth
.
UserInfo
!=
nil
{
if
auth
.
UserInfo
!=
nil
{
shard
=
auth
.
UserInfo
.
Shard
shard
=
auth
.
UserInfo
.
Shard
...
...
server/login/login.go
View file @
28fcb558
...
@@ -190,8 +190,10 @@ func (l *Login) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -190,8 +190,10 @@ func (l *Login) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// wrapped handler. Note that the Auth object will still
// wrapped handler. Note that the Auth object will still
// contain valid data, but Authenticated will be set to false.
// contain valid data, but Authenticated will be set to false.
if
req
.
URL
.
Path
==
l
.
urlFor
(
"/logout"
)
{
if
req
.
URL
.
Path
==
l
.
urlFor
(
"/logout"
)
{
log
.
Printf
(
"logging out user %s"
,
session
.
Username
)
if
session
.
Authenticated
{
session
.
Authenticated
=
false
log
.
Printf
(
"logging out user %s"
,
session
.
Username
)
session
.
Authenticated
=
false
}
session
.
Delete
()
session
.
Delete
()
}
else
if
!
session
.
Authenticated
{
}
else
if
!
session
.
Authenticated
{
// Save the current URL in the session for later redirect.
// Save the current URL in the session for later redirect.
...
...
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