Java Play! 2 - User management with cookies

后端 未结 2 1239
刺人心
刺人心 2020-12-15 13:40

I am trying to manage my user via cookie. It\'s not that easy because there is absolutely no documentation about this topic.

With the help of the sample \"zentask\"

2条回答
  •  我在风中等你
    2020-12-15 14:27

    As shown in the Zentask sample, your Secured class should extend Security.Authenticator.

    With this, it will allow to put a @Security.Authenticated annotation either on a Controller, or on an Action. This annotation allows to redirect the client to another page if the user is not properly authorized (by overriding the Security.Authenticator.onUnauthorized() method).

    The workflow is the following:

    1. Check authorization:
    2. Add an unique identifier in the client cookies
    3. Check if authenticated
    4. Secure a controller or an action
    5. If not authorized, redirect the client to another page

提交回复
热议问题