mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2025-01-03 17:42:20 +08:00
refactor: Spring Security OAuth2授权模式扩展
This commit is contained in:
parent
b25bb694d7
commit
3b55bac405
@ -104,12 +104,13 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap
|
||||
.accessTokenConverter(jwtAccessTokenConverter())
|
||||
.tokenEnhancer(tokenEnhancerChain)
|
||||
.tokenGranter(compositeTokenGranter)
|
||||
.userDetailsService(sysUserDetailsService)
|
||||
/** refresh token有两种使用方式:重复使用(true)、非重复使用(false),默认为true
|
||||
* 1 重复使用:access token过期刷新时, refresh token过期时间未改变,仍以初次生成的时间为准
|
||||
* 2 非重复使用:access token过期刷新时, refresh token过期时间延续,在refresh token有效期内刷新便永不失效达到无需再次登录的目的
|
||||
*/
|
||||
.reuseRefreshTokens(true);
|
||||
.reuseRefreshTokens(true)
|
||||
.tokenServices(tokenServices(endpoints))
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
@ -11,11 +11,21 @@ import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信授权者
|
||||
*
|
||||
* @author <a href="mailto:xianrui0365@163.com">xianrui</a>
|
||||
* @date 2021/9/25
|
||||
*/
|
||||
public class WechatTokenGranter extends AbstractTokenGranter {
|
||||
|
||||
/**
|
||||
* 声明授权者 CaptchaTokenGranter 支持授权模式 wechat
|
||||
* 根据接口传值 grant_type = wechat 的值匹配到此授权者
|
||||
* 匹配逻辑详见下面的两个方法
|
||||
*
|
||||
* @see org.springframework.security.oauth2.provider.CompositeTokenGranter#grant(String, TokenRequest)
|
||||
* @see org.springframework.security.oauth2.provider.token.AbstractTokenGranter#grant(String, TokenRequest)
|
||||
*/
|
||||
private static final String GRANT_TYPE = "wechat";
|
||||
private final AuthenticationManager authenticationManager;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user