O'Reilly logo

Play Framework Cookbook by Alexander Reelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the security module

One of the basic functions of an application is the need for authentication and authorization. If you only have basic needs and checks, you can use the security module that is already bundled with Play. This recipe shows simple use cases for it.

You can find the source code of this example in the chapter3/secure directory.

Getting ready

Create an application and put the security module in the configuration. Though you do need to install the module, you do not need to specify a version because it is built in with the standard Play distribution. The conf/dependencies.yml entry looks like the following:

require:
    - play
    - play -> secure

As usual, nothing is complete without a test, here it goes:

public class SecurityTest extends ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required