【问题标题】:Spring Security with Azure AD doesn't redirect带有 Azure AD 的 Spring Security 不会重定向
【发布时间】:2021-01-23 21:45:02
【问题描述】:

我按照本指南使用 Azure AD 设置安全性 - https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory

登录到 Microsoft 帐户系统后,我会将我重定向到 https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=25802571-a250-4e99-ba72-87c6eee9f1db&scope=openid%20https://graph.microsoft.com/user.read&state=0HA8WfPariUK8QXcwMlOseVIPNVm0f4XSa_T7JZZvyE%3D&redirect_uri=http://localhost:8079/login/oauth2/code/azure&nonce=eREVP5yO5L3WvOXH6HJfb_LAT8Gk7iu6jrdu259RePM 这样的网址,但此网址不会将我重定向到我的服务器

更新 1:我打开调试日志和重定向,我可以在控制台中看到以下日志

2020-10-08 22:39:59.700 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: 7e63aac3-6ace-46e6-ab45-9c86aadfeed6] Access Token was returned
2020-10-08 22:40:01.542 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: 712291cd-969f-4158-b26e-4b00aadfeed6] Access Token was returned
2020-10-08 22:40:02.762 DEBUG 756 --- [onPool-worker-9] c.m.a.m.ConfidentialClientApplication    : [Correlation ID: fafb0b37-254c-4e8d-bf15-ec5faadfeed6] Access Token was returned

【问题讨论】:

    标签: spring azure spring-boot spring-security azure-active-directory


    【解决方案1】:

    我尝试了 spring boot 示例,效果很好。使用测试用户登录后重定向到http://localhost:8080/

    您需要在门户中将重定向 URL 设置为 http://localhost:8080/login/oauth2/code/azure。确保还配置了权限并授予管理员同意。

    如果要更改重定向 URL,需要在 application.properties 中添加 spring.security.oauth2.client.registration.azure.redirect-uri-template 并在门户中设置重定向 URL。

    【讨论】:

      猜你喜欢
      • 2021-07-11
      • 1970-01-01
      • 1970-01-01
      • 2015-09-12
      • 1970-01-01
      • 2016-06-15
      • 2018-01-12
      • 2021-12-30
      • 2013-07-20
      相关资源
      最近更新 更多