Pri*_*a R 5 scala playframework silhouette
以下链接表示您可以将CookieAuthenticator用作无状态或有状态.
http://silhouette.mohiva.com/docs/authenticator
但我看不到任何选项可以在下面的链接做出选择.
http://silhouette.mohiva.com/v3.0/docs/config-authenticators#cookieauthenticator
我已经复制了以下示例的实现.这是无国籍还是有状态的?如果有状态我如何实现无状态身份验证?
一切都是正确的。
查看CookieAuthenticator.scalagithub上的源代码: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]
Run Code Online (Sandbox Code Playgroud)
因此,您只需要CookieAuthenticatorService使用定义的存储库进行创建。
在您的示例中,您可以找到一个字符串
new CookieAuthenticatorService(config, None, fingerprintGenerator, idGenerator, clock)
Run Code Online (Sandbox Code Playgroud)
repository这里的参数所以None是CookieAuthenticator无状态的。
| 归档时间: |
|
| 查看次数: |
504 次 |
| 最近记录: |