我正在尝试连接 Spring Security 以使用基本的 Authentik 设置。 Authentik 通过 Docker Compose 在 Docker 中运行,我的 Spring Boot 服务也是如此。
仅供参考,我已将问题中的应用程序名称替换为 {name} ;它实际上不是我的配置中的{name}。
我已在 application.yaml 文件中尝试了以下 URI 根:
Authentik 正在端口 80/443 上运行。它具有普通的自签名证书。如果我在浏览器中访问以下 URL,我会收到预期的 JSON 响应:
http://localhost/application/o/{name}/.well-known/openid-configuration
我一辈子都无法弄清楚为什么我无法让 Spring Security 在启动时与 Authentik 对话。我已经这样好几天了。
找到解决方案。无需修改 Authentik docker compose 文件。但是,我的应用程序的 docker compose 文件需要修改。我必须将 Authentik 网络添加到我的应用程序容器中,并将其添加到底部:
networks:
authentik_default:
driver: bridge
name: authentik_default
external: true
网络名称是通过在 Authentik 运行时执行
docker network ls
来确定的。这告诉了我 Authentik 网络的名称。然后我修改了我的 application.yaml
,使其查看容器名称而不是 localhost
。我能够通过 docker container ls
获取 Authentik 的“服务器”容器的容器名称。希望这对其他人有帮助!