【问题标题】:Perform action when access token is generated生成访问令牌时执行操作
【发布时间】:2016-10-06 21:57:44
【问题描述】:
上下文
当前AuthorizationServerConfigurerAdapter 配置如下:
- “隐式”OAuth2 授权类型
- 使用自定义过滤器进行的身份验证过程
- 授权端点生成 JWT 访问令牌。
在手动(或通过集成测试)对其进行测试时,我们收到了基于提供的范围的确认提示以及使用我们生成的 access_token 进行的重定向,因此效果很好。
问题
我试图弄清楚如何为这个新令牌的生成阶段附加侦听器或其他任何东西。
需要用这个访问令牌做一些事情,比如存储它,用一些authentication细节绑定它..
【问题讨论】:
标签:
spring-security
spring-boot
spring-security-oauth2
【解决方案1】:
嗯,当时我找到了一种在 TokenStore 中附加的方法(JwtTokenStore 实现)。
@Bean
public TokenStore tokenStore() {
JwtTokenStore store = new JwtTokenStore(accessTokenConverter()) {
@Override
public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
// HERE
}
};
return store;
}