這一切都是正確的。
窺視CookieAuthenticator.scala
源在github上:https://github.com/mohiva/play-silhouette/blob/master/silhouette/app/com/mohiva/play/silhouette/impl/authenticators/CookieAuthenticator.scala
/**
* The service that handles the cookie authenticator.
*
* @param settings The cookie settings.
* @param repository The repository to persist the authenticator. Set it to None to use a stateless approach.
* @param fingerprintGenerator The fingerprint generator implementation.
* @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 CookieAuthenticatorService(
settings: CookieAuthenticatorSettings,
repository: Option[AuthenticatorRepository[CookieAuthenticator]],
fingerprintGenerator: FingerprintGenerator,
idGenerator: IDGenerator,
clock: Clock)(implicit val executionContext: ExecutionContext)
extends AuthenticatorService[CookieAuthenticator]
所以,你只需要創建CookieAuthenticatorService
與定義的存儲庫。
在你的榜樣,你可以找到一個字符串
new CookieAuthenticatorService(config, None, fingerprintGenerator, idGenerator, clock)
這裏的repository
參數爲None
這樣CookieAuthenticator
是無狀態的。