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
-
The support for
AuthToken
rotation 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
AuthTokenManager
has the following 2 primary responsibilities:The driver does not make judgements on whether the current
AuthToken
should be updated. Instead, it calls theAuthTokenManager
to 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
GraphDatabase
class 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
AuthTokenManager
implementation is available via a newAuthTokenManagers
factory. It managesAuthToken
instances 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
LOGOFF
andLOGON
Bolt 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
AuthToken
instance 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
Driver
interface has 2 newsession
methods that accept anAuthToken
instance.A basic example:
The
Driver
includes 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
Driver
includes a new method that verifies a givenAuthToken
instance by communicating with the server.It requires a minimum Bolt 5.1 version.
Sample usage:
There are 2 new exceptions:
AuthTokenManagerExecutionException
- Indicates that theAuthTokenManager
execution has lead to an unexpected result. This includes invalid results and errors.TokenExpiredRetryableException
- Indicates that the token supplied by theAuthTokenManager
has been deemed as expired by the server. This is a retryable variant of theTokenExpiredException
used when the driver has an explicitAuthTokenManager
that might supply a new token following this failure. If driver is instantiated with the staticAuthToken
, theTokenExpiredException
will be used instead.Beta Was this translation helpful? Give feedback.
All reactions