优化公共starter的bean加载方式,避免依赖的工程因包路径不一致而导致加载不了的情况
This commit is contained in:
-38
@@ -1,38 +0,0 @@
|
||||
package com.central.oauth2.common.config;
|
||||
|
||||
import com.central.oauth2.common.store.*;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* token存储配置
|
||||
*
|
||||
* @author zlt
|
||||
*/
|
||||
@Configuration
|
||||
public class TokenStoreConfig {
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "db")
|
||||
@Import(AuthDbTokenStore.class)
|
||||
public class JdbcTokenConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "redis", matchIfMissing = true)
|
||||
@Import(AuthRedisTokenStore.class)
|
||||
public class RedisTokenConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "authJwt")
|
||||
@Import(AuthJwtTokenStore.class)
|
||||
public class AuthJwtTokenConfig {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "resJwt")
|
||||
@Import(ResJwtTokenStore.class)
|
||||
public class ResJwtTokenConfig {
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,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.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
|
||||
@@ -13,8 +14,8 @@ import javax.sql.DataSource;
|
||||
* @author zlt
|
||||
* @date 2018/7/24 16:23
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "db")
|
||||
public class AuthDbTokenStore {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.central.oauth2.common.store;
|
||||
|
||||
import com.central.common.model.SysUser;
|
||||
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.security.oauth2.common.DefaultOAuth2AccessToken;
|
||||
@@ -23,6 +24,7 @@ import java.util.Map;
|
||||
* @author zlt
|
||||
* @date 2018/7/24 16:21
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "authJwt")
|
||||
public class AuthJwtTokenStore {
|
||||
|
||||
@Bean("keyProp")
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.central.oauth2.common.store;
|
||||
|
||||
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.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
* @author zlt
|
||||
* @date 2018/7/25 9:36
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "redis", matchIfMissing = true)
|
||||
public class AuthRedisTokenStore {
|
||||
@Autowired
|
||||
private RedisConnectionFactory connectionFactory;
|
||||
|
||||
+2
@@ -4,6 +4,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.central.common.constant.SecurityConstants;
|
||||
import com.central.oauth2.common.converter.CustomUserAuthenticationConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -30,6 +31,7 @@ import java.util.stream.Collectors;
|
||||
* @author zlt
|
||||
* @date 2018/8/20 9:25
|
||||
*/
|
||||
@ConditionalOnProperty(prefix = "zlt.oauth2.token.store", name = "type", havingValue = "resJwt")
|
||||
public class ResJwtTokenStore {
|
||||
@Autowired
|
||||
private ResourceServerProperties resource;
|
||||
|
||||
+5
-1
@@ -1,2 +1,6 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.central.oauth2.common.config.SecurityPropertiesConfig
|
||||
com.central.oauth2.common.config.SecurityPropertiesConfig,\
|
||||
com.central.oauth2.common.store.AuthDbTokenStore,\
|
||||
com.central.oauth2.common.store.AuthRedisTokenStore,\
|
||||
com.central.oauth2.common.store.AuthJwtTokenStore,\
|
||||
com.central.oauth2.common.store.ResJwtTokenStore
|
||||
Reference in New Issue
Block a user