# auth-center 统一认证中心
# 主要配置参数
- server.port: 8001,默认端口
- spring.datasource.*: 数据库连接信息
- diboot.iam.platform-tenant-code: 启用多租户时的平台端租户编码(非多租户可忽略)
diboot:
iam:
platform-tenant-code: '00000'
1
2
3
2
3
# 核心代码说明
AuthorizationServerConfig: 认证服务器配置
- 默认通过JDBC管理ClientDetailsService。
@Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.jdbc(dataSource); }
1
2
3
4TokenEnhancer: 对默认token返回字段进行了扩展,扩展增加了用户信息: tenantId、userType、userId等字段。
通过redis存储token:
/** * Redis存储token * @return */ @Bean public RedisTokenStore redisTokenStore(){ return new RedisTokenStore(redisConnectionFactory); }
1
2
3
4
5
6
7
8