package com.xingfly.xfauth.config;
import com.xingfly.xfauth.service.security.JPAUserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
/**
* Created by SuperS on 2017/9/25.
*
* @author SuperS
*/
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private AuthenticationManager authenticationManager;
@Autowired
private RedisConnectionFactory connectionFactory;
@Autowired
private JPAUserDetailsService jpaUserDetailsService;
@Bean
public RedisTokenStore tokenStore() {
return new RedisTokenStore(connectionFactory);
}
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints
.authenticationManager(authenticationManager)
.userDetailsService(jpaUserDetailsService)//若无,refresh_token会有UserDetailsService is required错误
.tokenStore(tokenStore());
}
@Override
public void configure(AuthorizationServerSecurityConfigurer security) throws Exception {
security
.allowFormAuthenticationForClients()
.tokenKeyAccess("permitAll()")
.checkTokenAccess("isAuthenticated()");
}
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.inMemory()
.withClient("android")
.scopes("xx")
.secret("android")
.authorizedGrantTypes("password", "authorization_code", "refresh_token")
.and()
.withClient("webapp")
.scopes("xx")
.authorizedGrantTypes("implicit")
.and()
.withClient("browser")
.authorizedGrantTypes("refresh_token", "password")
.scopes("ui");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Spring Cloud 基于网关的统一授权认证
共56个文件
java:26个
xml:5个
gitignore:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 43 浏览量
2023-11-12
10:28:43
上传
评论
收藏 223KB ZIP 举报
温馨提示
使用OAuth2实现多个微服务的统一认证授权,通过向OAUTH服务发送某个类型的grant type进行集中认证和授权获得access token,这个access token是受其他微服务信任的。后续访问中可以通过这个access token来进行。
资源推荐
资源详情
资源评论
收起资源包目录
Spring-CloudJiYuZuulDeTongYiShouQuanRenZheng-master.zip (56个子文件)
Spring-CloudJiYuZuulDeTongYiShouQuanRenZheng-master
pom.xml 697B
eureka
mvnw.cmd 5KB
pom.xml 2KB
src
test
java
com
xingfly
eureka
EurekaApplicationTests.java 335B
main
resources
application.properties 188B
java
com
xingfly
eureka
EurekaApplication.java 417B
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
mvnw 6KB
.gitignore 259B
gateway
mvnw.cmd 5KB
pom.xml 2KB
src
main
resources
bootstrap.yml 700B
java
com
xingfly
gateway
GatewayApplication.java 591B
config
SecurityConfig.java 658B
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
mvnw 6KB
.gitignore 254B
xfauth
mvnw.cmd 5KB
pom.xml 3KB
src
test
java
com
xingfly
xfauth
XfauthApplicationTests.java 335B
main
resources
bootstrap.yml 533B
java
com
xingfly
xfauth
repository
RoleRepository.java 338B
AuthorityRepository.java 352B
UserRepository.java 380B
Init.java 2KB
controller
TestController.java 355B
UserController.java 403B
XfAuthApplication.java 517B
service
UserService.java 206B
security
JPAUserDetailsService.java 962B
UserServiceImpl.java 1KB
endpoint
RevokeTokenEndpoint.java 1KB
domain
base
BaseEntity.java 863B
Role.java 796B
Authority.java 507B
User.java 2KB
config
ResourceServerConfig.java 1KB
SecurityConfig.java 2KB
AuthorizationServerConfig.java 3KB
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
mvnw 6KB
.gitignore 254B
account
mvnw.cmd 5KB
pom.xml 3KB
src
main
resources
bootstrap.yml 351B
java
com
xingfly
account
controller
AccountController.java 630B
AccountApplication.java 574B
config
ResourceServerConfig.java 1KB
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
mvnw 6KB
.gitignore 249B
.gitignore 1KB
共 56 条
- 1
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6742
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功