keycloak-api-manager 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Handlers/groupsHandler.js +0 -1
- package/Handlers/rolesHandler.js +0 -1
- package/README.md +17 -1
- package/docs/api/attack-detection.md +42 -0
- package/docs/api/authentication-management.md +160 -0
- package/docs/api/client-policies.md +66 -0
- package/docs/api/client-scopes.md +194 -0
- package/docs/api/clients.md +450 -0
- package/docs/api/components.md +57 -0
- package/docs/api/configuration.md +447 -0
- package/docs/api/groups.md +129 -0
- package/docs/api/identity-providers.md +98 -0
- package/docs/api/organizations.md +615 -0
- package/docs/api/realms.md +277 -0
- package/docs/api/roles.md +102 -0
- package/docs/api/server-info.md +38 -0
- package/docs/api/user-profile.md +63 -0
- package/docs/api/users.md +1563 -0
- package/docs/api-reference.md +163 -0
- package/package.json +2 -16
- package/test/package-lock.json +2 -16
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for keycloak-api-manager.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
### Core API
|
|
8
|
+
- [Configuration & Authentication](api/configuration.md) - Setup, authentication, and lifecycle management
|
|
9
|
+
|
|
10
|
+
### Resource Management APIs
|
|
11
|
+
|
|
12
|
+
- [Realms](api/realms.md) - Realm creation, configuration, and management
|
|
13
|
+
- [Users](api/users.md) - User CRUD, credentials, roles, groups, sessions
|
|
14
|
+
- [Clients](api/clients.md) - Client management, secrets, authorization, service accounts
|
|
15
|
+
- [Client Scopes](api/client-scopes.md) - Client scope management and protocol mappers
|
|
16
|
+
- [Groups](api/groups.md) - Group management, members, roles, permissions
|
|
17
|
+
- [Roles](api/roles.md) - Realm and client roles, composite roles
|
|
18
|
+
- [Identity Providers](api/identity-providers.md) - IdP configuration and mappers
|
|
19
|
+
- [Components](api/components.md) - Component management (LDAP, Kerberos, etc.)
|
|
20
|
+
|
|
21
|
+
### Security & Authentication APIs
|
|
22
|
+
|
|
23
|
+
- [Authentication Management](api/authentication-management.md) - Flows, executions, required actions
|
|
24
|
+
- [Attack Detection](api/attack-detection.md) - Brute force protection and user lockout
|
|
25
|
+
- [Client Policies](api/client-policies.md) - Client policies and profiles
|
|
26
|
+
|
|
27
|
+
### Advanced APIs
|
|
28
|
+
|
|
29
|
+
- [Organizations](api/organizations.md) - Organization management (Keycloak 25+)
|
|
30
|
+
- [User Profile](api/user-profile.md) - User profile configuration and metadata
|
|
31
|
+
- [Server Info](api/server-info.md) - Server information, themes, providers
|
|
32
|
+
|
|
33
|
+
## Wrapper Enhancements (Beyond Basic Upstream Coverage)
|
|
34
|
+
|
|
35
|
+
The following areas include wrapper-level improvements for missing/incomplete endpoints and reliability fixes:
|
|
36
|
+
|
|
37
|
+
- **Organizations (Keycloak 25+)**: enriched CRUD and member/IdP linking flow, including robust update merge behavior
|
|
38
|
+
- **Client Policies**: direct REST coverage for update endpoints not reliably exposed in some client versions
|
|
39
|
+
- **User Profile**: direct REST coverage for configuration/metadata endpoints with consistent error handling
|
|
40
|
+
- **Groups Permissions**: fine-grained permissions helpers (`setPermissions`, `listPermissions`) for admin authorization flows
|
|
41
|
+
- **Clients Protocol Mappers**: helper methods for create/update/find/delete with safer mapper workflow handling
|
|
42
|
+
|
|
43
|
+
## Quick Reference
|
|
44
|
+
|
|
45
|
+
### Initialization
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const KeycloakManager = require('keycloak-api-manager');
|
|
49
|
+
|
|
50
|
+
// Configure and authenticate
|
|
51
|
+
await KeycloakManager.configure({
|
|
52
|
+
baseUrl: 'https://keycloak.example.com:8443',
|
|
53
|
+
realmName: 'master',
|
|
54
|
+
username: 'admin',
|
|
55
|
+
password: 'admin',
|
|
56
|
+
grantType: 'password',
|
|
57
|
+
clientId: 'admin-cli',
|
|
58
|
+
tokenLifeSpan: 60
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// Switch to different realm
|
|
62
|
+
KeycloakManager.setConfig({ realmName: 'my-realm' });
|
|
63
|
+
|
|
64
|
+
// Use handlers
|
|
65
|
+
const users = await KeycloakManager.users.find({ max: 100 });
|
|
66
|
+
const realm = await KeycloakManager.realms.findOne({ realm: 'my-realm' });
|
|
67
|
+
|
|
68
|
+
// Cleanup when done
|
|
69
|
+
KeycloakManager.stop();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Handler Namespace Reference
|
|
73
|
+
|
|
74
|
+
| Namespace | Description | Module |
|
|
75
|
+
|-----------|-------------|--------|
|
|
76
|
+
| `configure()` | Authentication and setup | Core |
|
|
77
|
+
| `setConfig()` | Runtime configuration | Core |
|
|
78
|
+
| `getToken()` | Get current access token | Core |
|
|
79
|
+
| `auth()` | Re-authenticate | Core |
|
|
80
|
+
| `stop()` | Stop token refresh timer | Core |
|
|
81
|
+
| `realms` | Realm management | realmsHandler |
|
|
82
|
+
| `users` | User management | usersHandler |
|
|
83
|
+
| `clients` | Client management | clientsHandler |
|
|
84
|
+
| `clientScopes` | Client scope management | clientScopesHandler |
|
|
85
|
+
| `groups` | Group management | groupsHandler |
|
|
86
|
+
| `roles` | Role management | rolesHandler |
|
|
87
|
+
| `identityProviders` | Identity provider management | identityProvidersHandler |
|
|
88
|
+
| `components` | Component management | componentsHandler |
|
|
89
|
+
| `authenticationManagement` | Authentication flow management | authenticationManagementHandler |
|
|
90
|
+
| `attackDetection` | Brute force detection | attackDetectionHandler |
|
|
91
|
+
| `organizations` | Organization management | organizationsHandler |
|
|
92
|
+
| `userProfile` | User profile configuration | userProfileHandler |
|
|
93
|
+
| `clientPolicies` | Client policy management | clientPoliciesHandler |
|
|
94
|
+
| `serverInfo` | Server information | serverInfoHandler |
|
|
95
|
+
|
|
96
|
+
## Parameter Conventions
|
|
97
|
+
|
|
98
|
+
Throughout the API:
|
|
99
|
+
|
|
100
|
+
- **Required parameters** are listed first and marked with ⚠️
|
|
101
|
+
- **Optional parameters** are listed after and marked with 📋
|
|
102
|
+
- **Query parameters** are passed as objects: `{ key: value, max: 100 }`
|
|
103
|
+
- **ID parameters** use Keycloak's UUID format
|
|
104
|
+
- **Realm context** can be set globally with `setConfig()` or per-call
|
|
105
|
+
|
|
106
|
+
## Error Handling
|
|
107
|
+
|
|
108
|
+
All API methods return Promises. Handle errors with try/catch:
|
|
109
|
+
|
|
110
|
+
```javascript
|
|
111
|
+
try {
|
|
112
|
+
const user = await KeycloakManager.users.findOne({ id: userId });
|
|
113
|
+
console.log(user.username);
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.error('API Error:', error.message);
|
|
116
|
+
// error.response may contain Keycloak-specific error details
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Return Values
|
|
121
|
+
|
|
122
|
+
- **Single resource**: Returns object (e.g., `{ id: '...', username: '...' }`)
|
|
123
|
+
- **Multiple resources**: Returns array (e.g., `[{ id: '...' }, ...]`)
|
|
124
|
+
- **Create operations**: Usually return `{ id: 'newly-created-id' }` or the created resource
|
|
125
|
+
- **Update operations**: Usually return void or updated resource
|
|
126
|
+
- **Delete operations**: Return void
|
|
127
|
+
- **Count operations**: Return number
|
|
128
|
+
|
|
129
|
+
## Authentication Modes
|
|
130
|
+
|
|
131
|
+
### Password Grant (Admin User)
|
|
132
|
+
|
|
133
|
+
```javascript
|
|
134
|
+
await KeycloakManager.configure({
|
|
135
|
+
baseUrl: 'https://keycloak.example.com',
|
|
136
|
+
realmName: 'master',
|
|
137
|
+
username: 'admin',
|
|
138
|
+
password: 'admin',
|
|
139
|
+
grantType: 'password',
|
|
140
|
+
clientId: 'admin-cli'
|
|
141
|
+
});
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Client Credentials Grant (Service Account)
|
|
145
|
+
|
|
146
|
+
```javascript
|
|
147
|
+
await KeycloakManager.configure({
|
|
148
|
+
baseUrl: 'https://keycloak.example.com',
|
|
149
|
+
realmName: 'master',
|
|
150
|
+
clientId: 'my-service-client',
|
|
151
|
+
clientSecret: 'client-secret-here',
|
|
152
|
+
grantType: 'client_credentials'
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Next Steps
|
|
157
|
+
|
|
158
|
+
Browse the handler-specific documentation for detailed method reference:
|
|
159
|
+
|
|
160
|
+
1. Start with [Configuration](api/configuration.md) to set up authentication
|
|
161
|
+
2. Explore [Realms](api/realms.md) and [Users](api/users.md) for basic operations
|
|
162
|
+
3. Check [Organizations](api/organizations.md) for Keycloak 25+ features
|
|
163
|
+
4. Review [Server Info](api/server-info.md) to inspect your Keycloak capabilities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keycloak-api-manager",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Enhanced Node.js wrapper for Keycloak Admin REST API. Professional alternative to @keycloak/keycloak-admin-client with advanced features, bug fixes, automatic token refresh, Organizations API support, fine-grained permissions, and comprehensive resource management. Battle-tested with 113+ integration tests.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,21 +8,7 @@
|
|
|
8
8
|
"setup-keycloak": "node test/docker-keycloak/setup-keycloak.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@keycloak/keycloak-admin-client": "^26.3.2"
|
|
12
|
-
"async": "^3.2.6",
|
|
13
|
-
"body-parser": "^2.2.0",
|
|
14
|
-
"cookie-parser": "^1.4.7",
|
|
15
|
-
"debug": "^4.4.1",
|
|
16
|
-
"express": "^5.1.0",
|
|
17
|
-
"express-session": "^1.18.1",
|
|
18
|
-
"jwt-simple": "^0.5.6",
|
|
19
|
-
"keycloak-connect": "^26.1.1",
|
|
20
|
-
"moment": "^2.30.1",
|
|
21
|
-
"morgan": "^1.10.0",
|
|
22
|
-
"request": "^2.88.2",
|
|
23
|
-
"responseinterceptor": "^1.1.8",
|
|
24
|
-
"serve-favicon": "^2.5.0",
|
|
25
|
-
"underscore": "^1.13.7"
|
|
11
|
+
"@keycloak/keycloak-admin-client": "^26.3.2"
|
|
26
12
|
},
|
|
27
13
|
"keywords": [
|
|
28
14
|
"keycloak",
|
package/test/package-lock.json
CHANGED
|
@@ -19,24 +19,10 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"..": {
|
|
22
|
-
"version": "
|
|
22
|
+
"version": "5.0.0",
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@keycloak/keycloak-admin-client": "^26.3.2"
|
|
26
|
-
"async": "^3.2.6",
|
|
27
|
-
"body-parser": "^2.2.0",
|
|
28
|
-
"cookie-parser": "^1.4.7",
|
|
29
|
-
"debug": "^4.4.1",
|
|
30
|
-
"express": "^5.1.0",
|
|
31
|
-
"express-session": "^1.18.1",
|
|
32
|
-
"jwt-simple": "^0.5.6",
|
|
33
|
-
"keycloak-connect": "^26.1.1",
|
|
34
|
-
"moment": "^2.30.1",
|
|
35
|
-
"morgan": "^1.10.0",
|
|
36
|
-
"request": "^2.88.2",
|
|
37
|
-
"responseinterceptor": "^1.1.8",
|
|
38
|
-
"serve-favicon": "^2.5.0",
|
|
39
|
-
"underscore": "^1.13.7"
|
|
25
|
+
"@keycloak/keycloak-admin-client": "^26.3.2"
|
|
40
26
|
}
|
|
41
27
|
},
|
|
42
28
|
"node_modules/@keycloak/keycloak-admin-client": {
|