Skip to content

Commit cdd4467

Browse files
committed
Added Active Sessions Document
1 parent 887793a commit cdd4467

10 files changed

Lines changed: 140 additions & 3 deletions
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Active Sessions
2+
3+
Active Sessions is a security feature that allows administrators to monitor and manage user login sessions across the application. With this feature, you can see where and when users are logged in, detect suspicious activity, and terminate sessions when needed. Session management works for both host and tenant users.
4+
5+
> Note: Session management is **disabled by default**. It must be enabled from the settings page before it can be used.
6+
7+
## Enabling Session Management
8+
9+
To enable session management, go to **Administration > Settings** and open the **Security** tab. You will find the **Session Management** section at the bottom of this tab.
10+
11+
![Settings Page Security Tab](images/settings-page-security-tab.png)
12+
13+
Set the **Session Management** toggle to **enabled**. Once enabled, the application will start tracking user sessions on every login. The **Active Sessions** menu item will also appear under the **Administration** menu.
14+
15+
When session management is disabled, no sessions are recorded, the Active Sessions menu item is hidden, and the related API endpoints return a disabled message.
16+
17+
## Session Management Settings
18+
19+
The following settings are available under the Session Management section on the settings page. These settings can be configured separately for host and each tenant.
20+
21+
![Active Sessions Settings Inputs](images/active-sessions-settings-inputs.png)
22+
23+
### Session Management Enabled
24+
25+
This is the master switch for the entire feature. When turned off, sessions are not tracked, the Active Sessions page is not accessible, and all session-related API calls are rejected.
26+
27+
### Session Fingerprint Validation
28+
29+
When enabled, the system generates a fingerprint for each session based on the client's IP address and User-Agent string. On subsequent requests, the system compares the current fingerprint with the stored one. If they do not match, the session is considered invalid and the user is logged out.
30+
31+
This provides an additional layer of security by detecting if a session token is used from a different device or network than the one that originally authenticated.
32+
33+
### Fingerprint Validation Policy
34+
35+
This setting controls what data is included when computing the session fingerprint. There are three options:
36+
37+
| Policy | Description |
38+
|---|---|
39+
| **IP and User Agent** | The fingerprint is computed using both the client's IP address and User-Agent header. This is the default and most restrictive option. A session becomes invalid if either the IP or browser changes. |
40+
| **IP Only** | The fingerprint is computed using only the client's IP address. The session remains valid if the user switches browsers on the same network, but becomes invalid if the IP changes. |
41+
| **User Agent Only** | The fingerprint is computed using only the User-Agent header. The session remains valid if the user's IP changes (e.g., switching networks), but becomes invalid if a different browser or device is used. |
42+
43+
> Note: Choose the policy based on your security requirements. **IP and User Agent** provides the strongest protection but may cause issues for users whose IP addresses change frequently (e.g., mobile users). **User Agent Only** is more lenient for users on dynamic networks.
44+
45+
### Session Absolute Timeout (Minutes)
46+
47+
Defines the maximum lifetime of a session in minutes. After this period, the session is automatically invalidated regardless of user activity. The value must be between **10** and **43200** (30 days). Setting this to **0** disables the absolute timeout, meaning sessions remain valid as long as there is activity.
48+
49+
### Session Revocation Enabled
50+
51+
Controls whether users and administrators can manually terminate (revoke) sessions from the Active Sessions page. When disabled, the revoke buttons are hidden and the revoke API endpoints are rejected. Disabling this does not affect automatic session invalidation through fingerprint validation or timeout.
52+
53+
## Active Sessions Page
54+
55+
To view active sessions, go to **Administration > Active Sessions** from the main menu. This page lists all active sessions for the current user.
56+
57+
![Active Sessions Page](images/active-sessions-page.png)
58+
59+
Each session entry displays the following information:
60+
61+
- **IP Address**: The IP address from which the session was initiated.
62+
- **Device Info**: The browser and operating system information parsed from the User-Agent header (e.g., "Chrome on Windows").
63+
- **Sign-in Time**: The date and time when the user logged in.
64+
- **Last Activity Time**: The date and time of the last recorded activity for this session. This is updated approximately every 5 minutes.
65+
- **Current**: A badge indicating that this is the session you are currently using.
66+
67+
### Revoking a Session
68+
69+
If session revocation is enabled, each session row (except the current one) displays a **Revoke** button. Clicking this button immediately terminates that session. The user associated with that session will be logged out on their next request.
70+
71+
### Revoking All Other Sessions
72+
73+
A **Revoke All Other Sessions** button is available at the top of the page. This terminates all active sessions for the current user except the one being used to perform the action. This is useful when you suspect that your account credentials have been compromised.
74+
75+
## Permissions
76+
77+
Active Sessions uses a single permission:
78+
79+
| Permission | Name | Description |
80+
|---|---|---|
81+
| Pages.Administration.ActiveSessions | Active Sessions | Grants access to the Active Sessions page under the Administration menu. This permission is available for both host and tenant users. |
82+
83+
This permission can be assigned to roles through **Administration > Role Management**. By default, the **Admin** role has this permission.
84+
85+
## Session Lifecycle
86+
87+
Understanding how sessions are managed throughout their lifecycle:
88+
89+
### Session Creation
90+
91+
When a user logs in (via JWT token authentication or cookie-based authentication), the system creates a new session record in the database. A unique session token is generated and included as a claim in the user's JWT token or authentication cookie. The session stores the user's IP address, User-Agent, a computed fingerprint, and the sign-in timestamp.
92+
93+
### Session Validation
94+
95+
On every authenticated request, the system validates the session associated with the request:
96+
97+
1. Checks if the session exists and is active.
98+
2. If fingerprint validation is enabled, compares the current request's fingerprint with the stored fingerprint.
99+
3. If an absolute timeout is configured, checks whether the session has exceeded the timeout period.
100+
4. If validation passes, the session's last activity time is updated (throttled to once every 5 minutes to minimize database writes).
101+
102+
If any validation check fails, the session is invalidated and the request is treated as unauthenticated.
103+
104+
### Session Termination
105+
106+
Sessions are terminated in the following cases:
107+
108+
- The user explicitly logs out.
109+
- An administrator revokes the session from the Active Sessions page.
110+
- The user clicks **Revoke All Other Sessions**.
111+
- Fingerprint validation fails on a subsequent request.
112+
- The session exceeds the absolute timeout period.
113+
114+
### Automatic Cleanup
115+
116+
A background worker runs every **24 hours** to clean up old session data:
117+
118+
- Inactive sessions older than **30 days** are permanently deleted from the database.
119+
- Active sessions with no activity for more than **30 days** are automatically invalidated.
120+
121+
This ensures that the session table does not grow indefinitely and stale sessions are properly cleaned up.
122+
123+
## Next
124+
125+
- [Visual Settings](Features-Angular-Visual-Settings)

docs/en/Features-Angular-Entity-History.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Here is a sample screenshot which show the value of **abp.custom.EntityHistory**
5252

5353
## Next
5454

55-
- [Subscription](Features-Angular-Subscription)
55+
- [Active Sessions](Features-Active-Sessions)

docs/en/Features-Mvc-Core-Entity-History.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ Here is a sample screenshot which show the value of **abp.custom.EntityHistory**
5353

5454
## Next
5555

56-
- [Subscription](Features-Mvc-Core-Subscription)
56+
- [Active Sessions](Features-Active-Sessions)

docs/en/Features-React-Entity-History.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Here is a sample screenshot which show the value of **abp.custom.EntityHistory**
5252

5353
## Next
5454

55-
- [Subscription](Features-React-Subscription)
55+
- [Active Sessions](Features-Active-Sessions)
33.4 KB
Loading
30.3 KB
Loading
80.6 KB
Loading

docs/en/nav-aspnet-core-angular.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@
319319
"text": "Entity History",
320320
"path": "Features-Angular-Entity-History.md"
321321
},
322+
{
323+
"text": "Active Sessions",
324+
"path": "Features-Active-Sessions.md"
325+
},
322326
{
323327
"text": "Visual Settings",
324328
"path": "Features-Angular-Visual-Settings.md"

docs/en/nav-aspnet-core-mvc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@
315315
"text": "Entity History",
316316
"path": "Features-Mvc-Core-Entity-History.md"
317317
},
318+
{
319+
"text": "Active Sessions",
320+
"path": "Features-Active-Sessions.md"
321+
},
318322
{
319323
"text": "Visual Settings",
320324
"path": "Features-Mvc-Core-Visual-Settings.md"

docs/en/nav-aspnet-core-react.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@
311311
"text": "Entity History",
312312
"path": "Features-React-Entity-History.md"
313313
},
314+
{
315+
"text": "Active Sessions",
316+
"path": "Features-Active-Sessions.md"
317+
},
314318
{
315319
"text": "Visual Settings",
316320
"path": "Features-React-Visual-Settings.md"

0 commit comments

Comments
 (0)