AuthToken rotation and session auth support #1419
Closed
injectives
announced in
Preview features
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The support for
AuthTokenrotation allows replacing the current token with a new token during the driver's lifetime. This might also be referred to as re-auth.The main objective of this feature is to allow token rotation for the same identity. As such, it is not intended for a change of identity.
A new type called
AuthTokenManagerhas the following 2 primary responsibilities:The driver does not make judgements on whether the current
AuthTokenshould be updated. Instead, it calls theAuthTokenManagerto check if the provided token is the same as the currently used token and takes action if not. The driver reserves the right to call the manager as often as it deems necessary. The manager implementations must be thread-safe and non-blocking for caller threads. For instance, IO operations must not be done on the calling thread.The
GraphDatabaseclass has been updated to include a set of new methods that accept theAuthTokenManager.An example of the driver instantiation:
The token rotation benefits from the new Bolt 5.1 version, but works on previous Bolt versions at the expence of replacing existing connections with new connections.
An expiration based
AuthTokenManagerimplementation is available via a newAuthTokenManagersfactory. It managesAuthTokeninstances that come with a UTC expiration timestamp and calls a new token supplier, which is provided by the user, when a new token is required.An example of the expiration based manager instantiation:
The new
LOGOFFandLOGONBolt protocol messages allow for auth management on active Bolt connections and are used by the features in this update.In addition to the token rotation support, this update also includes support for setting a static
AuthTokeninstance on the driver session level.Unlike the rotation feature, this feature may be used for an identity change. As such, it might be referred to as user switching.
It requires a minimum Bolt 5.1 version.
The
Driverinterface has 2 newsessionmethods that accept anAuthTokeninstance.A basic example:
The
Driverincludes a new method that checks whether the session auth is supported.The implementation assumes all servers to be at the same version.
Sample usage:
The
Driverincludes a new method that verifies a givenAuthTokeninstance by communicating with the server.It requires a minimum Bolt 5.1 version.
Sample usage:
There are 2 new exceptions:
AuthTokenManagerExecutionException- Indicates that theAuthTokenManagerexecution has lead to an unexpected result. This includes invalid results and errors.TokenExpiredRetryableException- Indicates that the token supplied by theAuthTokenManagerhas been deemed as expired by the server. This is a retryable variant of theTokenExpiredExceptionused when the driver has an explicitAuthTokenManagerthat might supply a new token following this failure. If driver is instantiated with the staticAuthToken, theTokenExpiredExceptionwill be used instead.Beta Was this translation helpful? Give feedback.
All reactions