【发布时间】:2020-09-01 08:05:25
【问题描述】:
我正在使用 Traefik 的 Foward Auth 中间件来验证我的请求。
身份验证服务器托管在http://localhost/auth
我要认证的请求来自http://rooms.localhost/:roomId
例如,http://rooms.localhost/ed455783-1502-4c9e-a403-28e621d77fb4?token=qwerty 是我的请求 URL。现在 URL 被转发到身份验证服务器进行身份验证。但是在身份验证服务器上,我看不到请求的 URL 或标头,例如 X-Forwarded-URI。
我能看到的标题是
{
host: 'localhost',
'user-agent': 'PostmanRuntime/7.26.3',
accept: '*/*',
'accept-encoding': 'gzip, deflate, br',
x-forwarded-for': '127.0.0.1',
'x-forwarded-host': 'localhost',
'x-forwarded-port': '80',
'x-forwarded-prefix': '/faa054d5-0fe3-435e-83cb-9b817177d495',
'x-forwarded-proto': 'http',
'x-forwarded-server': 'b35a8676b5a8',
'x-real-ip': '127.0.0.1'
}
那么我应该如何获取请求的 URI 以访问 token?
请注意,在 cookie 或标头中传递令牌对我来说不是一个选项,因为还需要对 WebSocket 连接进行身份验证。
以下是我的 traefik 标签
- traefik.http.middlewares.faa054d5-0fe3-435e-83cb-9b817177d495-auth.forwardauth.address: http://localhost/auth
- traefik.http.middlewares.faa054d5-0fe3-435e-83cb-9b817177d495-stripprefix.stripprefix.prefixes: /faa054d5-0fe3-435e-83cb-9b817177d495
- traefik.http.routers.faa054d5-0fe3-435e-83cb-9b817177d495.middlewares: faa054d5-0fe3-435e-83cb-9b817177d495-stripprefix, faa054d5-0fe3-435e-83cb-9b817177d495-auth
- traefik.http.routers.faa054d5-0fe3-435e-83cb-9b817177d495.rule: Host(`rooms.localhost`) && PathPrefix(`/faa054d5-0fe3-435e-83cb-9b817177d495`)
【问题讨论】:
标签: traefik traefik-authentication