Multi-layer routing
Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
8392503df7
commit
d6598f370c
37 changed files with 2834 additions and 37 deletions
51
integration/fixtures/routing/multi_layer_auth.toml
Normal file
51
integration/fixtures/routing/multi_layer_auth.toml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
[global]
|
||||
checkNewVersion = false
|
||||
sendAnonymousUsage = false
|
||||
|
||||
[log]
|
||||
level = "DEBUG"
|
||||
noColor = true
|
||||
|
||||
[entryPoints]
|
||||
[entryPoints.web]
|
||||
address = ":8000"
|
||||
|
||||
[api]
|
||||
insecure = true
|
||||
|
||||
[providers.file]
|
||||
filename = "{{ .SelfFilename }}"
|
||||
|
||||
## Dynamic Configuration ##
|
||||
|
||||
[http.middlewares]
|
||||
[http.middlewares.auth-middleware.forwardAuth]
|
||||
address = "http://127.0.0.1:{{ .AuthPort }}/auth"
|
||||
authResponseHeaders = ["X-User-Role", "X-User-Name"]
|
||||
|
||||
[http.services]
|
||||
[http.services.admin-service.loadBalancer]
|
||||
[[http.services.admin-service.loadBalancer.servers]]
|
||||
url = "http://{{ .AdminIP }}:80"
|
||||
|
||||
[http.services.developer-service.loadBalancer]
|
||||
[[http.services.developer-service.loadBalancer.servers]]
|
||||
url = "http://{{ .DeveloperIP }}:80"
|
||||
|
||||
[http.routers]
|
||||
# Parent router: matches path, applies auth middleware
|
||||
[http.routers.parent-router]
|
||||
rule = "PathPrefix(`/whoami`)"
|
||||
middlewares = ["auth-middleware"]
|
||||
|
||||
# Child router for admin role
|
||||
[http.routers.admin-router]
|
||||
rule = "Header(`X-User-Role`, `admin`)"
|
||||
service = "admin-service"
|
||||
parentRefs = ["parent-router@file"]
|
||||
|
||||
# Child router for developer role
|
||||
[http.routers.developer-router]
|
||||
rule = "Header(`X-User-Role`, `developer`)"
|
||||
service = "developer-service"
|
||||
parentRefs = ["parent-router@file"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue