Skip to content

Commit 9d98678

Browse files
Add some logging
1 parent 7e0e96b commit 9d98678

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ services:
6060
- "traefik.http.routers.whoami.middlewares=whoami-demo"
6161
# Add a test header to all incoming requests:
6262
# (the presense of this header in whoami response shows if the plugin works:)
63-
- "traefik.http.middlewares.whoami-demo.plugin.${PLUGIN_NAME}.header.name=sss"
63+
- "traefik.http.middlewares.whoami-demo.plugin.${PLUGIN_NAME}.header.name=X-API-KEY"
6464
- "traefik.http.middlewares.whoami-demo.plugin.${PLUGIN_NAME}.header.key=1244"
6565
- "traefik.http.routers.whoami.tls.certresolver=default"

header_auth.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
3737
}
3838

3939
func (a *HeaderAuth) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
40+
fmt.Println("a.header " + a.header["name"])
4041
if req.Header.Get(a.header["name"]) == a.header["key"] {
42+
fmt.Println("SUCCESS")
4143
req.Header.Del(a.header["name"])
4244
a.next.ServeHTTP(rw, req)
4345
}
46+
fmt.Println("FAILED")
4447
http.Error(rw, "Not allowed - verified null", http.StatusUnauthorized)
48+
4549
}

0 commit comments

Comments
 (0)