如何使用 OAuth2 身份验证设置 traefik
How to set traefik with OAuth2 authentication
我正在使用 traefik 作为反向代理。我想为入口点设置 OAuth2 身份验证。
在文档中,我找到了 Forward Authentication ,我认为它可能对此有用。但是文档太简单了
This configuration will first forward the request to http://authserver.com/auth.
If the response code is 2XX, access is granted and the original request is performed. Otherwise, the response from the authentication server is returned.
我不知道如何在转发中实现身份验证 OAuth2?
我已经尝试 oauth2_proxy 但没有找到解决方案。
在此issue/comment guybrush 提供了一个解决方案。但那实际上是双重反向代理。
我最近为此构建了一个应用程序:https://github.com/thomseddon/traefik-forward-auth
如您所述,它使用转发身份验证,并使用 Google OAuth 对用户进行身份验证。
此处有一个示例 Docker Compose 设置:https://github.com/thomseddon/traefik-forward-auth/blob/master/examples/docker-compose.yml。查看 traefik.toml 文件以了解 Traefik 如何配置为指向应用程序。
如果有帮助请告诉我!
不要试图让 Traefik 支持你的情况,而是让 Traefik 做它最擅长的事情,而不是使用 Keycloak Gatekeeper 进行身份验证(和潜在的授权)。
这会改变您的设置
Client -- Traefik -- Service
到
Client -- Traefik -- Gatekeeper -- Service
这意味着 Traefik 和 Gatekeeper 都充当反向代理。
使用这种方法对复杂的身份验证设置进行建模非常简单。然而,一个潜在的缺点是额外的 RP 层,因此对于高性能设置,这可能不是一个理想的解决方案。
请注意,Gatekeeper 可以与任何 OIDC 兼容的 IdP 一起使用,因此您无需 运行 Keycloak 即可使用它。
我正在使用 traefik 作为反向代理。我想为入口点设置 OAuth2 身份验证。 在文档中,我找到了 Forward Authentication ,我认为它可能对此有用。但是文档太简单了
This configuration will first forward the request to http://authserver.com/auth.
If the response code is 2XX, access is granted and the original request is performed. Otherwise, the response from the authentication server is returned.
我不知道如何在转发中实现身份验证 OAuth2?
我已经尝试 oauth2_proxy 但没有找到解决方案。
在此issue/comment guybrush 提供了一个解决方案。但那实际上是双重反向代理。
我最近为此构建了一个应用程序:https://github.com/thomseddon/traefik-forward-auth
如您所述,它使用转发身份验证,并使用 Google OAuth 对用户进行身份验证。
此处有一个示例 Docker Compose 设置:https://github.com/thomseddon/traefik-forward-auth/blob/master/examples/docker-compose.yml。查看 traefik.toml 文件以了解 Traefik 如何配置为指向应用程序。
如果有帮助请告诉我!
不要试图让 Traefik 支持你的情况,而是让 Traefik 做它最擅长的事情,而不是使用 Keycloak Gatekeeper 进行身份验证(和潜在的授权)。
这会改变您的设置
Client -- Traefik -- Service
到
Client -- Traefik -- Gatekeeper -- Service
这意味着 Traefik 和 Gatekeeper 都充当反向代理。
使用这种方法对复杂的身份验证设置进行建模非常简单。然而,一个潜在的缺点是额外的 RP 层,因此对于高性能设置,这可能不是一个理想的解决方案。
请注意,Gatekeeper 可以与任何 OIDC 兼容的 IdP 一起使用,因此您无需 运行 Keycloak 即可使用它。