play-silhouette の紹介
#rpscala 2015-04-22 @kawachi
何?
http://silhouette.mohiva.com/v2.0/docs

SecureSocial の fork
主要登場人物
IdentityService
AuthenticatorService EventBus
RequestProvider
認証の環境(設定)
ログイン情報に対応する
Identity の取得
Environment
Authenticator (認証コード)の

生成、取得など
Request から
ログイン情報を取り出す
認証イベントを

pub-sub する bus
Silhouette
認証情報を処理する
Controller
silhouette の良さそうなとこ
• Provider, AuthenticatorService の実装が充実してる
• (SecureSocial と比べれば) 疎結合
• sample code では Google Guice や cake pattern
で DI
• テストカバレッジが高い
Provider
• Credentials provider
• Basic Authentication
• Social providers
• OAuth1: linkedin, twitter, xing
• OAuth2: clef, dropbox, facebook, foursquare,
github, google, instagram, linkedin, vk
• OpenID: steam, yahoo
AuthenticatorService
• CookieAuthenticator
• クッキーに token 保存して、サーバ側に認証情報を保存
• SessionAuthenticator
• クッキーに認証情報を保存
• BearerTokenAuthenticator
• HTTP header で token やりとりしてサーバに認証情報を保存
• JWTAuthenticator
• DummyAuthenticator
play2-auth と比べて
• 対応は?
silhouette と play2-auth の対応
AuthConfigEnvironment
認証システム全体の設定
AuthConfig.UserIdentity
ユーザを表す型
AuthConfig.AuthorityAuthorization
認可の型
silhouette と play2-auth の対応
TokenAccessorAuthenticatorService
認証トークンの処理
AuthenticityToken (String)Authenticator
認証トークン
RequestProvider
IdContainerAuthenticatorDAO
認証トークンの格納
SecureSocial (fork元) と比べて
• Registration や Login を処理するコントローラ、
HTMLテンプレートが含まれていない
• イベント通知に Akka 使ってる
• 疎結合

Silhouette intro