-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support for NoSql datastores (Redis) #558
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
Comments
One option would be to include a |
Agree. I started creating our own MongoOAuth2AuthorizationService and MongoOAuth2AuthorizationConsentService. Serializing / Deserializing to MongoDb is a nightmare. I tried to look at the JDBC version but didn't provide much guidance in terms of an easy way to port. Attaching what I've done so far. The MongoRegisteredClientRepository seems OK but currently chose to use the in-memory implementations of OAuth2AuthorizationService and OAuth2AuthorizationConsentService. If someone can provide some guidance, I'd be more than happy to contribute the MongoDb version of these interfaces. |
I have implemented MongoDb version of this already for my personal project. But that's not very well structured right now. I am happy to discuss, plan and contribute. |
The In particular, notice how the the
Thanks for bringing this up! I agree that having something like this would be incredibly convenient. While there are a number of options for how you might support each datastore, we can potentially make mapping to/from JSON easier. However, I see some challenges with this as well, so we might need to discuss before trying anything in the project. I'm assuming this |
Just looked at the new Jdbc code. This has changed drastically since last time I wrote my MongoDb implementations. Will use these as a base. Can share code when done. |
@sjohnr - I think that the |
Hey @mikesaurus, thanks for the reply. No problem on the wording, I was also just using your example as an example, so I think we're on the same page. 😄 I also agree that focusing on the
|
Hey @sjohnr Long-winded thoughts -> The Not related specifically to NoSql storage, the one potential pain-point that I can see with creating any implementation of I have to qualify all of this by saying that I'm in the middle of a few different things right now, one of which is porting an existing auth server over to spring-auth-server. Most of the thoughts above are based on my initial analysis of the customizations that we need to make in order to complete the port. Currently, I'm focused on building out other areas of customization and I'm making use of the available JDBC implementations for testing. I haven't had a chance to implement and test any kind of Redis version yet. |
Thanks @mikesaurus, very helpful information/feedback to ensure we're working towards something the community can use. You're in a perfect position to give that feedback because you're porting from the old auth server to this one, so that's great! I will not comment too much on the design principles of a Redis implementation here, but having done one or two similar implementations in the past, I'd say just thinking of the state/tokens as a secondary index for the ID ought to simplify things for you. I wouldn't store the JSON multiple times, since we're not going to be optimizing it too much for space as far as I can see from this vantage point. I'll take these thoughts away and get back with a final design for the JSON mapping utility/component. Thanks! |
@sjohnr, I hadn't thought about indexing since I've been so focused on the JSON transformation. Wrapping the JSON payload in an entity with some indexed token value properties might be a simple/clean solution that I can try out when I get to that point. Thanks for the idea and for all of the hard work on the project! |
I've implemented the Mongo variety of the Jdbc implementation as referenced above. Let me know if I should open a PR or if the addition of the spring-data-mongodb dependency warrants a separate module. |
@bjornharvold, that's great! Feel free to create a separate github project for it. We won't be including a mongo (or redis) implementation in the core, though what we're discussing here is adding some support to make it easier to implement and keep in sync with the project's domain model. |
I added the MongoDb implementation here: https://github.com/bjornharvold/spring-authorization-server-mongodb |
This is a draft solution for supporting NoSQL databases. It uses intermediary objects (currently called "Resources", but open to better names) to simplify a transformation to/from JSON. The intermediary objects support full serialization to JSON with the use of the `OAuth2AuthorizationServerJackson2Module`. Supports the following: * Handles iterating/mapping supported token types, removing the need for applications to do this * Converts enumerated types to/from strings with support for "custom" types * Converts authorities to/from strings * Supports custom settings values Issue spring-projectsgh-558
Now that Spring Authorization Server As @sjohnr noted in this comment:
I would recommend using that guide as a starting point. Furthermore, I am very reluctant on providing Json utility classes and/or mappers in the core module as this is not something we want to maintain. Based on your comment, we seem to be on the same page:
However, I would like to find a middle ground here and provide some guidance on how to implement the core services using a JSON-backed store (e.g. Redis). I've opened gh-1019 to address this in a How-to guide that will include sample code that can be used as-is in the consuming application. I hope this is helpful? I'm going to close this in favour of gh-1019. |
See gh-1711 as it adds Redis implementations of the core components ( |
Expected Behavior
Some infrastructures do not include SQL-based data stores and instead make extensive use of NoSql data stores such as Redis, making the introduction of a SQL data store to support OAuth capabilities incredibly burdensome. spring-authorization-server data objects that are persisted as part of the process flow (such as OAuth2Authorization) should be easily (de)serializable using something like a JSON mapper in order to allow for either Spring provided/packaged or app developer created Redis implementations of OAuth2AuthorizationConsentService and OAuth2AuthorizationService.
Current Behavior
Serializing/deserializing spring-auth-server data objects to/from JSON requires custom data mapping that can create a maintenance nightmare in terms spring-auth-server compatibility (especially in the early/pre-v1.x stages of the spring-auth-server project).
Context
We currently use Redis as the backing data store for our customized spring-security-oauth2-based authorization server. We would like to upgrade to a spring-authorization-server-based authorization server without requiring a SQL database and all of the maintenance and operational overhead associated with it, since all of our current infrastructure and operations are geared toward Redis. We can try to work around the (de)serialization issues with custom data mapping, but custom data mapping tightly couples our code to the underlying data object implementations and concerns us in terms of maintenance/compatibility with spring-authorization-server upgrades.
The text was updated successfully, but these errors were encountered: