大佬教程收集整理的这篇文章主要介绍了使用 Azure OAuth2 的 Spring Boot - 回复 URL 不匹配错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有尝试使用 Azure OAuth2 保护的 Spring Boot Web 应用程序。此应用程序基于 Azure SDK 示例 azure-spring-boot-sample-active-directory-webapp。
我构建应用程序并将其作为 Web 应用程序部署到 Azure。我的 MS 证书受到质疑,我同意分享我的信息。我收到以下错误:
AADSTS50011: The reply URL specifIEd in the request does not match the reply URLs configured for the application: '**clIEnt ID**'.
我确定问题出在已注册应用程序的重定向 url 上。我注册了示例告诉我注册的网址,但我仍然收到错误消息。我删除了 Azure AD 注册的应用程序并重新开始,行为没有变化。
我在 Edge 和 Chrome 上看到了这个错误。
环境
Active Directory 应用注册
application.yaml
azure:
activedirectory:
authorization-clIEnts:
arm:
on-demand: true
scopes: https://management.core.windows.net/user_iR_556_11845@personation
graph:
scopes:
- https://graph.microsoft.com/User.Read
- https://graph.microsoft.com/Directory.Read.all
office:
scopes:
- https://manage.office.com/ActivityFeed.Read
- https://manage.office.com/ActivityFeed.ReadDlp
- https://manage.office.com/serviceHealth.Read
clIEnt-ID: my-clIEnt-ID
clIEnt-secret: my-clIEnt-secret
tenant-ID: my-tenant-ID
user-group:
allowed-groups: group1,group2
post-logout-redirect-uri: https://myapp.azurewebsites.net/
pom.xml
<?xml version="1.0" enCoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XML@R_616_10906@ma-instance"
xsi:@R_616_10906@maLOCATIOn="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-starter-parent</artifactID>
<version>2.3.8.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupID>mygroup</groupID>
<artifactID>adoauthdemo</artifactID>
<version>0.0.1-SNAPSHOT</version>
<name>adoauthdemo</name>
<description>Demonstration of integraTing a spring boot application with Azure AD OAuth</description>
<propertIEs>
<java.version>11</java.version>
</propertIEs>
<dependencIEs>
<dependency>
<groupID>com.azure.spring</groupID>
<artifactID>azure-spring-boot-starter-active-directory</artifactID>
<version>3.1.0</version>
</dependency>
<dependency>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-starter-oauth2-clIEnt</artifactID>
</dependency>
<dependency>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-starter-thymeleaf</artifactID>
</dependency>
<dependency>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-starter-web</artifactID>
</dependency>
<dependency>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-devtools</artifactID>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-configuration-processor</artifactID>
<optional>true</optional>
</dependency>
<dependency>
<groupID>org.projectlombok</groupID>
<artifactID>lombok</artifactID>
<optional>true</optional>
</dependency>
</dependencIEs>
<build>
<plugins>
<plugin>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-maven-plugin</artifactID>
<configuration>
<excludes>
<exclude>
<groupID>org.springframework.boot</groupID>
<artifactID>spring-boot-configuration-processor</artifactID>
</exclude>
<exclude>
<groupID>org.projectlombok</groupID>
<artifactID>lombok</artifactID>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupID>com.microsoft.azure</groupID>
<artifactID>azure-webapp-maven-plugin</artifactID>
<version>1.12.0</version>
<configuration>
<authType>azure_cli</authType>
<resourceGroup>adoauthdemo-rg</resourceGroup>
<appname>adoauthdemo</appname>
<pricingTIEr>B1</pricingTIEr>
<region>eastus</region>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
<runtime>
<os>linux</os>
<javaVersion>Java 11</javaVersion>
<webContainer>Java SE</webContainer>
</runtime>
</configuration>
</plugin>
</plugins>
</build>
</project>
我必须将以下内容添加到我的 application.yaml 中。
server:
forWARD-headers-strategy: native
说明
我在我的应用程序上打开调试,我终于看到是什么导致了我的问题:
RedirecTing to 'https://login.microsoftonline.com/**tenant id**/oauth2/v2.0/authorize?response_type=code&client_id=**client id**&scope=https://manage.office.com/serviceHealth.Read%20openid%20profile%20offline_access%20https://graph.microsoft.com/User.Read%20https://graph.microsoft.com/Directory.AccessAsUser.All%20https://graph.microsoft.com/Directory.Read.all%20https://manage.office.com/ActivityFeed.ReadDlp%20https://manage.office.com/ActivityFeed.Read&state=rccivv5nfrx270lpF_y4hHGDP-hhfUSSKI0mmokkNNA%3D&redirect_uri=http://myapp.azurewebsites.net/login/oauth2/code/azure&nonce=fVQX_yumChDneZJvE1pLljs81thZtpBk8do5h1XClGs'
重要的部分是 redirect_uri
参数:http://myapp.azurewebsites.net/login/oauth2/code/azure
我的 Spring Boot 应用使用的是 http 而不是 https。
现在我找到了解决这个问题的 article,他们解决了我上面指出的相同问题。
以上是大佬教程为你收集整理的使用 Azure OAuth2 的 Spring Boot - 回复 URL 不匹配错误全部内容,希望文章能够帮你解决使用 Azure OAuth2 的 Spring Boot - 回复 URL 不匹配错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。