Java 在spring bot中执行azure AD身份验证时回复URL不匹配

Java 在spring bot中执行azure AD身份验证时回复URL不匹配,java,spring,spring-boot,azure-active-directory,Java,Spring,Spring Boot,Azure Active Directory,我正在尝试在SpringBootWeb应用程序中实现azure ad身份验证。 我已经注册了应用程序,并在下面添加了重定向uri https://xxxxxxxxxxxxx/xxxxxxxxx/login/oauth2/code/azure/ http://localhost:8080/login/oauth2/code/azure/ 在localhost中测试时,一切正常。下面是application.properties的内容 应用程序属性 #disable the white label

我正在尝试在SpringBootWeb应用程序中实现azure ad身份验证。 我已经注册了应用程序,并在下面添加了重定向uri

https://xxxxxxxxxxxxx/xxxxxxxxx/login/oauth2/code/azure/
http://localhost:8080/login/oauth2/code/azure/
在localhost中测试时,一切正常。下面是application.properties的内容

应用程序属性

#disable the white label error page entirely
server.error.whitelabel.enabled=false

spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false

# Specifies your Active Directory ID:
azure.activedirectory.tenant-id=x-xxxxx-xxxxx-xxx-xxxxxxx

# Specifies your App Registration's Application ID:
azure.activedirectory.client-id=xxxxx-xxxx-xxxx-xxxx-xxxxxxx

# Specifies your App Registration's secret key:
azure.activedirectory.client-secret=xxxxxxxxxxxxx
POM.xml

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
   <groupId>com.microsoft.azure</groupId>
   <artifactId>azure-active-directory-spring-boot-starter</artifactId>
   <version>3.0.0</version>
</dependency>
这不太管用。 提前谢谢


Subham

重定向URI是URI,我们希望Azure AD或我们的IDP在成功的身份验证和令牌发布后将响应发回。现在,如果我们的请求中提到的重定向_uri(从应用程序到IDP[本例中为Azure AD]),然后在Azure AD的应用程序注册中配置的重定向_uri不匹配,AAD将抛出URL不匹配错误

为了解决此问题并了解应用程序发送的重定向URI是什么,我在这里提到了详细的步骤:


您还可以查看以下示例以了解更多信息:

请尝试在applications.properties中添加
server.forward headers strategy=native
。有关更多详细信息,请参阅我尝试过的,这也不起作用。请尝试添加这些
security.oauth2.client.pre-builded-redirect-uri=https://yourappurl.net/login security.oauth2.client.registered-redirect-uri=https://yourappurl.net/login security.oauth2.client.use current uri=false server.tomcat.remote ip header=x-forwarded-forserver.tomcat.protocol header=x-forwarded-proto-server.tomcat.use relative redirects=true server.use forward headers=true server.tomcat.internal proxy=.*
感谢您提供这些选项。Tomcat为我工作。。我没有收到回复url错误,但现在我收到的凭据无效。。这可能与配置的负载平衡器有关?我已经提到了应用程序在post中发送的uri。
 azure.activedirectory.redirect-uri-template= https://xxxxxxxxxxxx/xxxxxxx/login/oauth2/code/azure/