how apache shiro remember me works

how apache shiro remember me works

Apache Shiro's "Remember Me" feature allows users to remain authenticated on a website even after their session has ended. When a user logs in and checks the "Remember Me" checkbox, a cookie is set in the user's browser with a long-lived token. When the user returns to the website, the token is sent back to the server, and Shiro uses it to look up the user's authentication information and automatically log them in.

Here's a high-level overview of how the Remember Me feature works in Apache Shiro:

  1. The user logs in to the website and checks the "Remember Me" checkbox.

  2. Shiro generates a long-lived token and stores it in a cookie on the user's browser. The token is encrypted and signed to prevent tampering.

  3. When the user's session ends, the user's authentication information is persisted in a secure store (e.g., a database or a file). The token is also stored in the secure store, along with a reference to the user's authentication information.

  4. When the user returns to the website, Shiro looks for the Remember Me cookie and retrieves the token from it.

  5. Shiro uses the token to look up the user's authentication information in the secure store. If the information is found, Shiro automatically logs the user in and creates a new session for them.

  6. If the token is invalid or the user's authentication information is not found in the secure store, Shiro treats the user as an anonymous user and prompts them to log in again.

Created Time:2017-11-01 12:05:08  Author:lautturi