【发布时间】:2021-02-06 04:44:50
【问题描述】:
我有尝试使用 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 中看到此错误。
环境
- Spring Boot 父级:2.3.8.RELEASE
- Azure Starter AD:3.1.0
- 操作系统:Linux
- Java:Java 11
- Web 服务器堆栈:Java SE
Active Directory 应用注册
- 支持的帐户类型:仅限此组织目录中的帐户(单租户)
- 身份验证:Web:重定向网址:https://myapp.azurewebsites.net/login/oauth2/code/azure
- 身份验证:Web:重定向网址:https://myapp.azurewebsites.net/login/oauth2/code/arm
- 创建的秘密
- API 权限:Azure 服务管理:user_impersonation
- API 权限:Microsoft Graph:Directory.AccessAsUser.All(授予默认目录)
- API 权限:Microsoft Graph:User.Read(授予默认目录)
- API 权限:Office 365 管理 API:ActivityFeed.Read(授予默认目录)
- API 权限:Office 365 管理 API:ActivityFeed.ReadDlp(授予默认目录)
- API 权限:Office 365 管理 API:ServiceHealth.Read(授予默认目录)
application.yaml
azure:
activedirectory:
authorization-clients:
arm:
on-demand: true
scopes: https://management.core.windows.net/user_impersonation
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/XMLSchema-instance"
xsi:schemaLocation="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>
【问题讨论】:
标签: azure spring-boot oauth-2.0 azure-active-directory