代码拉取完成,页面将自动刷新
同步操作将从 东莞理工学院-黎志雄/基于Spring Security 5的OAuth2通用登录模块 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
spring boot 2.0后,加强了oauth2的支持。研究源码后,主要是增加了http.oauth2Login() ,在5.1.0.RC1版本,还增加了http.oauth2(),处理更加灵活。
当然,oauth2的功能还在不断完善中,特别在RC版本也是有BUG,有兴趣使用的,可以再等等。
本项目是算是在RC1版本中的二次封装,以适应中国国内oauth2提供商的规范(微信、QQ)以及我单位的中央认证的支持。
mvn install
<dependency>
<groupId>cn.edu.dgut.sw.security</groupId>
<artifactId>security-oauth2</artifactId>
<version>1.0.1</version>
</dependency>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
spring:
thymeleaf:
cache: false
security:
oauth2:
client:
registration:
github:
client-id: *****
client-secret: *****
weixin:
client-id: *****
client-secret: ******
dgut:
client-id: *****
client-secret: *****
qq:
client-id: *****
client-secret: *****
sai:
security:
oauth2:
authorizationResponseBasePath: /uaa/login #修改回调地址
@EnableSaiOAuth2Login
public class SaiOAuth2LoginConfiguration extends WebSecurityConfigurerAdapter {
private SaiOAuth2LoginSecurityConfigurer saiOAuth2LoginSecurityConfigurer;
public SaiOAuth2LoginConfiguration(SaiOAuth2LoginSecurityConfigurer saiOAuth2LoginSecurityConfigurer) {
this.saiOAuth2LoginSecurityConfigurer = saiOAuth2LoginSecurityConfigurer;
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.apply(saiOAuth2LoginSecurityConfigurer)
;
// @formatter:on
}
}
QQ:2231068
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。