Skip to content

How-to: Implement core services with JSON-backed store #1019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jgrandja opened this issue Dec 21, 2022 · 11 comments
Closed

How-to: Implement core services with JSON-backed store #1019

jgrandja opened this issue Dec 21, 2022 · 11 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@jgrandja
Copy link
Collaborator

We should provide a guide that demonstrates how to implement RegisteredClientRepository, OAuth2AuthorizationService and OAuth2AuthorizationConsentService using a JSON-backed store (e.g. Redis).

Related gh-558

@davidSeven
Copy link

Is there an implementation for Redis now

I saw a Redis implementation here before, but now it's gone

@littlefisher666
Copy link

I'm waiting.

@nkolosnjaji
Copy link

I guess this could be used with MongoDb aswell, looking forward!

@wapkch
Copy link

wapkch commented Apr 12, 2023

@vains-Sofia
Copy link

vains-Sofia commented Oct 11, 2023

I implemented a RedisOAuth2AuthorizationService based on redis storage in a jpa-like way
GitHub:https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java
Gitee:https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java

In the future, I will try to use the same method to implement RegisteredClientRepository and OAuth2AuthorizationConsentService.

@jgrandja jgrandja moved this from Planning to Prioritized in Spring Security Team Oct 20, 2023
@loren-coding
Copy link
Contributor

I implemented a based on redis storage in a jpa-like way GitHub:https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java Gitee:https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java`RedisOAuth2AuthorizationService`

In the future, I will try to use the same method to implement and .RegisteredClientRepository``OAuth2AuthorizationConsentService

How-to: Handle the expiration of the Secondary Index

@vains-Sofia
Copy link

I implemented a based on redis storage in a jpa-like way GitHub:https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java Gitee:https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.javaRedisOAuth2AuthorizationService
In the future, I will try to use the same method to implement and . RegisteredClientRepositoryOAuth2AuthorizationConsentService ``

How-to: Handle the expiration of the Secondary Index

There is currently no good solution. One stupid way is to manually set the expiration time of the Secondary Index.

@vains-Sofia
Copy link

I implemented a based on redis storage in a jpa-like way GitHub:https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.java Gitee:https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationService.javaRedisOAuth2AuthorizationService
In the future, I will try to use the same method to implement and . RegisteredClientRepositoryOAuth2AuthorizationConsentService ``

How-to: Handle the expiration of the Secondary Index

Problem solved;
Add annotation on SpringBean: @EnableRedisRepositories(enableKeyspaceEvents = RedisKeyValueAdapter.EnableKeyspaceEvents.ON_STARTUP), as shown below: GiteeGithub

@jgrandja
Copy link
Collaborator Author

jgrandja commented Sep 9, 2024

See gh-1711 as it adds Redis implementations of the core components (RegisteredClientRepository, OAuth2AuthorizationService and OAuth2AuthorizationConsentService) to the demo-authorizationserver sample.

@jgrandja jgrandja added this to the 1.4.0-M2 milestone Sep 17, 2024
@jgrandja jgrandja moved this from In Progress to Done in Spring Security Team Sep 17, 2024
@silverwind85
Copy link

When saving in the RedisOAuth2AuthorizationService class, there is an error "java.lang.reflect.InaccessibleObjectException: Unable to make field protected java.lang.String sun.net.www.protocol.https.Handler.proxy accessible: module java.base does not "opens sun.net.www.protocol.https" to unnamed module @3c72f59f "in the save method. The problem is the pricipal object. I set --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED but it did not help

Image

OAuth2AuthorizationGrantAuthorization authorizationGrantAuthorization = ModelMapper .convertOAuth2AuthorizationGrantAuthorization(authorization); this.authorizationGrantAuthorizationRepository.save(authorizationGrantAuthorization);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
Status: Done
Development

No branches or pull requests

8 participants