I just wrote an example app that might be helpful on my Github. The main idea is laid out below:
Normal actions in Play either expect an Action or a SimpleResult
def normal = Action { Ok("") }
Secured, the way you have it implemented, is expecting an Action
def secured = Secured { Action { Ok("") } }
And Action.async expects a Future of a SimpleResult, but still returns an Action
def async = Action.async { Future { Ok("") } }
What you seem to be looking for is a Secured that takes a Future[SimpleResult]. To do that you should try to follow the example laid out in the Play documentation for Action Composition for
trait Security {
class AuthenticatedRequest[A](val username: String, request: Request[A]) extends WrappedRequest[A](request)
object Secured extends ActionBuilder[AuthenticatedRequest] {
def invokeBlock[A](request: Request[A], block: (AuthenticatedRequest[A]) => Future[SimpleResult]) = {
request.session.get("username").map { username =>
block(new AuthenticatedRequest(username, request))
} getOrElse {
Future.successful(Results.Forbidden)
}
}
}
}
Then you should be able to compose something like this:
def securedAsync = Secured.async { Future { Ok("") } }