私はユーザーにソーシャルプロバイダにログインし、Play-Silhouette-Slickシードの例と同じように認証を設定できるようにするPlayアプリを持っています。次のコードは大丈夫ですが、とにかくそれを含めました。ステートレスシルエットCookieAuthenticatorはクッキーを見つけられない/削除できません
def authenticate(provider: String): Action[AnyContent] = Action.async { implicit request =>
(socialProviderRegistry.get[SocialProvider](provider) match {
case Some(provider: SocialProvider with CommonSocialProfileBuilder) =>
provider.authenticate().flatMap {
case Left(result) => Future.successful(result) // Redirect user to social provider
case Right(authInfo) => for {
profile <- provider.retrieveProfile(authInfo)
user <- userService.save(profile)
authInfo <- authInfoRepository.save(profile.loginInfo, authInfo)
authenticator <- silhouette.env.authenticatorService.create(profile.loginInfo)
cookie <- silhouette.env.authenticatorService.init(authenticator)
result <- silhouette.env.authenticatorService.embed(cookie, Redirect(routes.EateriesController.eaterySelection()))
} yield {
silhouette.env.eventBus.publish(LoginEvent(user, request))
println("Just to verify that everything went well")
result
}
}
case _ => Future.failed(new ProviderException(s"Cannot authenticate with unexpected social provider $provider"))
}).recover {
case e: ProviderException =>
logger.error("Unexpected provider error", e)
Redirect(routes.SignInController.index()).flashing("error" -> Messages("could.not.authenticate"))
}
}
私の問題は、ユーザーがログインした後、自分のアプリケーションのエンドポイントは、ユーザーがログインしていることを検出することができないということです。私はすぐにログイン後のページにリダイレクトするとき、私はオーセンティケータことをFirefoxで確認できますクッキーは設定されていますが、アプリで別のページに移動するとすぐにクッキーは存在しなくなります。
私のアプリは、クッキーが無効であると思っていたり、それを削除していると思っていますが、現在は手がかりがありません。これが起こる可能性がある他の理由がいくつかありますか、問題を絞り込むためにアプリケーションを記録する方法はありますか?
を私は今、このラインを持っています。 : – rusins
クッキーパスはどうですか? – mavarazy
クッキーパスは「/」に設定されています。 – rusins