Skip to content

Commit

Permalink
change for stable 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
gakuzzzz committed Nov 19, 2012
1 parent 399212e commit d03d9f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 40 deletions.
32 changes: 12 additions & 20 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Play2.0 module for Authentication and Authorization [![Build Status](https://sec
Java版には [Deadbolt 2](https://github.com/schaloner/deadbolt-2) というモジュールがありますので
こちらも参考にして下さい。

Play2.0final、Play2.0.1 および Play2.0.3 で動作確認をしています。
Play2.0.4 で動作確認をしています。

動機
---------------------------------------
Expand Down Expand Up @@ -45,17 +45,17 @@ Play2.0final、Play2.0.1 および Play2.0.3 で動作確認をしています
1. `Build.scala` もしくは `build.sbt` にライブラリ依存性定義を追加します。
1. 安定版

"jp.t2v" % "play20.auth_2.9.1" % "0.3"
"jp.t2v" % "play20.auth_2.9.1" % "0.4"

1. 開発版

"jp.t2v" % "play20.auth_2.9.1" % "0.4-SNAPSHOT"
"jp.t2v" % "play20.auth_2.9.1" % "0.5-SNAPSHOT"

For example: `Build.scala`

```scala
val appDependencies = Seq(
"jp.t2v" % "play20.auth_2.9.1" % "0.3"
"jp.t2v" % "play20.auth_2.9.1" % "0.4"
)

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
Expand Down Expand Up @@ -116,30 +116,22 @@ For example: `Build.scala`
/**
* ログインが成功した際に遷移する先を指定します。
*/
def loginSucceeded[A](request: Request[A]): PlainResult = Redirect(routes.Message.main)
// 0.4-SNAPSHOT では以下のシグネチャになります。
// def loginSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Message.main)
def loginSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Message.main)

/**
* ログアウトが成功した際に遷移する先を指定します。
*/
def logoutSucceeded[A](request: Request[A]): PlainResult = Redirect(routes.Application.login)
// 0.4-SNAPSHOT では以下のシグネチャになります。
// def logoutSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Application.login)
def logoutSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Application.login)

/**
* 認証が失敗した場合に遷移する先を指定します。
*/
def authenticationFailed[A](request: Request[A]): PlainResult = Redirect(routes.Application.login)
// 0.4-SNAPSHOT では以下のシグネチャになります。
// def authenticationFailed(request: RequestHeader): PlainResult = Redirect(routes.Application.login)
def authenticationFailed(request: RequestHeader): PlainResult = Redirect(routes.Application.login)

/**
* 認可(権限チェック)が失敗した場合に遷移する先を指定します。
*/
def authorizationFailed[A](request: Request[A]): PlainResult = Forbidden("no permission")
// 0.4-SNAPSHOT では以下のシグネチャになります。
// def authorizationFailed(request: RequestHeader): PlainResult = Forbidden("no permission")
def authorizationFailed(request: RequestHeader): PlainResult = Forbidden("no permission")

/**
* 権限チェックのアルゴリズムを指定します。
Expand Down Expand Up @@ -291,10 +283,10 @@ trait AuthConfigImpl extends AuthConfig {

// 他の設定省略

def authenticationFailed[A](request: Request[A]): PlainResult =
def authenticationFailed(request: RequestHeader): PlainResult =
Redirect(routes.Application.login).withSession("access_uri" -> request.uri)

def loginSucceeded[A](request: Request[A]): PlainResult = {
def loginSucceeded(request: RequestHeader): PlainResult = {
val uri = request.session.get("access_uri").getOrElse(routes.Message.main.url)
request.session - "access_uri"
Redirect(uri)
Expand Down Expand Up @@ -455,8 +447,8 @@ trait AuthConfigImpl extends AuthConfig {

// 他の設定省略

override def resolver[A](implicit request: Request[A]) =
new CookieRelationResolver[Id, A](request)
override def resolver(implicit request: RequestHeader) =
new CookieRelationResolver[Id](request)

}
```
Expand Down
32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This module targets the __Scala__ version of __Play2.0__.

For the Java version of Play2.0, there is an authorization module called [Deadbolt 2](https://github.com/schaloner/deadbolt-2).

This module has been tested on Play2.0final, Play2.0.1 and Play2.0.3.
This module has been tested on Play2.0.4.

Motivation
---------------------------------------
Expand Down Expand Up @@ -46,17 +46,17 @@ Installation
1. Add a dependency declaration into your `Build.scala` or `build.sbt` file:
1. For the stable release:

"jp.t2v" % "play20.auth_2.9.1" % "0.3"
"jp.t2v" % "play20.auth_2.9.1" % "0.4"

1. Current snapshot version:

"jp.t2v" % "play20.auth_2.9.1" % "0.4-SNAPSHOT"
"jp.t2v" % "play20.auth_2.9.1" % "0.5-SNAPSHOT"

For example your `Build.scala` might look like this:

```scala
val appDependencies = Seq(
"jp.t2v" % "play20.auth_2.9.1" % "0.3"
"jp.t2v" % "play20.auth_2.9.1" % "0.4"
)

val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
Expand Down Expand Up @@ -118,30 +118,22 @@ Usage
/**
* Where to redirect the user after a successful login.
*/
def loginSucceeded[A](request: Request[A]): PlainResult = Redirect(routes.Message.main)
// At 0.4-SNAPSHOT or grator, the signature becomes the following.
// def loginSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Message.main)
def loginSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Message.main)

/**
* Where to redirect the user after logging out
*/
def logoutSucceeded[A](request: Request[A]): PlainResult = Redirect(routes.Application.login)
// At 0.4-SNAPSHOT or grator, the signature becomes the following.
// def logoutSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Application.login)
def logoutSucceeded(request: RequestHeader): PlainResult = Redirect(routes.Application.login)

/**
* If the user is not logged in and tries to access a protected resource then redirct them as follows:
*/
def authenticationFailed[A](request: Request[A]): PlainResult = Redirect(routes.Application.login)
// At 0.4-SNAPSHOT or grator, the signature becomes the following.
// def authenticationFailed(request: RequestHeader): PlainResult = Redirect(routes.Application.login)
def authenticationFailed(request: RequestHeader): PlainResult = Redirect(routes.Application.login)

/**
* If authorization failed (usually incorrect password) redirect the user as follows:
*/
def authorizationFailed[A](request: Request[A]): PlainResult = Forbidden("no permission")
// At 0.4-SNAPSHOT or grator, the signature becomes the following.
// def authorizationFailed(request: RequestHeader): PlainResult = Forbidden("no permission")
def authorizationFailed(request: RequestHeader): PlainResult = Forbidden("no permission")

/**
* A function that determines what `Authority` a user has.
Expand Down Expand Up @@ -292,10 +284,10 @@ trait AuthConfigImpl extends AuthConfig {

// Other settings are omitted.

def authenticationFailed[A](request: Request[A]): PlainResult =
def authenticationFailed(request: RequestHeader): PlainResult =
Redirect(routes.Application.login).withSession("access_uri" -> request.uri)

def loginSucceeded[A](request: Request[A]): PlainResult = {
def loginSucceeded(request: RequestHeader): PlainResult = {
val uri = request.session.get("access_uri").getOrElse(routes.Message.main.url.toString)
request.session - "access_uri"
Redirect(uri)
Expand Down Expand Up @@ -449,8 +441,8 @@ trait AuthConfigImpl extends AuthConfig {

// Other settings omitted.

override def resolver[A](implicit request: Request[A]) =
new CookieRelationResolver[Id, A](request)
override def resolver(implicit request: RequestHeader) =
new CookieRelationResolver[Id](request)

}
```
Expand Down

0 comments on commit d03d9f5

Please sign in to comment.