I am developing one project and using Silhouette authentication framework. For regular requests from the browser UI I use CookieAuthenticator and for REST API requests I use JWTAuthenticator. Here is a part of Silhouette source code with documentation which makes me feel I do not completely understand how this thing really works:
/**
* The service that handles the JWT authenticator.
*
* If the authenticator DAO is deactivated then a stateless approach will be used. But note
* that you will loose the possibility to invalidate a JWT.
*
* @param settings The authenticator settings.
* @param dao The DAO to store the authenticator. Set it to None to use a stateless approach.
* @param idGenerator The ID generator used to create the authenticator ID.
* @param clock The clock implementation.
* @param executionContext The execution context to handle the asynchronous operations.
*/
class JWTAuthenticatorService(
settings: JWTAuthenticatorSettings,
dao: Option[AuthenticatorDAO[JWTAuthenticator]],
idGenerator: IDGenerator,
clock: Clock)(implicit val executionContext: ExecutionContext)
extends AuthenticatorService[JWTAuthenticator]
with Logger {
Notice this part of the doc
If the authenticator DAO is deactivated then a stateless approach will be used. But note * that you will loose the possibility to invalidate a JWT.
So it works precisely as they say. When I pass None
as a value of the dao
parameter then generated tokens keep valid even if I shut down the app. But without a backing store how these tokens keep valid? When I start the app again and use the same token it authenticates the user. And I don't know how it does this. Could you explain?