generated from hhftechnology/plugindemo
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Not sure if this use-case is supported, but I'm trying to use the middleware in multiple routers, and it seems the whitelistedIPs are not shared across routers. I think I have the behavior narrowed down, but I don't know what the intended operating mode is.
After adding log lines, right before the check on isWhitelisted:
fmt.Printf("[%s] INFO whitelistedIPs %+v\n", i.name, i.whitelistedIPs)
fmt.Printf("[%s] INFO clientIP (%s), isWhitelisted: (%t), expiresAt: (%s).\n", i.name, clientIP, isWhitelisted, ipData.ExpiresAt)And running these requests after approval of knock.localhost has happened:
curl -6 knock.localhost #=> 418 (default of noop@internal)
curl -6 service.localhost #=> 403I can see this in logging:
[my-ipwhitelistshaper@file] INFO whitelistedIPs map[127.0.0.1:{ExpiresAt:2025-10-22 21:48:26.421020933 +0200 CEST ValidationID:8a35d8fa02016749091fbc7411435eda ValidationCode:penguin} ::1:{ExpiresAt:2025-10-22 21:49:40.142884351 +0200 CEST m=+402.508945046 ValidationID:3948f3f1798c7aed9569733a6342a889 ValidationCode:airplane}]
[my-ipwhitelistshaper@file] INFO clientIP (::1), isWhitelisted: (true), expiresAt: (2025-10-22 21:49:40.142884351 +0200 CEST m=+402.508945046)
...
[my-ipwhitelistshaper@file] INFO whitelistedIPs map[]
[my-ipwhitelistshaper@file] INFO clientIP (::1), isWhitelisted: (false), expiresAt: (0001-01-01 00:00:00 +0000 UTC)
Running traefik with this config:
# Static configuration
log:
level: DEBUG
providers:
file:
filename: dynamic.yml
entryPoints:
web:
address: ":80"
asDefault: true
experimental:
localPlugins:
ipwhitelistshaper:
moduleName: github.com/hhftechnology/ipwhitelistshaper# Dynamic configuration
http:
middlewares:
my-ipwhitelistshaper:
plugin:
ipwhitelistshaper:
approvalURL: "https://knock.localhost"
storagePath: "./plugins-storage/ipwhitelistshaper"
routers:
# Main router that applies the whitelist protection
protected-service:
rule: "Host(`service.localhost`)"
service: "noop@internal"
middlewares:
- "my-ipwhitelistshaper"
# Special router to handle the knock-knock endpoint
knock-router:
rule: "Host(`knock.localhost`)"
service: "noop@internal"
middlewares:
- "my-ipwhitelistshaper"Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels