我使用的是spring-security-oauth2,所有与oauth相关的信息都存储在数据库中。在表oauth_access_token中,使用字段认证。
我想知道此字段中存储的内容。也许有人可以告诉我,我可以在spring-security-oauth2源代码中找到该字段的生成。
我已经想通了,该字段取决于用户对象(或类),因为每当我改变某事时。在用户类中,认证字段的内容发生变化。 是否有可能以某种方式停用此字段用于身份验证过程或覆盖生成身份验证字段内容的方法?
答案 0 :(得分:0)
我想知道此字段中存储的内容。也许有人可以告诉我,我可以在spring-security-oauth2源代码中找到该字段的生成。
看看org.springframework.security.oauth2.provider.token.store.JdbcTokenStore
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 });
}
它使用org.springframework.security.oauth2.common.util.SerializationUtils
来序列化身份验证对象。
是否有可能以某种方式停用此字段用于身份验证过程或覆盖生成身份验证字段内容的方法?
Spring将使用此字段创建包含用户权限的身份验证对象。