mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-11-21 05:53:11 -05:00
Handle cookies in keibi
This commit is contained in:
parent
14c8f25499
commit
4dc34641ec
18
auth/jwt.go
18
auth/jwt.go
@ -40,13 +40,23 @@ func (h *Handler) CreateJwt(c echo.Context) error {
|
||||
}
|
||||
|
||||
auth := c.Request().Header.Get("Authorization")
|
||||
var jwt *string
|
||||
var token string
|
||||
|
||||
if !strings.HasPrefix(auth, "Bearer ") {
|
||||
if auth == "" {
|
||||
c, _ := c.Request().Cookie("X-Bearer")
|
||||
if c != nil {
|
||||
token = c.Value
|
||||
}
|
||||
} else if strings.HasPrefix(auth, "Bearer ") {
|
||||
token = auth[len("Bearer "):]
|
||||
} else if auth != "" {
|
||||
return echo.NewHTTPError(http.StatusUnauthorized, "Invalid bearer format.")
|
||||
}
|
||||
|
||||
var jwt *string
|
||||
if token == "" {
|
||||
jwt = h.createGuestJwt()
|
||||
} else {
|
||||
token := auth[len("Bearer "):]
|
||||
|
||||
tkn, err := h.createJwt(token)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -23,7 +23,7 @@ x-transcoder: &transcoder-base
|
||||
- "traefik.http.routers.transcoder.rule=PathPrefix(`/video`)"
|
||||
- "traefik.http.routers.transcoder.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
develop:
|
||||
watch:
|
||||
@ -94,7 +94,7 @@ services:
|
||||
- "traefik.http.routers.api.rule=PathPrefix(`/api/`) || PathPrefix(`/swagger`)"
|
||||
- "traefik.http.routers.api.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
develop:
|
||||
watch:
|
||||
@ -129,7 +129,7 @@ services:
|
||||
- "traefik.http.routers.scanner.rule=PathPrefix(`/scanner/`)"
|
||||
- "traefik.http.routers.scanner.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
command: fastapi dev scanner --host 0.0.0.0 --port 4389
|
||||
develop:
|
||||
|
||||
@ -19,7 +19,7 @@ x-transcoder: &transcoder-base
|
||||
- "traefik.http.routers.transcoder.rule=PathPrefix(`/video`)"
|
||||
- "traefik.http.routers.transcoder.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
|
||||
services:
|
||||
@ -64,7 +64,7 @@ services:
|
||||
- "traefik.http.routers.api.rule=PathPrefix(`/api/`) || PathPrefix(`/swagger`)"
|
||||
- "traefik.http.routers.api.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
|
||||
scanner:
|
||||
@ -86,7 +86,7 @@ services:
|
||||
- "traefik.http.routers.scanner.rule=PathPrefix(`/scanner/`)"
|
||||
- "traefik.http.routers.scanner.middlewares=phantom-token"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.address=http://auth:4568/auth/jwt"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,Cookie,X-Api-Key"
|
||||
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
|
||||
|
||||
transcoder:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user