From 6cf87875ed4c48bc94f596910d7f3c85238e73c5 Mon Sep 17 00:00:00 2001 From: gakuzzzz Date: Thu, 13 Nov 2014 03:41:03 +0900 Subject: [PATCH] release 0.13.0 --- README.ja.md | 20 +++++++++++-------- README.md | 20 +++++++++++-------- project/Build.scala | 2 +- sample/app/controllers/builder/Messages.scala | 4 ++-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/README.ja.md b/README.ja.md index 5409ce7..b9ef12b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -7,8 +7,6 @@ Play2.x module for Authentication and Authorization [![Build Status](https://sec --------------------------------------- このモジュールは __Play2.x__ の __Scala__版を対象としています。 -Java版には [Deadbolt 2](https://github.com/schaloner/deadbolt-2) というモジュールがありますので -こちらも参考にして下さい。 Play2.3.0 で動作確認をしています。 @@ -31,8 +29,8 @@ Play2.3.0 で動作確認をしています。 これでは認証/認可以外にも様々なAction合成を行いたい場合にネストが深くなって非常に記述性が低くなります。 -このモジュールでは `Either[PlainResult, User]` を返すインターフェイスを用意することで、 -柔軟に他の操作を組み合わせて使用することができます。 +このモジュールでは [Stackable-Controller](https://github.com/t2v/stackable-controller)の実装や、 +`ActionRefiner` による実装など、柔軟に他の操作を組み合わせて使用する方法を提供しています。 以前のバージョン @@ -54,15 +52,15 @@ Play2.1以前をお使いの方へ `Build.scala` もしくは `build.sbt` にライブラリ依存性定義を追加します。 - "jp.t2v" %% "play2-auth" % "0.12.0", - "jp.t2v" %% "play2-auth-test" % "0.12.0" % "test" + "jp.t2v" %% "play2-auth" % "0.13.0", + "jp.t2v" %% "play2-auth-test" % "0.13.0" % "test" For example: `Build.scala` ```scala val appDependencies = Seq( - "jp.t2v" %% "play2-auth" % "0.12.0", - "jp.t2v" %% "play2-auth-test" % "0.12.0" % "test" + "jp.t2v" %% "play2-auth" % "0.13.0", + "jp.t2v" %% "play2-auth-test" % "0.13.0" % "test" ) ``` @@ -159,6 +157,12 @@ For example: `Build.scala` */ override lazy val cookieSecureOption: Boolean = play.api.Play.isProd(play.api.Play.current) + /** + * SessionID Cookieの有効期限を、ブラウザが閉じられるまでにするか否かの設定です。 + * デフォルトは false です。 + */ + override lazy val isTransientCookie: Boolean = false + } ``` diff --git a/README.md b/README.md index a1f75ee..c9b642d 100644 --- a/README.md +++ b/README.md @@ -9,12 +9,11 @@ Target This module targets the __Scala__ version of __Play2.x__. -For the Java version of Play2.x, there is an authorization module called [Deadbolt 2](https://github.com/schaloner/deadbolt-2). Motivation --------------------------------------- -### Play2.x's Existing Security trait +### More secure than Play2.x's Security trait The existing `Security` trait in Play2.x API does not define an identifier that identifies a user. @@ -31,8 +30,7 @@ Your application can expire sessions after a set time limit. Since the `Security` trait in Play2.x API returns `Action`, complicated action methods wind up deeply nested. -Play2x-Auth provides an interface that returns an [`Either[PlainResult, User]`](http://www.scala-lang.org/api/current/scala/util/Either.html) -making writing complicated action methods easier. [`Either`](http://www.scala-lang.org/api/current/scala/util/Either.html) is a wrapper similar to `Option` +Play2x-Auth provides a way of composition. Previous Version @@ -61,15 +59,15 @@ Add dependency declarations into your `Build.scala` or `build.sbt` file: * __for Play2.3.x__ - "jp.t2v" %% "play2-auth" % "0.12.0", - "jp.t2v" %% "play2-auth-test" % "0.12.0" % "test" + "jp.t2v" %% "play2-auth" % "0.13.0", + "jp.t2v" %% "play2-auth-test" % "0.13.0" % "test" For example your `Build.scala` might look like this: ```scala val appDependencies = Seq( - "jp.t2v" %% "play2-auth" % "0.12.0", - "jp.t2v" %% "play2-auth-test" % "0.12.0" % "test" + "jp.t2v" %% "play2-auth" % "0.13.0", + "jp.t2v" %% "play2-auth-test" % "0.13.0" % "test" ) ``` @@ -165,6 +163,12 @@ Usage */ override lazy val cookieSecureOption: Boolean = play.api.Play.isProd(play.api.Play.current) + /** + * Whether a login session is closed when the brower is terminated. + * default is false. + */ + override lazy val isTransientCookie: Boolean = false + } ``` diff --git a/project/Build.scala b/project/Build.scala index 2c3d3ec..8ca6843 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -62,7 +62,7 @@ object ApplicationBuild extends Build { .settings( libraryDependencies += "com.typesafe.play" %% "play" % playVersion % "provided", libraryDependencies += play.PlayImport.cache, - libraryDependencies += "jp.t2v" %% "stackable-controller" % "0.4.1-SNAPSHOT", + libraryDependencies += "jp.t2v" %% "stackable-controller" % "0.4.1", name := appName, publishMavenStyle := appPublishMavenStyle, publishArtifact in Test := appPublishArtifactInTest, diff --git a/sample/app/controllers/builder/Messages.scala b/sample/app/controllers/builder/Messages.scala index 32f26bc..8855c8f 100644 --- a/sample/app/controllers/builder/Messages.scala +++ b/sample/app/controllers/builder/Messages.scala @@ -27,14 +27,14 @@ trait Messages extends Controller with AuthActionBuilders with AuthConfigImpl { final def AuthorizationTxAction(authority: Authority): ActionBuilder[AuthTxRequest] = composeAuthorizationAction(TransactionalAction)(authority) class PjaxAuthRequest[A](val template: String => Html => Html, val authRequest: AuthTxRequest[A]) extends WrappedRequest[A](authRequest) - class PjaxRefiner extends ActionTransformer[AuthTxRequest, PjaxAuthRequest] { + object PjaxRefiner extends ActionTransformer[AuthTxRequest, PjaxAuthRequest] { override protected def transform[A](request: AuthTxRequest[A]): Future[PjaxAuthRequest[A]] = { val template: String => Html => Html = if (request.headers.keys("X-Pjax")) html.pjaxTemplate.apply else html.builder.fullTemplate.apply(request.user) Future.successful(new PjaxAuthRequest(template, request)) } } - def MyAction(authority: Authority): ActionBuilder[PjaxAuthRequest] = AuthorizationTxAction(authority).andThen(new PjaxRefiner) + def MyAction(authority: Authority): ActionBuilder[PjaxAuthRequest] = AuthorizationTxAction(authority) andThen PjaxRefiner def main = MyAction(NormalUser) { implicit request => val title = "message main"