mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-09 01:47:03 +00:00
fix: revert frontChannelLogout impl.
This commit is contained in:
@@ -1,26 +1,27 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// FrontChannelLogout triggers logout triggered by a third-party.
|
||||
func (h *Handler) FrontChannelLogout(w http.ResponseWriter, r *http.Request) {
|
||||
sessionParamKeys := []string{"sid", "session_state"}
|
||||
externalSessionID := extractExternalSessionID(r, sessionParamKeys)
|
||||
params := r.URL.Query()
|
||||
sid := params.Get("sid")
|
||||
|
||||
// Unconditionally destroy all local references to the session.
|
||||
h.deleteCookie(w, SessionCookieName, h.Cookies)
|
||||
|
||||
if len(externalSessionID) == 0 {
|
||||
log.Infof("any of parameters %q not set in request; ignoring", sessionParamKeys)
|
||||
if len(sid) == 0 {
|
||||
log.Info("sid parameter not set in request; ignoring")
|
||||
h.DeleteSessionFallback(w, r)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
|
||||
sessionID := h.localSessionID(externalSessionID)
|
||||
sessionID := h.localSessionID(sid)
|
||||
|
||||
err := h.destroySession(w, r, sessionID)
|
||||
if err != nil {
|
||||
@@ -30,15 +31,3 @@ func (h *Handler) FrontChannelLogout(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
func extractExternalSessionID(r *http.Request, paramKeys []string) string {
|
||||
params := r.URL.Query()
|
||||
var sessionId = ""
|
||||
for _, k := range paramKeys {
|
||||
sessionId = params.Get(k)
|
||||
if len(sessionId) != 0 {
|
||||
return sessionId
|
||||
}
|
||||
}
|
||||
return sessionId
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user