2016-03-14 17 views
5

Aşağıdaki bağlantı CookieAuthenticator'ı durum bilgisi olmayan veya durum bilgisi olan kullanabileceğinizi belirtir.Play Silhouette'i kullanarak durum bilgisi olmayan çerez kimlik doğrulaması nasıl yapılır?

http://silhouette.mohiva.com/docs/authenticator

Ama aşağıdaki bağlantıdan seçim yapmak için herhangi bir seçenek göremiyorum.

http://silhouette.mohiva.com/v3.0/docs/config-authenticators#cookieauthenticator

aşağıda örnek olarak uygulanmasını kopyaladığınız. Bu durum vatansız mı, devleti mi? Durum bilgisi yoksa durum bilgisi olmayan kimlik doğrulamasını nasıl yapabilirim?

https://github.com/mohiva/play-silhouette-seed

cevap

4

Hepsi doğru.

github CookieAuthenticator.scala kaynağına bak:

/** 
* 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] 

https://github.com/mohiva/play-silhouette/blob/master/silhouette/app/com/mohiva/play/silhouette/impl/authenticators/CookieAuthenticator.scala Yani sadece tanımlı depo ile CookieAuthenticatorService oluşturmanız gerekir.

sizin örnekte

, bir dize repository parametre burada çok CookieAuthenticator vatansız ise None olduğunu

new CookieAuthenticatorService(config, None, fingerprintGenerator, idGenerator, clock) 

bulabilirsiniz.

İlgili konular