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
Add support for using an AuthTokenManager bean to authenticate with Neo4j #36650
Add support for using an AuthTokenManager bean to authenticate with Neo4j #36650
Conversation
…bean. Neo4j Java driver introduced support for an `AuthTokenManager` that can be used to define expiring tokens to be used as authentication with a database. This commit adds a `ObjectProvider<AuthTokenManager> authTokenManagers` parameter to the corresponding auto configuration class. If the provider resolves to a unique object, that `AuthTokenManager` will have precedence over any static token.
AuthTokenManager
bean.AuthTokenManager
bean
Thanks for the PR, @michael-simons. I was just about to merge it when I realised that we may have a problem with service connections and Connection details are intended to provide everything that's needed to connect to Neo4j. In a situation where there's a user-defined Assuming that it does for a moment, I'm not totally sure how to do it. One approach would be to add a |
Oh yes, I get what you're saying and it makes a lot of sense to me. So an updated version could look like this:
And then I don't know enough about the connection details I realise. Would a user provide a custom bean then? Which wouldn't be a problem for our users I think. |
Neo4j Java driver introduced support for an `AuthTokenManager` that can be used to define expiring tokens for authentication with a database. This commit adds an `ObjectProvider<AuthTokenManager> authTokenManagers` parameter to the corresponding auto configuration class. If the provider resolves to a unique object, that `AuthTokenManager` will have precedence over any static token. See spring-projectsgh-36650
Thanks, Michael. I've pushed a branch that hopefully shows more clearly what I was trying to describe earlier: https://github.com/wilkinsona/spring-boot/tree/gh-36650. If a user wants to use an |
Wow, thanks for your effort, understandable and suits the use case. Only curious about the the reason using |
No good reason at all. Thanks for catching that. It should be |
Neo4j Java driver introduced support for an `AuthTokenManager` that can be used to define expiring tokens for authentication with a database. This commit adds an `ObjectProvider<AuthTokenManager> authTokenManagers` parameter to the corresponding auto configuration class. If the provider resolves to a unique object, that `AuthTokenManager` will have precedence over any static token. See gh-36650
Thanks for the super fast turnaround, I know a bunch of people approaching this addition. 🙇 |
My pleasure. Thanks for the PR! |
AuthTokenManager
bean
Neo4j Java driver introduced support for an
AuthTokenManager
that can be used to define expiring tokens to be used as authentication with a database.This commit adds a
ObjectProvider<AuthTokenManager> authTokenManagers
parameter to the corresponding auto configuration class. If the provider resolves to a unique object, thatAuthTokenManager
will have precedence over any static token.The usecase for Neo4j users is to be able to define expiring tokens and the like. Without this addition, they must configure the driver bean completely on their own. The config customiser will not help them as the token manager is configured in parallel. This leads to a lot of unnecessary duplicated code and some things are not even obvious that they won't work anymore (such as the integration with Spring logging).
The
AuthTokenManager
interface is marked as preview as it will probably receive more methods, it't won't go away however the code does not depend on specifics.I tried adding the tests into unit scope, but the least bloated way is just running them as an integration test. To avoid having to start multiple containers, I used two nested tests in
Neo4jAutoConfigurationIntegrationTests
.