问题描述
我正在关注 Azure 文档的以下两个教程:https://docs.microsoft.com/en-us/azure/java/spring-framework/deploy-spring-boot-java-app-with-maven-plugin它展示了如何将一个简单的 Spring Boot 应用程序部署到 Azure 和https://docs.microsoft.com/en-us/azure/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory使用 Spring Security OAuth2 客户端设置和使用活动目录作为 OAuth2 服务器.基本上我只是将 OAuth2 依赖项添加到 Maven、WebSecurityConfig 类,如第二个文档中所示,另外还有 azure.activedirectoy 和 spring.security 属性.
I am following the following two tutorials of the Azure documentation: https://docs.microsoft.com/en-us/azure/java/spring-framework/deploy-spring-boot-java-app-with-maven-plugin which shows how to deploy a simple Spring Boot application to Azure and https://docs.microsoft.com/en-us/azure/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-active-directory to set up and use an active directory as OAuth2 server with a Spring Security OAuth2 Client. Basically I just add the OAuth2 dependencies to Maven, a WebSecurityConfig class as shown in the second document and additionally also the azure.activedirectoy and spring.security properties.
当应用程序从我的本地计算机运行时,登录和重定向工作正常.但是当应用程序部署到 Azure 时,我收到一个应用程序错误消息:无效的重定向 URI 参数.我想我已将重定向 uri 正确设置为
When the application is just run from my local computer the login and redirection works fine. But when the application is deployed to Azure, I get an application error saying: Invalid Redirect URI Parameter. I think I have set the redirect-uri correctly as
在应用程序属性中以及在我的 Active Directory 中的应用程序注册中.
in the application properties as well as in the application registration with my Active Directory.
据我所知,授权请求使用了正确的参数:
As far as I can see the authorization request uses the right parameters:
那么,无效的重定向 URI 参数是什么,我该如何更改?
So, what could the Invalid Redirect URI Parameter be, and how can I change this?
推荐答案
我按照这两个教程,在本地环境下运行良好,在 Azure webapp 上,我遇到了重定向 url 不匹配错误.
I followed these two tutorials, it works fine on local environment, on Azure webapp, I encountered redirect url mismatch error.
原因是redirect_uri总是以http开头.在 applications.properties 中添加 server.forward-headers-strategy=native
后,它就可以工作了.(我使用的是spring boot 2.2)
The cause is that the redirect_uri is always started with http. After adding server.forward-headers-strategy=native
in applications.properties, it works. (I am using spring boot 2.2)
这里是 pom.xml 供您参考.
Here is the pom.xml for your reference.
这篇关于使用 Active Directory 的 Azure 上 Spring OAuth2 应用程序的重定向 URL:无效的重定向 URI 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!