Make /jwt return an Authorization header for traefik

This commit is contained in:
Zoe Roux 2025-03-23 23:52:31 +01:00
parent e6e2f8ce91
commit 825619b11d
No known key found for this signature in database
2 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"crypto/x509"
"encoding/pem"
"fmt"
"maps"
"net/http"
"strings"
@ -67,6 +68,7 @@ func (h *Handler) CreateJwt(c echo.Context) error {
if err != nil {
return err
}
c.Response().Header().Add("Authorization", fmt.Sprintf("Bearer %s", t))
return c.JSON(http.StatusOK, Jwt{
Token: t,
})

View File

@ -86,8 +86,8 @@ services:
- "traefik.http.routers.api.rule=PathPrefix(`/api/`)"
- "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.authResponseHeaders=Authorization"
- "traefik.http.middlewares.phantom-token.forwardauth.authRequestHeaders=Authorization,X-Api-Key"
- "traefik.http.middlewares.phantom-token.forwardauth.authResponseHeaders=Authorization"
# scanner:
# build: ./scanner