Skip to content

Commit

Permalink
release 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gakuzzzz committed Nov 12, 2014
1 parent ee6dcf0 commit 6cf8787
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
20 changes: 12 additions & 8 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 で動作確認をしています。

Expand All @@ -31,8 +29,8 @@ Play2.3.0 で動作確認をしています。

これでは認証/認可以外にも様々なAction合成を行いたい場合にネストが深くなって非常に記述性が低くなります。

このモジュールでは `Either[PlainResult, User]` を返すインターフェイスを用意することで
柔軟に他の操作を組み合わせて使用することができます
このモジュールでは [Stackable-Controller](https://github.com/t2v/stackable-controller)の実装や
`ActionRefiner` による実装など、柔軟に他の操作を組み合わせて使用する方法を提供しています


以前のバージョン
Expand All @@ -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"
)
```

Expand Down Expand Up @@ -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

}
```

Expand Down
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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"
)
```

Expand Down Expand Up @@ -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

}
```

Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions sample/app/controllers/builder/Messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6cf8787

Please sign in to comment.