如何使用Azure AD在应用程序服务上设置Spring Boot应用程序的重定向URI



我按照下面的教程在本地部署了一个使用Azure AD:的Spring Boot web应用程序

https://dev.to/azure/using-spring-security-with-azure-active-directory-mga

这在本地运行良好,我已将该应用程序部署到Azure应用程序服务。为了正确重定向Oauth,我正在App Service上配置重定向URI,Azure GUI需要一个以"https://"开头的Oauth重定向URI,Spring boot需要一个格式为"http://[domain]:[port]/login/oauth2/code/Azure"的重定向URI。

有没有一种方法可以将Spring配置为期望一个以"https://"开头的URI

我尝试更新以下应用程序属性,但没有帮助。有一种变通方法可以将Type=Public client/nature与"http"URI一起使用。有更好的解决方案吗?

spring.security.oauth2.client.registration.azure.redirect-uri-template={baseUrl}/login/oauth2/code/{registrationId}

在应用程序服务中,前端正在卸载SSL。对于Tomcat和WildFly映像,我们添加了一个过滤器,负责对web工作机器上的上下文进行水合。

不幸的是,在客户带来自己的Web服务器(如Spring Boot(的情况下,他们需要添加自定义逻辑,如我们过滤器中的逻辑,以解决此问题。

另一种选择是依靠App Service使用App Service EasyAuth功能进行身份验证:https://learn.microsoft.com/en-us/azure/app-service/overview-authentication-authorization

使用spring的新azure spring boot starter active directory依赖项,您可以添加azure.activedirectory.redirect-uri-template属性。

示例application.yml:

azure:
activedirectory:
tenant-id: <id>
client-id: <id>
client-secret: <secret>
redirect-uri-template: https://app.example.com/login/oauth2/code/

Spring Cloud Azure 4.x版更新

示例application.yml:

spring:
cloud:
azure:
active-directory:
enabled: true
profile:
tenant-id: <tenant_id>
credential:
client-id: <client_id>
client-secret: <secret>
redirect-uri-template: https://app.example.com/login/oauth2/code/

最新更新