Packages

  • package root
    Definition Classes
    root
  • package play

    Play framework.

    Play framework.

    Play

    http://www.playframework.com

    Definition Classes
    root
  • package api

    Contains the public API for Scala developers.

    Contains the public API for Scala developers.

    Read configuration
    val poolSize = configuration.getInt("engine.pool.size")
    Use the logger
    Logger.info("Hello!")
    Define a Plugin
    class MyPlugin(app: Application) extends Plugin
    Create adhoc applications (for testing)
    val application = Application(new File("."), this.getClass.getClassloader, None, Play.Mode.DEV)
    Definition Classes
    play
  • package mvc

    Contains the Controller/Action/Result API to handle HTTP requests.

    Contains the Controller/Action/Result API to handle HTTP requests.

    For example, a typical controller:

    class HomeController @Inject() (val controllerComponents: ControllerComponents) extends BaseController {
    
      def index = Action {
        Ok("It works!")
      }
    
    }
    Definition Classes
    api
  • object Security

    Helpers to create secure actions.

    Helpers to create secure actions.

    Definition Classes
    mvc
  • AuthenticatedBuilder
  • AuthenticatedRequest

class AuthenticatedBuilder[U] extends ActionBuilder[[A]AuthenticatedRequest[A, U], AnyContent]

An authenticated action builder.

This can be used to create an action builder, like so:

class UserAuthenticatedBuilder (parser: BodyParser[AnyContent])(implicit ec: ExecutionContext)
  extends AuthenticatedBuilder[User]({ req: RequestHeader =>
  req.session.get("user").map(User)
}, parser) {
  @Inject()
  def this(parser: BodyParsers.Default)(implicit ec: ExecutionContext) = {
    this(parser: BodyParser[AnyContent])
  }
}

You can then use the authenticated builder with other action builders, i.e. to use a messagesApi with authentication, you can add:

 class AuthMessagesRequest[A](val user: User,
                             messagesApi: MessagesApi,
                             request: Request[A])
extends MessagesRequest[A](request, messagesApi)

class AuthenticatedActionBuilder(val parser: BodyParser[AnyContent],
                                 messagesApi: MessagesApi,
                                 builder: AuthenticatedBuilder[User])
                                (implicit val executionContext: ExecutionContext)
    extends ActionBuilder[AuthMessagesRequest, AnyContent] {
  type ResultBlock[A] = (AuthMessagesRequest[A]) => Future[Result]

  @Inject
  def this(parser: BodyParsers.Default,
           messagesApi: MessagesApi,
           builder: UserAuthenticatedBuilder)(implicit ec: ExecutionContext) = {
    this(parser: BodyParser[AnyContent], messagesApi, builder)
  }

  def invokeBlock[A](request: Request[A], block: ResultBlock[A]): Future[Result] = {
    builder.authenticate(request, { authRequest: AuthenticatedRequest[A, User] =>
      block(new AuthMessagesRequest[A](authRequest.user, messagesApi, request))
    })
  }
}
Source
Security.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. AuthenticatedBuilder
  2. ActionBuilder
  3. ActionFunction
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new AuthenticatedBuilder(userinfo: (RequestHeader) => Option[U], defaultParser: BodyParser[AnyContent], onUnauthorized: (RequestHeader) => Result = implicit request => Unauthorized(views.html.defaultpages.unauthorized()))(implicit executionContext: ExecutionContext)

    userinfo

    The function that looks up the user info.

    onUnauthorized

    The function to get the result for when no authenticated user can be found.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def andThen[Q[_]](other: ActionFunction[[A]AuthenticatedRequest[A, U], Q]): ActionBuilder[Q, AnyContent]

    Compose this ActionFunction with another, with this one applied first.

    Compose this ActionFunction with another, with this one applied first.

    other

    ActionFunction with which to compose

    returns

    The new ActionFunction

    Definition Classes
    ActionBuilderActionFunction
  5. final def apply(block: => Result): Action[AnyContent]

    Constructs an Action with default content, and no request parameter.

    Constructs an Action with default content, and no request parameter.

    For example:

    val hello = Action {
      Ok("Hello!")
    }
    block

    the action code

    returns

    an action

    Definition Classes
    ActionBuilder
  6. final def apply(block: (AuthenticatedRequest[AnyContent, U]) => Result): Action[AnyContent]

    Constructs an Action with default content.

    Constructs an Action with default content.

    For example:

    val echo = Action { request =>
      Ok("Got request [" + request + "]")
    }
    block

    the action code

    returns

    an action

    Definition Classes
    ActionBuilder
  7. final def apply[A](bodyParser: BodyParser[A]): ActionBuilder[[A]AuthenticatedRequest[A, U], A]

    Constructs an ActionBuilder with the given BodyParser.

    Constructs an ActionBuilder with the given BodyParser. The result can then be applied directly to a block.

    For example:

    val echo = Action(parse.anyContent) { request =>
      Ok("Got request [" + request + "]")
    }
    A

    the type of the request body

    bodyParser

    the BodyParser to use to parse the request body

    returns

    an action

    Definition Classes
    ActionBuilder
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. final def async[A](bodyParser: BodyParser[A])(block: (AuthenticatedRequest[A, U]) => Future[Result]): Action[A]

    Constructs an Action with the given BodyParser that returns a future of a result.

    Constructs an Action with the given BodyParser that returns a future of a result.

    For example:

    val hello = Action.async(parse.anyContent) { request =>
      ws.url(request.getQueryString("url").get).get().map { r =>
        if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
      }
    }
    block

    the action code

    returns

    an action

    Definition Classes
    ActionBuilder
  10. final def async(block: (AuthenticatedRequest[AnyContent, U]) => Future[Result]): Action[AnyContent]

    Constructs an Action that returns a future of a result, with default content.

    Constructs an Action that returns a future of a result, with default content.

    For example:

    val hello = Action.async { request =>
      ws.url(request.getQueryString("url").get).get().map { r =>
        if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
      }
    }
    block

    the action code

    returns

    an action

    Definition Classes
    ActionBuilder
  11. final def async(block: => Future[Result]): Action[AnyContent]

    Constructs an Action that returns a future of a result, with default content, and no request parameter.

    Constructs an Action that returns a future of a result, with default content, and no request parameter.

    For example:

    val hello = Action.async {
      ws.url("http://www.playframework.com").get().map { r =>
        if (r.status == 200) Ok("The website is up") else NotFound("The website is down")
      }
    }
    block

    the action code

    returns

    an action

    Definition Classes
    ActionBuilder
  12. def authenticate[A](request: Request[A], block: (AuthenticatedRequest[A, U]) => Future[Result]): Future[Result]

    Authenticate the given block.

  13. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  14. def compose[B](other: ActionBuilder[Request, B]): ActionBuilder[[A]AuthenticatedRequest[A, U], B]
    Definition Classes
    ActionFunction
  15. def compose[Q[_]](other: ActionFunction[Q, Request]): ActionFunction[Q, [A]AuthenticatedRequest[A, U]]

    Compose another ActionFunction with this one, with this one applied last.

    Compose another ActionFunction with this one, with this one applied last.

    other

    ActionFunction with which to compose

    returns

    The new ActionFunction

    Definition Classes
    ActionFunction
  16. def composeAction[A](action: Action[A]): Action[A]

    Compose the action with other actions.

    Compose the action with other actions. This allows mixing in of various actions together.

    action

    The action to compose

    returns

    The composed action

    Attributes
    protected
    Definition Classes
    ActionBuilder
  17. def composeParser[A](bodyParser: BodyParser[A]): BodyParser[A]

    Compose the parser.

    Compose the parser. This allows the action builder to potentially intercept requests before they are parsed.

    bodyParser

    The body parser to compose

    returns

    The composed body parser

    Attributes
    protected
    Definition Classes
    ActionBuilder
  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  20. implicit val executionContext: ExecutionContext

    returns

    The execution context to run the request in.

    Definition Classes
    AuthenticatedBuilderActionFunction
  21. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  22. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  23. def invokeBlock[A](request: Request[A], block: (AuthenticatedRequest[A, U]) => Future[Result]): Future[Result]

    Invoke the block.

    Invoke the block. This is the main method that an ActionBuilder has to implement, at this stage it can wrap it in any other actions, modify the request object or potentially use a different class to represent the request.

    request

    The request

    block

    The block of code to invoke

    returns

    A future of the result

    Definition Classes
    AuthenticatedBuilderActionFunction
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  27. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  28. lazy val parser: BodyParser[AnyContent]

    returns

    The BodyParser to be used by this ActionBuilder if no other is specified

    Definition Classes
    AuthenticatedBuilderActionBuilder
  29. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  30. def toString(): String
    Definition Classes
    AnyRef → Any
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from ActionFunction[Request, [A]AuthenticatedRequest[A, U]]

Inherited from AnyRef

Inherited from Any

Ungrouped