mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +00:00
fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi.
This commit is contained in:
@@ -147,7 +147,12 @@ func (h *OAuthHandler) HandleCallback(rw http.ResponseWriter, req *http.Request,
|
|||||||
cookie, err := req.Cookie("_oidc_raczylo_m")
|
cookie, err := req.Cookie("_oidc_raczylo_m")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.logger.Errorf("Main session cookie not found in request: %v", err)
|
h.logger.Errorf("Main session cookie not found in request: %v", err)
|
||||||
h.logger.Debugf("Available cookies: %v", req.Header.Get("Cookie"))
|
// Log cookie names only, not values (avoid logging sensitive session data)
|
||||||
|
cookieNames := make([]string, 0, len(req.Cookies()))
|
||||||
|
for _, c := range req.Cookies() {
|
||||||
|
cookieNames = append(cookieNames, c.Name)
|
||||||
|
}
|
||||||
|
h.logger.Debugf("Available cookies (names only): %v", cookieNames)
|
||||||
} else {
|
} else {
|
||||||
h.logger.Errorf("Main session cookie exists but CSRF token is empty. Cookie value length: %d", len(cookie.Value))
|
h.logger.Errorf("Main session cookie exists but CSRF token is empty. Cookie value length: %d", len(cookie.Value))
|
||||||
h.logger.Debugf("Cookie details - Domain: %s, Path: %s, Secure: %v, HttpOnly: %v, SameSite: %v",
|
h.logger.Debugf("Cookie details - Domain: %s, Path: %s, Secure: %v, HttpOnly: %v, SameSite: %v",
|
||||||
|
|||||||
+4
-1
@@ -5,6 +5,7 @@ package traefikoidc
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -144,6 +145,8 @@ func (t *TraefikOidc) sendErrorResponse(rw http.ResponseWriter, req *http.Reques
|
|||||||
t.logger.Debugf("Sending HTML error response (code %d): %s", code, message)
|
t.logger.Debugf("Sending HTML error response (code %d): %s", code, message)
|
||||||
|
|
||||||
returnURL := "/"
|
returnURL := "/"
|
||||||
|
// Escape message to prevent XSS attacks
|
||||||
|
escapedMessage := html.EscapeString(message)
|
||||||
|
|
||||||
htmlBody := fmt.Sprintf(`
|
htmlBody := fmt.Sprintf(`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -165,7 +168,7 @@ func (t *TraefikOidc) sendErrorResponse(rw http.ResponseWriter, req *http.Reques
|
|||||||
<p><a href="%s">Return to application</a></p>
|
<p><a href="%s">Return to application</a></p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`, message, returnURL)
|
</html>`, escapedMessage, returnURL)
|
||||||
|
|
||||||
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
|
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
rw.WriteHeader(code)
|
rw.WriteHeader(code)
|
||||||
|
|||||||
Reference in New Issue
Block a user