spring-authorization-server icon indicating copy to clipboard operation
spring-authorization-server copied to clipboard

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

Open jgrandja opened this issue 1 year ago • 10 comments

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

jgrandja avatar Dec 21 '22 12:12 jgrandja

Is there an implementation for Redis now

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

davidSeven avatar Mar 10 '23 07:03 davidSeven

I'm waiting.

littlefisher666 avatar Mar 29 '23 02:03 littlefisher666

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

nkolosnjaji avatar Apr 04 '23 13:04 nkolosnjaji

I tried implementing a RedisOAuth2AuthorizationService: https://github.com/wapkch/spring-authorization-server-demo/blob/main/src/main/java/sample/redis/RedisOAuth2AuthorizationService.java

wapkch avatar Apr 12 '23 03:04 wapkch

I tried implementing a RedisOAuth2AuthorizationService: https://github.com/wapkch/spring-authorization-server-demo/blob/main/src/main/java/sample/redis/RedisOAuth2AuthorizationService.java

Out of curiosity, is your proposal functional?

Tks

algarves avatar Sep 25 '23 18:09 algarves

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.

vains-Sofia avatar Oct 11 '23 02:10 vains-Sofia

Sorry, didn't have time to implement it until now, have now added Redis based RegisteredClientRepository and OAuth2AuthorizationConsentService implementation using the same way (similar to Jpa)

RedisRegisteredClientRepository: Github: https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/repository/RedisRegisteredClientRepository.java Gitee: https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/repository/RedisRegisteredClientRepository.java

RedisOAuth2AuthorizationConsentService: Github: https://github.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationConsentService.java Gitee: https://gitee.com/vains-Sofia/authorization-example/blob/master/authorization-server/src/main/java/com/example/service/impl/RedisOAuth2AuthorizationConsentService.java

vains-Sofia avatar Oct 24 '23 07:10 vains-Sofia

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 .RegisteredClientRepository``OAuth2AuthorizationConsentService

How-to: Handle the expiration of the Secondary Index

loren-coding avatar Nov 01 '23 08:11 loren-coding

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 avatar Nov 01 '23 09:11 vains-Sofia

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

vains-Sofia avatar Nov 27 '23 09:11 vains-Sofia