oAuth:结果大小不正确:预期1,实际2使用jdbctokenstore

时间:2016-04-28 06:40:30

标签: spring oauth

我们在spring oauth面临一个问题重复访问令牌,我们通过扩展DefaultTokenServices来放置同步令牌服务,但它没有解决。 我们使用Oauth版本:oauth2:1.0.0 春季版:3.2.5。

参考图像:数据如何存储在后端。

https://cloud.githubusercontent.com/assets/1098585/14854150/2be8edda-0cac-11e6-8eb6-4383583c8c97.png

1 个答案:

答案 0 :(得分:1)

我们遇到了同样的问题。我通过将表authentication_id中的oauth_access_token设置为primary来解决此问题。

org.springframework.security.oauth2.provider.token.DefaultTokenServices#refreshAccessToken中存在竞争条件,导致表oauth_access_token中的条目具有重复的authentication_id(即使在2.0.5之后)。当两个线程同时访问数据库但两者仍然获得旧刷新令牌(tokenStore.readAuthenticationForRefreshToken(refreshToken))的身份验证时,会发生这种情况。

create table oauth_access_token (
  token_id VARCHAR(256),
  token LONGVARBINARY,
  authentication_id VARCHAR(256) PRIMARY KEY,
  user_name VARCHAR(256),
  client_id VARCHAR(256),
  authentication LONGVARBINARY,
  refresh_token VARCHAR(256)
);
相关问题