O'Reilly logo

Play Framework Cookbook - Second Edition by Giancarlo Inductivo, 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

Implementing token authentication using JWT

In this recipe, we integrate the widely-used user authentication strategy, Token authentication, with authenticate requests to protected Play actions and endpoints. We will use the open source library, nimbus-jose-jwt, by Connect2Id to sign-in and verify JWT for successful user logins.

Subsequent requests to other protected endpoints and actions will now only require the JWT to be added to the request header using the authorization header. Signed JWTs will, however, have a prescribed expiration date and we will ensure that we validate this for each JWT signed request.

Note

More information about Connect2id and nimbus-jose-jwt can be found here:

http://connect2id.com/products/nimbus-jose-jwt

More information ...

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