Skip to content

Commit fd1d3dd

Browse files
authored
feat(docs): add session management documents (#1397)
* feat(docs): add session management docs add session management docs * fix(docs): fix broken links fix broken anchor links * chore(docs): add i18n add i18n # Conflicts: # i18n/de/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/ja/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/ko/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/pt-BR/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/th/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/zh-CN/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # i18n/zh-TW/docusaurus-plugin-content-docs/current/developers/signing-keys.mdx # Conflicts: # i18n/de/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/de/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/es/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/es/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/fr/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/fr/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/ja/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/ja/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/ko/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/ko/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/pt-BR/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/pt-BR/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/th/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/th/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/zh-CN/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/zh-CN/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx # i18n/zh-TW/docusaurus-plugin-content-docs/current/end-user-flows/mfa/configure-mfa.mdx # i18n/zh-TW/docusaurus-plugin-content-docs/current/logto-cloud/private-cloud.mdx * fix: fix lint fix lint
1 parent d19ead9 commit fd1d3dd

103 files changed

Lines changed: 9370 additions & 5425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/developers/signing-keys.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_position: 5
77

88
# Signing keys
99

10-
Logto [OIDC signing keys](https://auth.wiki/signing-key), as known as "OIDC private keys" and "OIDC cookie keys", are the signing keys used to sign JWTs ([access tokens](https://auth.wiki/access-token) and [ID tokens](https://auth.wiki/id-token)) and browser cookies in Logto [sign-in sessions](/end-user-flows/sign-out#what-is-a-logto-session). These signing keys are generated when seeding Logto database ([open-source](/logto-oss)) or creating a new tenant ([Cloud](/logto-cloud)) and can be managed through [CLI](/logto-oss/using-cli) (open-source), Management APIs or Console UI.
10+
Logto [OIDC signing keys](https://auth.wiki/signing-key), as known as "OIDC private keys" and "OIDC cookie keys", are the signing keys used to sign JWTs ([access tokens](https://auth.wiki/access-token) and [ID tokens](https://auth.wiki/id-token)) and browser cookies in Logto [sign-in sessions](/sessions#what-is-a-logto-session). These signing keys are generated when seeding Logto database ([open-source](/logto-oss)) or creating a new tenant ([Cloud](/logto-cloud)) and can be managed through [CLI](/logto-oss/using-cli) (open-source), Management APIs or Console UI.
1111

1212
By default, Logto uses the elliptic curve (EC) algorithm to generate digital signatures. However, considering that users often need to verify JWT signatures and many older tools do not support the EC algorithm (only supporting RSA), we have implemented the functionality to rotate private keys and allow users to choose the signature algorithm (including both RSA and EC). This ensures compatibility with services that use outdated signature verification tools.
1313

docs/end-user-flows/account-settings/by-account-api.mdx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Some frequent use cases are listed below:
2424
- Update user identities including email, phone, and social connections
2525
- Manage MFA factors (verifications)
2626
- Manage user sessions
27+
- Manage user authorized apps (grants)
2728

2829
To learn more about the available APIs, please visit [Logto Account API Reference](https://openapi.logto.io/group/endpoint-my-account) and [Logto Verification API Reference](https://openapi.logto.io/group/endpoint-verifications).
2930

@@ -52,6 +53,7 @@ Once enabled, configure per-field permissions for identifiers, profile data, and
5253
- For OIDC or OAuth social and enterprise connectors, Logto [secret vault](/secret-vault/federated-token-set) securely stores third-party access and refresh tokens after authentication. Apps can then call external APIs, such as syncing Google Calendar events, without prompting users to sign in again. Token retrieval becomes available automatically once the Account API is enabled.
5354
4. **Session management**:
5455
- When enabled, users can view and manage their active sessions, including device information and last sign-in time. Users can also revoke sessions to log out from specific devices.
56+
- This same `Sessions` field permission also controls user authorized apps (grants) APIs (view and revoke grants).
5557
- Before end users access session management, they must verify their identity via password, email, or SMS to obtain a 10-minute verification record ID. See [Get a verification record id](#get-a-verification-record-id).
5658

5759
## How to access Account API \{#how-to-access-account-api}
@@ -74,7 +76,7 @@ const config: LogtoConfig = {
7476
UserScope.Address, // To manage address
7577
UserScope.Identities, // For identity and MFA related APIs
7678
UserScope.Profile, // To manage user profile
77-
UserScope.Sessions, // To manage user sessions
79+
UserScope.Sessions, // To manage user sessions and app grants
7880
],
7981
};
8082
```
@@ -713,3 +715,54 @@ Optional query parameters:
713715
- `all`: Revoke all grants associated with the session.
714716
- `firstParty`: Revoke only first-party app grants associated with the session. (Recommended for most use cases, as it revokes access for your own app while keeping third-party app grants intact, providing a better user experience.)
715717
- unspecified: Default behavior revokes grants that does not have `offline_access` scope, which typically means revoking non-refresh-token grants for the session.
718+
719+
### Manage user authorized apps (grants) \{#manage-user-authorized-apps-grants}
720+
721+
Use user authorized apps (grants) APIs when users need to review and revoke authorized apps from their account settings page.
722+
723+
:::note
724+
725+
- App grant APIs share the same permission model as session APIs.
726+
- `UserScope.Sessions` scope is required.
727+
- `Sessions` field in account center settings must be enabled:
728+
- `ReadOnly` or `Edit` to list grants.
729+
- `Edit` to revoke grants.
730+
731+
:::
732+
733+
**List active app grants**
734+
735+
To list active app grants of the current user, use the [`GET /api/my-account/grants`](https://openapi.logto.io/operation/operation-getgrants) endpoint.
736+
737+
```bash
738+
curl https://[tenant-id].logto.app/api/my-account/grants \
739+
-H 'authorization: Bearer <access_token>' \
740+
-H 'logto-verification-id: <verification_record_id>' \
741+
-H 'content-type: application/json'
742+
```
743+
744+
Optional query parameter:
745+
746+
- `appType=firstParty`: Return first-party app grants only.
747+
- `appType=thirdParty`: Return third-party app grants only.
748+
- Omit `appType`: Return all active grants.
749+
750+
```bash
751+
curl "https://[tenant-id].logto.app/api/my-account/grants?appType=thirdParty" \
752+
-H 'authorization: Bearer <access_token>' \
753+
-H 'logto-verification-id: <verification_record_id>' \
754+
-H 'content-type: application/json'
755+
```
756+
757+
**Revoke app grant by grant ID**
758+
759+
To revoke a specific app grant, use the [`DELETE /api/my-account/grants/{grantId}`](https://openapi.logto.io/operation/operation-deletegrantbyid) endpoint.
760+
761+
```bash
762+
curl -X DELETE https://[tenant-id].logto.app/api/my-account/grants/{grantId} \
763+
-H 'authorization: Bearer <access_token>' \
764+
-H 'logto-verification-id: <verification_record_id>' \
765+
-H 'content-type: application/json'
766+
```
767+
768+
When a grant is revoked, previously issued opaque access tokens and refresh tokens for that grant are invalidated.

docs/end-user-flows/account-settings/by-management-api.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,18 @@ Personal access tokens provide a secure way for users to grant [access token](ht
202202
| GET | [/api/users/\{userId\}/sessions](https://openapi.logto.io/operation/operation-listusersessions) | Get user sessions by user ID. |
203203
| GET | [/api/users/\{userId\}/sessions/\{sessionId\}](https://openapi.logto.io/operation/operation-getusersession) | Get a user session by session ID. |
204204
| DELETE | [/api/users/\{userId\}/sessions/\{sessionId\}](https://openapi.logto.io/operation/operation-deleteusersession) | Delete a user session by session ID. |
205+
206+
### Manage user authorized apps (grants) \{#manage-user-authorized-apps-grants}
207+
208+
| method | path | description |
209+
| ------ | -------------------------------------------------------------------------------------------------------- | ------------------------------------ |
210+
| GET | [/api/users/\{userId\}/grants](https://openapi.logto.io/operation/operation-listusergrants) | List active app grants for the user. |
211+
| DELETE | [/api/users/\{userId\}/grants/\{grantId\}](https://openapi.logto.io/operation/operation-deleteusergrant) | Revoke a specific app grant by ID. |
212+
213+
Optional query parameter for grant listing:
214+
215+
- `appType=firstParty`: Return first-party app grants only.
216+
- `appType=thirdParty`: Return third-party app grants only.
217+
- Omit `appType`: Return all active grants.
218+
219+
When a grant is revoked, previously issued opaque access tokens and refresh tokens for that grant are invalidated.

docs/end-user-flows/sign-out.mdx

Lines changed: 11 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,15 @@
11
---
2-
sidebar_position: 8
2+
sidebar_position: 7.5
33
---
44

55
# Sign-out
66

7-
Sign-out in Logto (as an OIDC identity provider) involves both:
7+
Sign-out in Logto involves two layers:
88

9-
- A **centralized Logto session** (browser cookie under Logto domain), and
10-
- **Distributed client-side auth state** (tokens and local app session in each app).
9+
- **Logto session sign-out**: Ends the centralized sign-in session under the Logto domain.
10+
- **App sign-out**: Clears local session state and tokens in your client application.
1111

12-
To understand sign-out behavior, it helps to separate these two layers and then see how **grants** connect them.
13-
14-
## Core concepts \{#core-concepts}
15-
16-
### What is a Logto session? \{#what-is-a-logto-session}
17-
18-
A Logto session is the centralized sign-in state managed by Logto. It is created after successful authentication and represented by cookies under the Logto domain.
19-
20-
If the session cookie is valid, the user can be silently authenticated (SSO) across multiple apps that trust the same Logto tenant.
21-
22-
If no valid session exists, Logto shows the sign-in page.
23-
24-
### What are grants? \{#what-are-grants}
25-
26-
A **grant** represents the authorization status for a specific user + client application combination.
27-
28-
- One Logto session can have grants for multiple client apps.
29-
- A grant is what issued tokens are associated with.
30-
- In this doc set, use **grant** as the cross-app authorization unit.
31-
32-
### How session, grants, and client auth status relate \{#how-session-grants-and-client-auth-status-relate}
33-
34-
```mermaid
35-
flowchart LR
36-
subgraph Logto [Logto domain]
37-
S[Logto session]
38-
G1[Grant for App A]
39-
G2[Grant for App B]
40-
end
41-
42-
subgraph AppA [Client domain A]
43-
A[Local session / tokens]
44-
end
45-
46-
subgraph AppB [Client domain B]
47-
B[Local session / tokens]
48-
end
49-
50-
S --> G1
51-
S --> G2
52-
G1 --> A
53-
G2 --> B
54-
```
55-
56-
- **Logto session** controls centralized SSO experience.
57-
- **Client local session/tokens** control whether each app currently treats user as signed in.
58-
- **Grants** connect these two worlds by representing app-specific authorization state.
59-
60-
## Sign-in recap (why sign-out is multi-layered) \{#sign-in-recap-why-sign-out-is-multi-layered}
61-
62-
```mermaid
63-
sequenceDiagram
64-
autonumber
65-
actor User
66-
67-
box Relying Party (RP)
68-
participant Client as Client application
69-
end
70-
71-
box Logto (IdP)
72-
participant OIDC as OIDC provider
73-
participant SignIn as Sign-in page
74-
end
75-
76-
User ->> Client: Access application
77-
Client ->> OIDC: Redirect for authentication
78-
OIDC -->> OIDC: Check Logto session
79-
OIDC ->> SignIn: Prompt sign-in if needed
80-
SignIn ->> OIDC: User authenticates
81-
OIDC -->> OIDC: Create session and grant
82-
OIDC ->> Client: Return authorization code
83-
Client ->> OIDC: Exchange code for tokens
84-
OIDC -->> Client: Return tokens
85-
```
86-
87-
## Session topology across apps/devices \{#session-topology-across-apps-devices}
88-
89-
### Shared session cookie (same browser/user agent) \{#shared-session-cookie-same-browser-user-agent}
90-
91-
If a user signs in to multiple apps from the same browser, those apps can reuse the same Logto session cookie and SSO behavior applies.
92-
93-
```mermaid
94-
flowchart TD
95-
U[User]
96-
A["Client Application A (Client domain A)"]
97-
B["Client Application B (Client domain B)"]
98-
C{"Logto session exists? (Logto domain)"}
99-
D["Sign-in page (Logto domain)"]
100-
101-
subgraph UA["User agent A (same browser)"]
102-
U
103-
A
104-
B
105-
C
106-
D
107-
end
108-
109-
U -->|Sign in| A
110-
A -->|Redirect to Logto| C
111-
U -->|Open app| B
112-
B -->|Redirect to Logto| C
113-
C -->|No| D
114-
D -->|Create session| C
115-
```
116-
117-
### Isolated session cookies (different devices/browsers) \{#isolated-session-cookies-different-devices-browsers}
118-
119-
Different browsers/devices hold different Logto cookies, so sign-in session state is isolated.
120-
121-
```mermaid
122-
flowchart TD
123-
U[User]
124-
A["Client Application A (Client domain A)"]
125-
C{"Logto session exists? (Device A, Logto domain)"}
126-
D["Sign-in page (Device A, Logto domain)"]
127-
128-
subgraph DeviceA["User agent A"]
129-
A
130-
C
131-
D
132-
end
133-
134-
B["Client Application B (Client domain B)"]
135-
E{"Logto session exists? (Device B, Logto domain)"}
136-
F["Sign-in page (Device B, Logto domain)"]
137-
138-
subgraph DeviceB["User agent B"]
139-
B
140-
E
141-
F
142-
end
143-
144-
U -->|Sign in| A
145-
A -->|Redirect to Logto| C
146-
U -->|Sign in| B
147-
B -->|Redirect to Logto| E
148-
C -->|No| D
149-
E -->|No| F
150-
D -->|Create session| C
151-
F -->|Create session| E
152-
```
12+
To better understand how sessions work in Logto, see [Sessions](/sessions).
15313

15414
## Sign-out mechanisms \{#sign-out-mechanisms}
15515

@@ -174,6 +34,12 @@ In current Logto SDK behavior:
17434

17535
As a result, current SDK sign-out is treated as **global sign-out**.
17636

37+
:::note
38+
39+
- **Global sign-out**: Revoke the centralized Logto session.
40+
41+
:::
42+
17743
### What happens during global sign-out \{#what-happens-during-global-sign-out}
17844

17945
```mermaid

docs/integrate-logto/application-data-structure.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,25 @@ To ensure the refresh token TTL setting takes full effect, make sure to include
179179

180180
The OpenID Connect backchannel logout endpoint. See [Federated sign-out: Back-channel logout](#) for more information.
181181

182+
### Max allowed grants (`maxAllowedGrants`) \{#max-allowed-grants-maxallowedgrants}
183+
184+
`maxAllowedGrants` is an optional app-level field under `customClientMetadata` that controls the maximum number of concurrent active grants per user for the current app.
185+
186+
- **Default**: `undefined` (no limit)
187+
- **When configured**: On each successful authorization, Logto checks the total active grants for the user in the current app (across browsers and devices). If the limit is exceeded, Logto revokes the oldest grants.
188+
189+
This setting is useful when you want to cap concurrent authenticated devices per app.
190+
191+
:::note
192+
193+
This field is not supported for:
194+
195+
- Machine-to-machine apps
196+
- Protected apps
197+
- SAML apps
198+
199+
:::
200+
182201
### Custom data \{#custom-data}
183202

184203
Additional custom application info not listed in the pre-defined application properties, users can define their own custom data fields according to their specific needs, such as business-specific settings and configurations.

0 commit comments

Comments
 (0)