You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected Behavior
Support RedisOAuth2AuthorizationService, which is an implementation of OAuth2AuthorizationService using Redis.
Current Behavior
The following implementations of OAuth2AuthorizationService are currently supported: InMemoryOAuth2AuthorizationService, which uses application memory, and JdbcOAuth2AuthorizationService, which uses a relational database.
Context
i want to use an OAuth2AuthorizationService implementation that has persistence rather than application memory. I tried to use the JdbcOAuth2Authorization Service using a relational database, but I was using JPA in the project, so I have defined and used the JpaOAuth2AuthorizationService, an implementation customized by referring to the spring guide document.
However, as the data increased, I thought that there was a limit to efficiently query under various query conditions (state, authorization_code_value, access_token_value, etc...), and it was difficult to apply the index efficiently. Also, a separate scheduling task was required to delete expired data. So, I thought it might be more efficient to use an implementation using redis.
@OverridepublicOAuth2AuthorizationfindByToken(Stringtoken, OAuth2TokenTypetokenType) {
Assert.hasText(token, "token cannot be empty");
Optional<Authorization> result;
if (tokenType == null) {
result = this.authorizationRepository.findByStateOrAuthorizationCodeValueOrAccessTokenValueOrRefreshTokenValueOrOidcIdTokenValueOrUserCodeValueOrDeviceCodeValue(token);
} elseif (OAuth2ParameterNames.STATE.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByState(token);
} elseif (OAuth2ParameterNames.CODE.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByAuthorizationCodeValue(token);
} elseif (OAuth2ParameterNames.ACCESS_TOKEN.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByAccessTokenValue(token);
} elseif (OAuth2ParameterNames.REFRESH_TOKEN.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByRefreshTokenValue(token);
} elseif (OidcParameterNames.ID_TOKEN.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByOidcIdTokenValue(token);
} elseif (OAuth2ParameterNames.USER_CODE.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByUserCodeValue(token);
} elseif (OAuth2ParameterNames.DEVICE_CODE.equals(tokenType.getValue())) {
result = this.authorizationRepository.findByDeviceCodeValue(token);
} else {
result = Optional.empty();
}
returnresult.map(this::toObject).orElse(null);
}
I think that expired tokens can be automatically deleted by applying TTL, and even if the data increases, it can be efficiently searched by storing them in key-value form without having to apply multiple indexes. Of course, I think Redis might not be the best choice if you need to lookup on a variety of conditions rather than just keys, but I think it's relatively efficient compared to implementing it using an RDBMS.
Do you have any plans to support the OAuth2AuthorizationService implementation using redis? If you don't have any plans to support it, I wonder why. Maybe I'm thinking about it all wrong?
The text was updated successfully, but these errors were encountered:
sinbom
changed the title
Support RedisOAuth2AuthorizationService that implementation of OAuth2AuthorizationService
Support RedisOAuth2AuthorizationService, which is an implementation of OAuth2AuthorizationService using Redis
Jun 13, 2024
Expected Behavior
Support RedisOAuth2AuthorizationService, which is an implementation of OAuth2AuthorizationService using Redis.
Current Behavior
The following implementations of OAuth2AuthorizationService are currently supported: InMemoryOAuth2AuthorizationService, which uses application memory, and JdbcOAuth2AuthorizationService, which uses a relational database.
Context
i want to use an OAuth2AuthorizationService implementation that has persistence rather than application memory. I tried to use the JdbcOAuth2Authorization Service using a relational database, but I was using JPA in the project, so I have defined and used the JpaOAuth2AuthorizationService, an implementation customized by referring to the spring guide document.
However, as the data increased, I thought that there was a limit to efficiently query under various query conditions (state, authorization_code_value, access_token_value, etc...), and it was difficult to apply the index efficiently. Also, a separate scheduling task was required to delete expired data. So, I thought it might be more efficient to use an implementation using redis.
Oauth2AuthorizationService.findByToken
JpaOAuth2AuthorizationService.findByToken
I think that expired tokens can be automatically deleted by applying TTL, and even if the data increases, it can be efficiently searched by storing them in key-value form without having to apply multiple indexes. Of course, I think Redis might not be the best choice if you need to lookup on a variety of conditions rather than just keys, but I think it's relatively efficient compared to implementing it using an RDBMS.
Do you have any plans to support the OAuth2AuthorizationService implementation using redis? If you don't have any plans to support it, I wonder why. Maybe I'm thinking about it all wrong?
The text was updated successfully, but these errors were encountered: