OAuth2实现 单点登录SSO 遇到的问题

Blade 未结 1 3643
星辰
星辰 剑圣 2020-03-12 11:23

一、该问题的重现步骤是什么?

1. 参考:https://www.cnblogs.com/cjsblog/p/10548022.html

2. sso服务端(blade-auth)改动

(1)参考上面文章对blade-auth做了如下改动

image.png

(2)blade-auth 授权服务器配置(BladeAuthorizationServerConfiguration)、资源服务器配置(BladeResourceServerConfiguration)未改动

3.sso客户端改动

(1)blade-system 改动,增加WebSecurityConfig类

image.png

(2)application-dev.yml增加下图配置

image.png

(3)blade-system的pom.xml增加如下依赖

image.png

(4)saber登录显示未获取用户的租户信息

image.png

(5)后端控制台日志




二、你期待的结果是什么?实际看到的又是什么?

期待的结果:登录成功

实际看到:登录失败

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

产品及版本: bladex,saber2.4.0

操作系统:win10


四、请提供详细的错误堆栈信息,这很重要。

(1)blade-auth 错误

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : --> GET http://192.168.23.184:8106/client/tenant-id?tenantId=000000

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : authorization: Basic c2FiZXI6c2FiZXJfc2VjcmV0

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : Accept: */*

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : --> END GET

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : <-- 401 Unauthorized http://localhost/blade-auth/oauth/authorize?client_id=saber&redirect_uri=http://192.168.23.184:8106/login&response_type=code&state=vUT99N (67ms)

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : transfer-encoding: chunked

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : Content-Type: application/json;charset=UTF-8

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : 

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : {"code":401,"data":null,"message":"缺失令牌,鉴权失败"}

[-blade-system-1] o.s.core.cloud.http.OkHttpSlf4jLogger    : <-- END HTTP (62-byte body)

[  XNIO-1 task-3] o.s.s.o.provider.endpoint.TokenEndpoint  : Handling error: InternalAuthenticationServiceException, 未获得用户的租户信息



image.png

(2)blade-gateway  错误

================ Gateway Response Start  ================

<=== 400 POST: /blade-auth/oauth/token?tenantId=000000&username=admin&password=admin&grant_type=captcha&scope=all&type=account

===Headers===  transfer-encoding: [chunked]

===Headers===  Access-Control-Allow-Headers: [X-Requested-With, Tenant-Id, Blade-Auth, Content-Type, Authorization, credential, X-XSRF-TOKEN, token, username, client]

===Headers===  Access-Control-Allow-Methods: [GET,POST,PUT,DELETE,OPTIONS,HEAD]

===Headers===  Access-Control-Allow-Origin: [*]

===Headers===  Access-Control-Expose-Headers: [*]

===Headers===  Access-Control-Max-Age: [18000L]

===Headers===  Access-Control-Allow-Credentials: [true]

===Headers===  Cache-Control: [no-store]

===Headers===  X-XSS-Protection: [1; mode=block]

===Headers===  Pragma: [no-cache]

===Headers===  X-Frame-Options: [DENY]

===Headers===  Date: [Thu, 12 Mar 2020 03:19:30 GMT]

===Headers===  X-Content-Type-Options: [nosniff]

===Headers===  Content-Type: [application/json;charset=UTF-8]

===Headers===  connection: [close]

================  Gateway Response End  =================



1条回答
  • image.png

    System服务启动了吗?在68行代码打个断点看看。

    0 讨论(2)
提交回复