oauth2 单点登陆 sso笔记

oauth2 单点登陆 sso笔记:

1、设置security oauth2的 ResourceServer的Filter们的顺序,根据需求,有时候需要,有时不需要
在 oauth server上不需要
security.oauth2.resource.filter-order=3

不同的版本配置不一样,SPRING SECURITY
security oauth2 不要配置此项



2、关闭 spring security
security.basic.enabled=false
spring security  5 已经取消了此项配置



3、hibernate  
spring.jpa.open-in-view=true
解决hibernate 延迟加载,JSON转换报错问题


4、报错问题

一.先创建OAuth2授权服务器、资源服务器  @EnableResourceServer @EnableAuthorizationServer
二.ui服务器做单点登录 @EnableOAuth2Sso

1、访问UI服务器上受保护的资源  http://localhost:2000/user1

2、跳转到Oauth2授权服务器,输入正确的帐号密码,回调

sso登陆完,
回调

报错:
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Apr 21 15:51:22 CST 2018
There was an unexpected error (type=Unauthorized, status=401).
Authentication Failed: Could not obtain access token


在application.properties文件中指定项目根路径后,正常
server.context-path=/ui

分析原因:单点登陆  @EnableOAuth2Sso 注解默认对根路径下的所有链接提供保护。/login也不例外。


单点登陆项目源码 :https://github.com/lp8653/springpackage


猜你喜欢

转载自blog.csdn.net/u013756305/article/details/80031550