You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add session management and authentication enhancements to CMS documentation
* Move endpoints to U&P feature docs and rework related sections
* Clean up configurations- and environment variables-related content
* Fix typo in link
* Clean up examples because they were mixing legacy and session management
* Update LLMs-full.txt
* Update docusaurus/docs/cms/configurations/admin-panel.md
Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com>
* Remove useless/wrong values from env docs
* Update docusaurus/docs/cms/features/users-permissions.md
---------
Co-authored-by: Pierre Wizla <pwizla+github@gmail.com>
Co-authored-by: Pierre Wizla <pwizla@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docusaurus/docs/cms/api/rest.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ tags:
16
16
17
17
The REST API allows accessing the [content-types](/cms/backend-customization/models) through API endpoints. Strapi automatically creates [API endpoints](#endpoints) when a content-type is created. [API parameters](/cms/api/rest/parameters) can be used when querying API endpoints to refine the results.
18
18
19
-
This section of the documentation is for the REST API reference. We also have [guides](/cms/api/rest/guides/intro) available for specific use cases.
19
+
This section of the documentation is for the REST API reference for content-types. We also have [guides](/cms/api/rest/guides/intro) available for specific use cases.
20
20
21
21
:::prerequisites
22
22
All content types are private by default and need to be either made public or queries need to be authenticated with the proper permissions. See the [Quick Start Guide](/cms/quick-start#step-4-set-roles--permissions), the user guide for the [Users & Permissions feature](/cms/features/users-permissions#roles), and [API tokens configuration documentation](/cms/features/api-tokens) for more details.
Copy file name to clipboardExpand all lines: docusaurus/docs/cms/backend-customization/examples/authentication.md
+114Lines changed: 114 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -145,6 +145,120 @@ const Login = () => {
145
145
exportdefaultLogin;
146
146
```
147
147
148
+
## Enhanced Authentication with Session Management
149
+
150
+
The above example uses the traditional JWT approach. For enhanced security, you can enable session management mode in your Users & Permissions configuration, which provides shorter-lived access tokens and refresh token functionality.
151
+
152
+
### Configuration
153
+
154
+
First, enable session management in your `/config/plugins.js`:
155
+
156
+
```js title="/config/plugins.js"
157
+
module.exports= ({ env }) => ({
158
+
'users-permissions': {
159
+
config: {
160
+
jwtManagement:'refresh',
161
+
sessions: {
162
+
accessTokenLifespan:604800, // 1 week (default)
163
+
maxRefreshTokenLifespan:2592000, // 30 days
164
+
idleRefreshTokenLifespan:604800, // 7 days
165
+
},
166
+
},
167
+
},
168
+
});
169
+
```
170
+
171
+
### Enhanced Login Component
172
+
173
+
Here's an updated login component that handles both JWT and refresh tokens:
Copy file name to clipboardExpand all lines: docusaurus/docs/cms/configurations/admin-panel.md
+68-3Lines changed: 68 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
title: Admin panel configuration
3
3
sidebar_label: Admin panel
4
4
displayed_sidebar: cmsSidebar
5
-
toc_max_heading_level: 2
5
+
toc_max_heading_level: 3
6
6
description: Strapi's admin panel offers a single entry point file for its configuration.
7
7
tags:
8
8
- admin panel
@@ -57,7 +57,7 @@ export default {
57
57
58
58
:::
59
59
60
-
## Admin panel server
60
+
## Admin panel server
61
61
62
62
By default, Strapi's admin panel is exposed via `http://localhost:1337/admin`. For security reasons, the host, port, and path can be updated.
63
63
@@ -204,7 +204,11 @@ For Strapi Cloud customers, the `auditLogs.retentionDays` value stored in the li
204
204
205
205
## Authentication
206
206
207
-
The authentication system, including [SSO configuration](/cms/configurations/guides/configure-sso), can be configured with the following parameters:
207
+
The authentication system, including [SSO configuration](/cms/configurations/guides/configure-sso) and [session management](#session-management), can be configured with the following parameters:
208
+
209
+
### Basic authentication
210
+
211
+
To configure basic authentication, use the following parameters:
@@ -218,6 +222,43 @@ The authentication system, including [SSO configuration](/cms/configurations/gui
218
222
|`auth.events.onConnectionSuccess`| Function called when an admin user log in successfully to the administration panel | function |`undefined`|
219
223
|`auth.events.onConnectionError`| Function called when an admin user fails to log in to the administration panel | function |`undefined`|
220
224
225
+
Additional configuration parameters are available for [session management](#session-management).
226
+
227
+
### Session management
228
+
229
+
Admin authentication uses session management by default for enhanced security.
230
+
231
+
Session management provides enhanced security for authentication in Strapi applications by using short-lived access tokens paired with longer-lived refresh tokens. This approach reduces the risk of token theft and allows for more granular control over user sessions.
232
+
233
+
Strapi's session management system supports both admin panel authentication and Content API authentication through the [Users & Permissions feature](/cms/features/users-permissions). The system provides:
234
+
235
+
- Short-lived access tokens (typically 30 minutes) for API requests
236
+
- Refresh tokens for obtaining new access tokens
237
+
- Device-specific sessions for targeted logout
238
+
- Configurable token lifespans for different security requirements
239
+
240
+
To configure session lifespans and behavior, use the following parameters:
Copy file name to clipboardExpand all lines: docusaurus/docs/cms/configurations/environment.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,30 @@ Prefixing an environment variable name with `STRAPI_ADMIN_` exposes the variable
56
56
57
57
<SampleEnv />
58
58
59
+
Set these environment variables for secure authentication with [sessions management](/cms/features/users-permissions#jwt-management-modes) configuration:
60
+
61
+
```bash title=".env"
62
+
# Admin authentication
63
+
ADMIN_JWT_SECRET=your-admin-secret-key
64
+
65
+
# Cookie domain (optional)
66
+
ADMIN_COOKIE_DOMAIN=yourdomain.com
67
+
68
+
# Users & Permissions JWT secret
69
+
JWT_SECRET=your-content-api-secret-key
70
+
71
+
# Users & Permissions session management
72
+
UP_JWT_MANAGEMENT=refresh # or 'legacy-support'
73
+
UP_SESSIONS_ACCESS_TTL=604800 # 1 week in seconds
74
+
UP_SESSIONS_MAX_REFRESH_TTL=2592000 # 30 days in seconds
75
+
UP_SESSIONS_IDLE_REFRESH_TTL=604800 # 7 days in seconds
76
+
UP_SESSIONS_HTTPONLY=false # true for HTTP-only cookies
77
+
UP_SESSIONS_COOKIE_NAME=strapi_up_refresh
78
+
UP_SESSIONS_COOKIE_SAMESITE=lax
79
+
UP_SESSIONS_COOKIE_PATH=/
80
+
UP_SESSIONS_COOKIE_SECURE=false # true in production
81
+
```
82
+
59
83
## Environment configurations
60
84
61
85
Configurations can be created with the following naming and structure conventions: `./config/env/{environment}/{filename}`. This is useful when you need specific static configurations for specific environments and using environment variables is not the best solution.
0 commit comments