From 7e0bc84b0fa9255f4148b935cedea4015615fc02 Mon Sep 17 00:00:00 2001 From: WilliamB78 Date: Tue, 4 Mar 2025 09:59:42 +0100 Subject: [PATCH 1/2] feat: add Remote-User header --- docker-compose.dev.yml | 1 + docker-compose.example.yml | 1 + internal/api/api.go | 2 ++ 3 files changed, 4 insertions(+) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 12e59f9..f550606 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -31,3 +31,4 @@ services: traefik.http.routers.tinyauth.rule: Host(`tinyauth.dev.local`) traefik.http.services.tinyauth.loadbalancer.server.port: 3000 traefik.http.middlewares.tinyauth.forwardauth.address: http://tinyauth:3000/api/auth/traefik + traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: Remote-User diff --git a/docker-compose.example.yml b/docker-compose.example.yml index c19ae98..6af3925 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -29,3 +29,4 @@ services: traefik.http.routers.tinyauth.rule: Host(`tinyauth.example.com`) traefik.http.services.tinyauth.loadbalancer.server.port: 3000 traefik.http.middlewares.tinyauth.forwardauth.address: http://tinyauth:3000/api/auth/traefik + traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: Remote-User diff --git a/internal/api/api.go b/internal/api/api.go index ac1214e..04ae52c 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -235,6 +235,8 @@ func (api *API) SetupRoutes() { return } + c.Header("Remote-User", userContext.Username) + // The user is allowed to access the app c.JSON(200, gin.H{ "status": 200, From 33904f7f86aabe3053158b735b27f5afadcb1b48 Mon Sep 17 00:00:00 2001 From: Stavros Date: Tue, 4 Mar 2025 16:00:28 +0200 Subject: [PATCH 2/2] refactor: rename remote user to x tinyauth user --- docker-compose.dev.yml | 2 +- docker-compose.example.yml | 2 +- internal/api/api.go | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index f550606..e17e92b 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -31,4 +31,4 @@ services: traefik.http.routers.tinyauth.rule: Host(`tinyauth.dev.local`) traefik.http.services.tinyauth.loadbalancer.server.port: 3000 traefik.http.middlewares.tinyauth.forwardauth.address: http://tinyauth:3000/api/auth/traefik - traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: Remote-User + traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: X-Tinyauth-User diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 6af3925..03c3a60 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -29,4 +29,4 @@ services: traefik.http.routers.tinyauth.rule: Host(`tinyauth.example.com`) traefik.http.services.tinyauth.loadbalancer.server.port: 3000 traefik.http.middlewares.tinyauth.forwardauth.address: http://tinyauth:3000/api/auth/traefik - traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: Remote-User + traefik.http.middlewares.tinyauth.forwardauth.authResponseHeaders: X-Tinyauth-User diff --git a/internal/api/api.go b/internal/api/api.go index 04ae52c..f17e148 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -235,7 +235,8 @@ func (api *API) SetupRoutes() { return } - c.Header("Remote-User", userContext.Username) + // Set the user header + c.Header("X-Tinyauth-User", userContext.Username) // The user is allowed to access the app c.JSON(200, gin.H{