Move websocket auth to keibi

This commit is contained in:
Zoe Roux
2025-12-18 20:37:15 +01:00
parent 82ede32aa7
commit 896d8f5cd0
3 changed files with 16 additions and 51 deletions
+11 -3
View File
@@ -44,9 +44,17 @@ func (h *Handler) CreateJwt(c echo.Context) error {
var token string
if auth == "" {
c, _ := c.Request().Cookie("X-Bearer")
if c != nil {
token = c.Value
cookie, _ := c.Request().Cookie("X-Bearer")
if cookie != nil {
token = cookie.Value
} else {
protocol, ok := c.Request().Header["Sec-Websocket-Protocol"]
if ok &&
len(protocol) == 2 &&
protocol[0] == "kyoo" &&
strings.HasPrefix(protocol[1], "Bearer") {
token = protocol[1][len("Bearer "):]
}
}
} else if strings.HasPrefix(auth, "Bearer ") {
token = auth[len("Bearer "):]