成都网站排名公司,房子设计图平面图,wordpress怎么手动更新,e龙岩公共服务网最近在写一套OAuth2s授权认证#xff0c;当在oauth2-client调用oauth2-server#xff0c;并且在点击授权以后#xff0c;oauth2-client却显示【authorization_request_not_found】#xff0c;并跳到了登陆页面。
经过调试发现#xff0c;【authorization_request_not_fou…最近在写一套OAuth2s授权认证当在oauth2-client调用oauth2-server并且在点击授权以后oauth2-client却显示【authorization_request_not_found】并跳到了登陆页面。
经过调试发现【authorization_request_not_found】是由OAuth2LoginAuthenticationFilter中报出的具体位置如下
导致这个的原因是因为从request的session中获取authorizationRequest时获取不到值这是因为我们的oauth2-client和oauth2-server的url分别是localhost:9002和localhost:9001下面是stackoverflow给出的这个现象的说明 意思就是当localhost是两个端口调用会覆盖cookie解决办法就是不用localhost改成域名。
tips对浏览器来说cookie是区分域不区分端口的在一个ip地址下多个端口的cookie是共享的 所以【authorization_request_not_found】这个问题解决办法就是
step1到host文件(C:\Windows\System32\drivers\etc)中将oauth2 server的ip通过域名映射一下
step2修改我们oauth2-client中的配置文件将provider下的跟oauth2 server有关的url都是用域名:端口不要再使用localhost:端口如下
server:port: 9002
spring:security:oauth2:client:registration:myclient:clientId: myclientclientSecret: 123456redirectUri: {baseUrl}/login/oauth2/code/{registrationId}authorizationGrantType: authorization_codeprovider:myclient:authorizationUri: http://www.oauth2server.com:9001/oauth/authorizetokenUri: http://www.oauth2server.com:9001/oauth/tokenuserInfoUri: http://www.oauth2server.com:8208/users/userinfouserNameAttribute: name
经过上面修改后就会解决cookie覆盖问题从而解决了【authorization_request_not_found】这个问题。