Yuc*_*uci 7 spring spring-security oauth-2.0
在通过客户端应用程序想要访问的OAuth2保护的远程资源的Spring定义中,我将use-current-uri设置为true,换句话说,当前URI应该用作重定向(如果可用).看起来像:
<oauth:resource id="myResourceId" type="authorization_code"
client-id="${clientId}" client-secret="${clientSecret}"
access-token-uri="${accessTokenUri}"
user-authorization-uri="${userAuthorizationUri}"
use-current-uri="true"
scope="myScope"
pre-established-redirect-uri="${preEstablishedRedirectUri}"/>
Run Code Online (Sandbox Code Playgroud)
现在问题是,Spring Security OAuth2客户端将获取当前内部Tomcat URL而不是公共Web应用程序的URL.该场景是位于Apache服务器后面的Tomcat服务器,它产生两组URL:
由于重定向URL用于授权服务器(例如,Twitter,ORCID)用于发回授权代码,因此应使用公共Web应用程序的URL,而不是内部URL.
顺便说一句,我使用的是spring-security-oauth2的以下版本:
想知道是否有办法告诉Spring使用公共URL.谢谢.
小智 1
在 Tomcat conf/server.xml 的连接器元素中,尝试设置 Tomcat 前面的公共 URL,如下所示:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
proxyName="example.com"
proxyPort="443" (or whatever port you are using, same goes for scheme )
scheme="https" />
Run Code Online (Sandbox Code Playgroud)
这样,tomcat 的内部 getServerName 和 getServerPort 方法将开始提供正确的值,希望这些值能够创建正确的 URL。
您可能还需要配置您的网络服务器,将来自 http://example.com/users/login的请求路由到http://localhost:8080/myapplication/users/login(如果尚未完成)。
| 归档时间: |
|
| 查看次数: |
1417 次 |
| 最近记录: |