neo4j / neo4j-python-driver

Neo4j Bolt driver for Python
https://neo4j.com/docs/api/python-driver/current/
Other
898 stars 186 forks source link

Add the ability to Refresh Auth Token Credentials #891

Closed vkagamlyk closed 1 year ago

vkagamlyk commented 1 year ago

Add the ability to Refresh Auth Token Credentials

Currently when credentials expire, driver will continue trying to connect with the outdated credentials. There is no ability to update or refresh login credentials (See https://github.com/neo4j/neo4j-python-driver/issues/834).

This PR introduces the ability to pass an optional credentials_refresher function to an authToken object which will change credentials as they become obsolete.

There are no breaking changes introduced in this PR.

There is a test which uses a simple credentials_refresher to validate that these modifications do not break serialization.

Intended use

auth_token = basic_auth("some_login", "ignored")
auth_token.add_credentials_refresher(credentials_refresher)
self.driver = GraphDatabase.driver(uri, auth=auth_token, encrypted=True)

I'm a first-time contributor and have just signed the CLA

robsdedude commented 1 year ago

HI and thank you very much for taking the time to work on this PR.

I am really sorry, but I have to close this PR. We've been working on a more general solution for this and other use-cases. There is no estimate yet as to when it will be released but you can see its current state here: https://github.com/neo4j/neo4j-python-driver/pull/890

This is planned across all official drivers. Again, I'm sorry for this. Consider contacting us before starting to work a feature PR to help avoid such unlucky situations.

Also, for future reference, please check the CONTRIBUTING.md as we have a CLA we need our contributors to sign, as well as a pre-commit set-up specific to the Python driver. No need for any actions right now, but for hopefully future PRs.