public interface RotatableTokenStore
extends org.springframework.security.oauth2.provider.token.TokenStore
TokenStore
concept used to support the refresh token rotation concept in
Broadleaf.Modifier and Type | Method and Description |
---|---|
String |
cleanupBatch(String startingId,
int partition)
Given a refresh token primary key from which to start (i.e.
|
List<RefreshToken> |
findByAncestor(String tokenValue)
Find all refresh token instances derived from the original, root refresh token.
|
int |
getPartition()
Randomly retrieve a partition number with the bounds of the partitions currently available to
the system.
|
int |
getPartition(String tokenValue)
Given an encoded refresh token string, find the partition on which that token is stored.
|
List<Integer> |
getPartitions()
List all the partitions known to the system
|
String |
getRootId(String tokenValue)
Given an encoded refresh token string, find the root token
JTI for the inheritance
line. |
void |
isolatedRemoveRefreshTokenById(int partition,
String tokenId)
Remove a specific refresh token using its primary key and partition
|
RefreshToken |
readRefreshTokenEntity(String tokenValue)
Given an encoded refresh token string, return the
RefreshToken instance matching from
the datastore. |
void |
rotate(String tokenValue)
Given an encoded refresh token string, find that refresh token in the datastore and perform
rotation setup on it.
|
default void |
storeRefreshToken(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken,
org.springframework.security.oauth2.provider.OAuth2Authentication authentication) |
void |
storeRefreshToken(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken,
org.springframework.security.oauth2.provider.OAuth2Authentication authentication,
String ancestorRefreshToken)
Store a refresh token in the datastore, and include the
JTI value of the original,
root refresh token in the line. |
findTokensByClientId, findTokensByClientIdAndUserName, getAccessToken, readAccessToken, readAuthentication, readAuthentication, readAuthenticationForRefreshToken, readRefreshToken, removeAccessToken, removeAccessTokenUsingRefreshToken, removeRefreshToken, storeAccessToken
void rotate(@NonNull String tokenValue)
tokenValue
- The refresh token to rotateorg.springframework.security.oauth2.common.exceptions.InvalidTokenException
- Thrown if the rotation fails@NonNull List<RefreshToken> findByAncestor(@NonNull String tokenValue)
tokenValue
- The original, root refresh tokenRefreshTokenRepository.findByAncestor(String)
void isolatedRemoveRefreshTokenById(int partition, @NonNull String tokenId)
partition
- The partition shard in which the refresh token entity existstokenId
- The primary key value of the refresh tokenvoid storeRefreshToken(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken, org.springframework.security.oauth2.provider.OAuth2Authentication authentication, String ancestorRefreshToken)
JTI
value of the original,
root refresh token in the line.refreshToken
- The refresh token to storeauthentication
- The current authentication associated with the tokenancestorRefreshToken
- The original, root refresh token JTIdefault void storeRefreshToken(org.springframework.security.oauth2.common.OAuth2RefreshToken refreshToken, org.springframework.security.oauth2.provider.OAuth2Authentication authentication)
storeRefreshToken
in interface org.springframework.security.oauth2.provider.token.TokenStore
int getPartition()
int getPartition(@NonNull String tokenValue)
tokenValue
- The encoded refresh token string@NonNull List<Integer> getPartitions()
@Nullable RefreshToken readRefreshTokenEntity(@NonNull String tokenValue)
RefreshToken
instance matching from
the datastore.tokenValue
- The encoded refresh token stringRefreshToken
instance matching from the datastore@Nullable String cleanupBatch(@Nullable String startingId, int partition)
RefreshToken.getId()
,
delete all refresh tokens that have expired (either token expiration or rotation expiration)
in a batch. The size of the batch is governed by
TokenProperties.getCleanupBatchSize()
. The intent is to call this method in
succession until the response is null, indicating the whole table has been traversed.startingId
- The refresh token primary key from which to begin expiration detection and
cleanup. This value should be null when run the first time.partition
- The partition on which to perform the check (the startingId
should
be available in this partition)@NonNull String getRootId(@NonNull String tokenValue)
JTI
for the inheritance
line.tokenValue
- The encoded refresh token stringJTI
for the inheritance line. If this token is itself the
root, then the response will be this token's own JTI
.Copyright © 2021. All rights reserved.