Spring security 如何生成表oauth\u access\u token表的身份验证blob字段?
我使用的是spring-security-oauth2,所有与oauth相关的信息都存储在数据库中。在表oauth_access_令牌中,使用了字段身份验证 我想知道这个字段中存储了什么。也许有人可以告诉我,我可以在spring-security-oauth2源代码中找到这个字段的生成 我已经弄明白,这个字段取决于用户对象或类,因为每当我在用户类中更改某个内容时,身份验证字段的内容都会更改。 是否可以在身份验证过程中停用此字段的使用,或覆盖生成身份验证字段内容的方法 我想知道这个字段中存储了什么。也许有人可以告诉我,我可以在spring-security-oauth2源代码中找到这个字段的生成 请看org.springframework.security.oauth2.provider.token.store.JdbcTokenStore 它使用org.springframework.security.oauth2.common.util.SerializationUtils序列化身份验证对象 是否可以在身份验证过程中停用此字段的使用,或覆盖生成身份验证字段内容的方法Spring security 如何生成表oauth\u access\u token表的身份验证blob字段?,spring-security,spring-security-oauth2,Spring Security,Spring Security Oauth2,我使用的是spring-security-oauth2,所有与oauth相关的信息都存储在数据库中。在表oauth_access_令牌中,使用了字段身份验证 我想知道这个字段中存储了什么。也许有人可以告诉我,我可以在spring-security-oauth2源代码中找到这个字段的生成 我已经弄明白,这个字段取决于用户对象或类,因为每当我在用户类中更改某个内容时,身份验证字段的内容都会更改。 是否可以在身份验证过程中停用此字段的使用,或覆盖生成身份验证字段内容的方法 我想知道这个字段中存储了什么
Spring将创建身份验证对象,包括使用此字段的用户的权限 谢谢你的帮助。有没有办法改变这种行为,从而只保存用户对象的某些部分?您可以创建自己的JdbcTokenStore或扩展它并重写该方法,只要确保返回正确的身份验证对象,以便检查spring。
public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {
String refreshToken = null;
if (token.getRefreshToken() != null) {
refreshToken = token.getRefreshToken().getValue();
}
if (readAccessToken(token.getValue())!=null) {
removeAccessToken(token.getValue());
}
jdbcTemplate.update(insertAccessTokenSql, new Object[] { extractTokenKey(token.getValue()),
new SqlLobValue(serializeAccessToken(token)), authenticationKeyGenerator.extractKey(authentication),
authentication.isClientOnly() ? null : authentication.getName(),
authentication.getOAuth2Request().getClientId(),
// this one
new SqlLobValue(serializeAuthentication(authentication)), extractTokenKey(refreshToken) }, new int[] {
Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR });
}