search(SearchDto searchDto) {
searchDto.setIsHighlighter(true);
searchDto.setSortCol("createTime");
return queryService.strQuery("sys_user", searchDto, SEARCH_LOGIC_DEL_DTO);
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java b/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
index 716a48a56584339eda3800c79b0efbbdfbd22931..2d29f858189a019bb97781a6b583650836e62521 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/ISysRoleService.java
@@ -9,10 +9,13 @@ import com.central.common.model.SysRole;
import com.central.common.service.ISuperService;
/**
-* @author zlt
+ * @author zlt
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
public interface ISysRoleService extends ISuperService {
- void saveRole(SysRole sysRole);
+ void saveRole(SysRole sysRole) throws Exception;
void deleteRole(Long id);
@@ -28,7 +31,7 @@ public interface ISysRoleService extends ISuperService {
* @param sysRole
* @return Result
*/
- Result saveOrUpdateRole(SysRole sysRole);
+ Result saveOrUpdateRole(SysRole sysRole) throws Exception;
/**
* 查询所有角色
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
index 26adcb5dd8ca69451f7708c96923d7205ea3cbbe..aaf899fdb3c001e6c7f4e2cfecc17d5c9b387067 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/ISysUserService.java
@@ -13,7 +13,10 @@ import com.central.common.model.SysRole;
import com.central.common.model.SysUser;
/**
-* @author zlt
+ * @author zlt
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
public interface ISysUserService extends ISuperService {
/**
@@ -98,7 +101,7 @@ public interface ISysUserService extends ISuperService {
*/
List findAllUsers(Map params);
- Result saveOrUpdateUser(SysUser sysUser);
+ Result saveOrUpdateUser(SysUser sysUser) throws Exception;
/**
* 删除用户
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
index 4d28373dd043ac2c151305b2cb56b5a785ef6d2d..8550e08d5eb774a3ba481b758e4bd14d725059ad 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysRoleServiceImpl.java
@@ -29,7 +29,7 @@ import javax.annotation.Resource;
@Slf4j
@Service
public class SysRoleServiceImpl extends SuperServiceImpl implements ISysRoleService {
- private final static String LOCK_KEY_ROLECODE = CommonConstant.LOCK_KEY_PREFIX+"rolecode:";
+ private final static String LOCK_KEY_ROLECODE = "rolecode:";
@Resource
private SysUserRoleMapper userRoleMapper;
@@ -42,7 +42,7 @@ public class SysRoleServiceImpl extends SuperServiceImpl
@Transactional(rollbackFor = Exception.class)
@Override
- public void saveRole(SysRole sysRole) {
+ public void saveRole(SysRole sysRole) throws Exception {
String roleCode = sysRole.getCode();
super.saveIdempotency(sysRole, lock
, LOCK_KEY_ROLECODE+roleCode, new QueryWrapper().eq("code", roleCode), "角色code已存在");
@@ -67,7 +67,7 @@ public class SysRoleServiceImpl extends SuperServiceImpl
@Override
@Transactional
- public Result saveOrUpdateRole(SysRole sysRole) {
+ public Result saveOrUpdateRole(SysRole sysRole) throws Exception {
if (sysRole.getId() == null) {
this.saveRole(sysRole);
} else {
diff --git a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
index ce66739043877daf11cdf1ab836f84c11d261ee2..a52d173b4c892713b85081dd9804612f9a4f2f63 100644
--- a/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
+++ b/zlt-business/user-center/src/main/java/com/central/user/service/impl/SysUserServiceImpl.java
@@ -37,7 +37,7 @@ import javax.annotation.Resource;
@Slf4j
@Service
public class SysUserServiceImpl extends SuperServiceImpl implements ISysUserService {
- private final static String LOCK_KEY_USERNAME = CommonConstant.LOCK_KEY_PREFIX+"username:";
+ private final static String LOCK_KEY_USERNAME = "username:";
@Autowired
private PasswordEncoder passwordEncoder;
@@ -219,7 +219,7 @@ public class SysUserServiceImpl extends SuperServiceImpl
@Transactional(rollbackFor = Exception.class)
@Override
- public Result saveOrUpdateUser(SysUser sysUser) {
+ public Result saveOrUpdateUser(SysUser sysUser) throws Exception {
if (sysUser.getId() == null) {
if (StringUtils.isBlank(sysUser.getType())) {
sysUser.setType(UserType.BACKEND.name());
diff --git a/zlt-business/user-center/src/main/resources/application.yml b/zlt-business/user-center/src/main/resources/application.yml
index a9c6558619edac640d75be1207b827afb6c96688..f9a8c71b3558af208267e981da6072acfdc6c0fe 100644
--- a/zlt-business/user-center/src/main/resources/application.yml
+++ b/zlt-business/user-center/src/main/resources/application.yml
@@ -34,7 +34,10 @@ zlt:
- sys_role_user
- sys_role_menu
ignoreSqls:
+ # 用户关联角色时,显示所有角色
- com.central.user.mapper.SysRoleMapper.findAll
+ # 用户列表显示用户所关联的所有角色
+ - com.central.user.mapper.SysUserRoleMapper.findRolesByUserIds
#审计日志
# audit-log:
# enabled: true
diff --git a/zlt-commons/pom.xml b/zlt-commons/pom.xml
index 2fbe456af8e5e4876b74c3ea5636199cc3cf091b..7ef16f85585a484e189f270446f7f76293593134 100644
--- a/zlt-commons/pom.xml
+++ b/zlt-commons/pom.xml
@@ -4,7 +4,7 @@
com.zlt
central-platform
- 3.5.0
+ 5.1.0
zlt-commons
通用组件
@@ -16,10 +16,12 @@
zlt-db-spring-boot-starter
zlt-swagger2-spring-boot-starter
zlt-log-spring-boot-starter
- zlt-ribbon-spring-boot-starter
+ zlt-loadbalancer-spring-boot-starter
zlt-auth-client-spring-boot-starter
zlt-sentinel-spring-boot-starter
zlt-common-core
zlt-elasticsearch-spring-boot-starter
+ zlt-oss-spring-boot-starter
+ zlt-zookeeper-spring-boot-starter
\ No newline at end of file
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml b/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
index 710df120efdb2c21eaf9d0fd6d54b79500ff7989..83051b2b7d3d843b971602fcc5b9708eab6460a2 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
com.zlt
zlt-commons
- 3.5.0
+ 5.1.0
4.0.0
jar
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java
similarity index 35%
rename from zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java
rename to zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java
index e85ed2a206b7329d029a35e5dfdb1050604f5f61..17ede13300e3b8f91f9d639d063cc3bea20d4e5e 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/config/SecurityPropertiesConfig.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/AuthClientAutoConfiguration.java
@@ -1,15 +1,21 @@
-package com.central.oauth2.common.config;
+package com.central.oauth2.common;
import com.central.oauth2.common.properties.SecurityProperties;
+import com.central.oauth2.common.properties.TokenStoreProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.ComponentScan;
/**
+ * 鉴权自动配置
+ *
* @author zlt
- * @date 2019/10/7
+ * @version 1.0
+ * @date 2021/7/24
*
- * Blog: https://blog.csdn.net/zlt2000
+ * Blog: https://zlt2000.gitee.io
* Github: https://github.com/zlt2000
*/
-@EnableConfigurationProperties(SecurityProperties.class)
-public class SecurityPropertiesConfig {
+@EnableConfigurationProperties({SecurityProperties.class, TokenStoreProperties.class})
+@ComponentScan
+public class AuthClientAutoConfiguration {
}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java
new file mode 100644
index 0000000000000000000000000000000000000000..23865987397d45d0337ed0bc48f37c2fb8f62fb8
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/constants/IdTokenClaimNames.java
@@ -0,0 +1,89 @@
+package com.central.oauth2.common.constants;
+
+/**
+ * id_token属性名常量
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/4/23
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+public class IdTokenClaimNames {
+ /**
+ * {@code iss} - the Issuer identifier
+ */
+ public final static String ISS = "iss";
+
+ /**
+ * {@code sub} - the Subject identifier
+ */
+ public final static String SUB = "sub";
+
+ /**
+ * {@code aud} - the Audience(s) that the ID Token is intended for
+ */
+ public final static String AUD = "aud";
+
+ /**
+ * {@code exp} - the Expiration time on or after which the ID Token MUST NOT be accepted
+ */
+ public final static String EXP = "exp";
+
+ /**
+ * {@code iat} - the time at which the ID Token was issued
+ */
+ public final static String IAT = "iat";
+
+ /**
+ * {@code auth_time} - the time when the End-User authentication occurred
+ */
+ public final static String AUTH_TIME = "auth_time";
+
+ /**
+ * {@code nonce} - a {@code String} value used to associate a Client session with an ID Token,
+ * and to mitigate replay attacks.
+ */
+ public final static String NONCE = "nonce";
+
+ /**
+ * {@code acr} - the Authentication Context Class Reference
+ */
+ public final static String ACR = "acr";
+
+ /**
+ * {@code amr} - the Authentication Methods References
+ */
+ public final static String AMR = "amr";
+
+ /**
+ * {@code azp} - the Authorized party to which the ID Token was issued
+ */
+ public final static String AZP = "azp";
+
+ /**
+ * {@code at_hash} - the Access Token hash value
+ */
+ public final static String AT_HASH = "at_hash";
+
+ /**
+ * {@code c_hash} - the Authorization Code hash value
+ */
+ public final static String C_HASH = "c_hash";
+
+ /**
+ * {@code name} - 用户姓名
+ */
+ public final static String NAME = "name";
+
+ /**
+ * {@code login_name} - 登录名
+ */
+ public final static String L_NAME = "login_name";
+
+ /**
+ * {@code picture} - 头像照片
+ */
+ public final static String PIC = "picture";
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
index 7bf2431560f4a9c7483321f24feaca3f9ecdf97e..fbc865810213faa8ae2f37295ab10c470d2b9750 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/converter/CustomUserAuthenticationConverter.java
@@ -1,5 +1,6 @@
package com.central.oauth2.common.converter;
+import com.central.common.model.LoginAppUser;
import com.central.common.model.SysUser;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
@@ -68,7 +69,7 @@ public class CustomUserAuthenticationConverter implements UserAuthenticationConv
principal = user;
} else {
Integer id = (Integer)map.get("id");
- SysUser user = new SysUser();
+ LoginAppUser user = new LoginAppUser();
user.setUsername((String)principal);
user.setId(Long.valueOf(id));
principal = user;
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
index bdc0048ca6a07843284482da1df514279ab92829..c3f77106773a9f08ba928a2eec835bbd69f23cb4 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/AuthProperties.java
@@ -28,4 +28,11 @@ public class AuthProperties {
* url权限配置
*/
private UrlPermissionProperties urlPermission = new UrlPermissionProperties();
+
+ /**
+ * 是否开启统一登出
+ * 1. 登出时把同一个用户名下的所有token都注销
+ * 2. 登出信息通知所有单点登录系统
+ */
+ private Boolean unifiedLogout = false;
}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
index 16a5b65373acba6d4d52cfcd43c6e58ecdb6dbee..e0c3c15fe9b45e9d2384b8eba9ede3c78f7f20db 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/PermitProperties.java
@@ -23,6 +23,7 @@ public class PermitProperties {
"/*/v2/api-docs",
"/swagger/api-docs",
"/swagger-ui.html",
+ "/doc.html",
"/swagger-resources/**",
"/webjars/**",
"/druid/**"
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java
new file mode 100644
index 0000000000000000000000000000000000000000..0f2687fbb08933d216745bddbcaf23520482e718
--- /dev/null
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/properties/TokenStoreProperties.java
@@ -0,0 +1,27 @@
+package com.central.oauth2.common.properties;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+
+/**
+ * Token配置
+ *
+ * @author zlt
+ * @version 1.0
+ * @date 2021/5/19
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
+ */
+@Setter
+@Getter
+@ConfigurationProperties(prefix = "zlt.oauth2.token.store")
+@RefreshScope
+public class TokenStoreProperties {
+ /**
+ * token存储类型(redis/db/authJwt/resJwt)
+ */
+ private String type = "redis";
+}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
index 954cf05400790ad34471f00bfd9c517dbb1a4c01..c08a178be284950f10254caa6a2251fc083efaac 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/service/impl/DefaultPermissionServiceImpl.java
@@ -25,6 +25,9 @@ import java.util.stream.Collectors;
*
* @author zlt
* @date 2018/10/28
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
@Slf4j
public abstract class DefaultPermissionServiceImpl {
@@ -32,7 +35,7 @@ public abstract class DefaultPermissionServiceImpl {
@Autowired
private SecurityProperties securityProperties;
- private AntPathMatcher antPathMatcher = new AntPathMatcher();
+ private final AntPathMatcher antPathMatcher = new AntPathMatcher();
/**
* 查询当前用户拥有的资源权限
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
index d084e5494e032dda113b24a7180aade2df7c5587..1d0b1ec9da443322b32001b2ba3b76edfd19fbe2 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthDbTokenStore.java
@@ -3,6 +3,7 @@ package com.central.oauth2.common.store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
@@ -14,6 +15,7 @@ import javax.sql.DataSource;
* @author zlt
* @date 2018/7/24 16:23
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "db")
public class AuthDbTokenStore {
@Autowired
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
index 9b99fb79c800782f811c749b25b9e8da55349c0a..2d26122245c32f0f0d2c1a3b88ee76a4b25736eb 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthJwtTokenStore.java
@@ -5,6 +5,8 @@ import com.central.oauth2.common.converter.CustomUserAuthenticationConverter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.bootstrap.encrypt.KeyProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
@@ -23,16 +25,14 @@ import java.util.Map;
*
* @author zlt
* @date 2018/7/24 16:21
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "authJwt")
public class AuthJwtTokenStore {
-
- @Bean("keyProp")
- public KeyProperties keyProperties() {
- return new KeyProperties();
- }
-
- @Resource(name = "keyProp")
+ @Resource
private KeyProperties keyProperties;
@Bean
@@ -41,6 +41,7 @@ public class AuthJwtTokenStore {
}
@Bean
+ @Order(2)
public JwtAccessTokenConverter jwtAccessTokenConverter() {
final JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
KeyPair keyPair = new KeyStoreKeyFactory
@@ -51,25 +52,4 @@ public class AuthJwtTokenStore {
tokenConverter.setUserTokenConverter(new CustomUserAuthenticationConverter());
return converter;
}
-
- /**
- * jwt 生成token 定制化处理
- * 添加一些额外的用户信息到token里面
- *
- * @return TokenEnhancer
- */
- @Bean
- public TokenEnhancer tokenEnhancer() {
- return (accessToken, authentication) -> {
- final Map additionalInfo = new HashMap<>(1);
- Object principal = authentication.getPrincipal();
- //增加id参数
- if (principal instanceof SysUser) {
- SysUser user = (SysUser)principal;
- additionalInfo.put("id", user.getId());
- }
- ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
- return accessToken;
- };
- }
}
diff --git a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
index a865158949277b5ebb60f81bc9d89dbc94633a95..239dc42060c5e5050d1c7ad23a4f9dd37bf59c27 100644
--- a/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
+++ b/zlt-commons/zlt-auth-client-spring-boot-starter/src/main/java/com/central/oauth2/common/store/AuthRedisTokenStore.java
@@ -4,7 +4,9 @@ import com.central.oauth2.common.properties.SecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.security.oauth2.provider.token.TokenStore;
/**
@@ -13,17 +15,15 @@ import org.springframework.security.oauth2.provider.token.TokenStore;
*
* @author zlt
* @date 2018/7/25 9:36
+ *
+ * Blog: https://zlt2000.gitee.io
+ * Github: https://github.com/zlt2000
*/
+@Configuration
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "redis", matchIfMissing = true)
public class AuthRedisTokenStore {
- @Autowired
- private RedisConnectionFactory connectionFactory;
-
- @Autowired
- private SecurityProperties securityProperties;
-
@Bean
- public TokenStore tokenStore() {
- return new CustomRedisTokenStore(connectionFactory, securityProperties);
+ public TokenStore tokenStore(RedisConnectionFactory connectionFactory, SecurityProperties securityProperties, RedisSerializer