equipes keycloak flow

This commit is contained in:
alma 2025-05-03 15:36:20 +02:00
parent 0bb4c8fca4
commit b6978fb6b0
215 changed files with 8041 additions and 1 deletions

View File

@ -212,7 +212,7 @@ export function Sidebar({ isOpen, onClose }: SidebarProps) {
icon: Building2,
href: "/mediation",
iframe: process.env.NEXT_PUBLIC_IFRAME_MEDIATIONS_URL,
requiredRole: ["mediation", "expression"],
requiredRole: "mediation",
},
];

105
lib/keycloak.ts Normal file
View File

@ -0,0 +1,105 @@
import KcAdminClient from '@keycloak/keycloak-admin-client';
import { Credentials } from '@keycloak/keycloak-admin-client/lib/utils/auth';
// Cache the admin client to avoid creating a new one for each request
let adminClient: KcAdminClient | null = null;
/**
* Get a Keycloak admin client instance
* @returns KcAdminClient instance
*/
export async function getKeycloakAdminClient(): Promise<KcAdminClient> {
if (adminClient) {
try {
// Check if the token is still valid by making a simple request
await adminClient.users.find({ max: 1 });
return adminClient;
} catch (error) {
// Token expired, create a new client
console.log('Keycloak token expired, creating new admin client');
adminClient = null;
}
}
const kcAdminClient = new KcAdminClient({
baseUrl: process.env.NEXT_PUBLIC_KEYCLOAK_ISSUER || 'http://localhost:8080',
realmName: 'master', // Use master realm to manage other realms
});
// Authenticate admin client
await kcAdminClient.auth({
clientId: process.env.KEYCLOAK_ADMIN_CLIENT_ID || 'admin-cli',
username: process.env.KEYCLOAK_ADMIN_USERNAME || 'admin',
password: process.env.KEYCLOAK_ADMIN_PASSWORD || 'admin',
grantType: 'password',
} as Credentials);
// Set the target realm to work with
kcAdminClient.setConfig({
realmName: process.env.KEYCLOAK_REALM || 'cercle',
});
// Cache the admin client
adminClient = kcAdminClient;
return kcAdminClient;
}
/**
* Get a user by ID
* @param userId - Keycloak user ID
* @returns User representation or null if not found
*/
export async function getUserById(userId: string) {
try {
const kcAdminClient = await getKeycloakAdminClient();
return await kcAdminClient.users.findOne({ id: userId });
} catch (error) {
console.error('Error getting user by ID:', error);
return null;
}
}
/**
* Get a user by email
* @param email - User email
* @returns User representation or null if not found
*/
export async function getUserByEmail(email: string) {
try {
const kcAdminClient = await getKeycloakAdminClient();
const users = await kcAdminClient.users.find({ email: email });
return users?.[0] || null;
} catch (error) {
console.error('Error getting user by email:', error);
return null;
}
}
/**
* Get all available roles in the realm
* @returns Array of role representations
*/
export async function getAllRoles() {
try {
const kcAdminClient = await getKeycloakAdminClient();
return await kcAdminClient.roles.find();
} catch (error) {
console.error('Error getting roles:', error);
return [];
}
}
/**
* Get user roles for a specific user
* @param userId - Keycloak user ID
* @returns User role mappings
*/
export async function getUserRoles(userId: string) {
try {
const kcAdminClient = await getKeycloakAdminClient();
return await kcAdminClient.users.listRoleMappings({ id: userId });
} catch (error) {
console.error('Error getting user roles:', error);
return null;
}
}

157
node_modules/.package-lock.json generated vendored
View File

@ -175,6 +175,23 @@
"node": ">=18"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.25.0",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.0.tgz",
"integrity": "sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@floating-ui/core": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.6.9.tgz",
@ -351,6 +368,82 @@
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linux-arm64": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.1.0.tgz",
"integrity": "sha512-IVfGJa7gjChDET1dK9SekxFFdflarnUB8PwW8aGwEoF3oAsSDuNUTYS+SKDOyOJxQyDC1aPFMuRYLoDInyV9Ew==",
"cpu": [
"arm64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-libvips-linuxmusl-arm64": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.1.0.tgz",
"integrity": "sha512-jYZdG+whg0MDK+q2COKbYidaqW/WTz0cc1E+tMAusiDygrM4ypmSCjOJPmFTvHHJ8j/6cAGyeDWZOsK06tP33w==",
"cpu": [
"arm64"
],
"license": "LGPL-3.0-or-later",
"optional": true,
"os": [
"linux"
],
"funding": {
"url": "https://opencollective.com/libvips"
}
},
"node_modules/@img/sharp-linux-arm64": {
"version": "0.34.1",
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.1.tgz",
"integrity": "sha512-kX2c+vbvaXC6vly1RDf/IWNXxrlxLNpBVWkdpRq5Ka7OOKj6nr66etKy2IENf6FtOgklkg9ZdGpEu9kwdlcwOQ==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linux-arm64": "1.1.0"
}
},
"node_modules/@img/sharp-linuxmusl-arm64": {
"version": "0.34.1",
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.1.tgz",
"integrity": "sha512-DfvyxzHxw4WGdPiTF0SOHnm11Xv4aQexvqhRDAoD00MzHekAj9a/jADXeXYCDFH/DzYruwHbXU7uz+H+nWmSOQ==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
},
"funding": {
"url": "https://opencollective.com/libvips"
},
"optionalDependencies": {
"@img/sharp-libvips-linuxmusl-arm64": "1.1.0"
}
},
"node_modules/@ioredis/commands": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
@ -416,6 +509,20 @@
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@keycloak/keycloak-admin-client": {
"version": "26.2.2",
"resolved": "https://registry.npmjs.org/@keycloak/keycloak-admin-client/-/keycloak-admin-client-26.2.2.tgz",
"integrity": "sha512-H0U3jjkXRHR0zU9xVcv5+GzWpDCAEab4NHKCbilVZSjrSLzqbGLMTEiGAo81NpHilseTiFpzEkz2qFm6/Hm0BA==",
"license": "Apache-2.0",
"dependencies": {
"camelize-ts": "^3.0.0",
"url-join": "^5.0.0",
"url-template": "^3.1.1"
},
"engines": {
"node": ">=18"
}
},
"node_modules/@next/env": {
"version": "15.3.1",
"resolved": "https://registry.npmjs.org/@next/env/-/env-15.3.1.tgz",
@ -438,6 +545,38 @@
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-gnu": {
"version": "15.3.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-15.3.1.tgz",
"integrity": "sha512-wBQ+jGUI3N0QZyWmmvRHjXjTWFy8o+zPFLSOyAyGFI94oJi+kK/LIZFJXeykvgXUk1NLDAEFDZw/NVINhdk9FQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@next/swc-linux-arm64-musl": {
"version": "15.3.1",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-15.3.1.tgz",
"integrity": "sha512-IIxXEXRti/AulO9lWRHiCpUUR8AR/ZYLPALgiIg/9ENzMzLn3l0NSxVdva7R/VDcuSEBo0eGVCe3evSIHNz0Hg==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
}
},
"node_modules/@nextcloud/files": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@nextcloud/files/-/files-2.1.0.tgz",
@ -2892,6 +3031,15 @@
"node": ">= 6"
}
},
"node_modules/camelize-ts": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/camelize-ts/-/camelize-ts-3.0.0.tgz",
"integrity": "sha512-cgRwKKavoDKLTjO4FQTs3dRBePZp/2Y9Xpud0FhuCOTE86M2cniKN4CCXgRnsyXNMmQMifVHcv6SPaMtTx6ofQ==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001692",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001692.tgz",
@ -6941,6 +7089,15 @@
"requires-port": "^1.0.0"
}
},
"node_modules/url-template": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/url-template/-/url-template-3.1.1.tgz",
"integrity": "sha512-4oszoaEKE/mQOtAmdMWqIRHmkxWkUZMnXFnjQ5i01CuRSK3uluxcH1MRVVVWmhlnzT1SCDfKxxficm2G37qzCA==",
"license": "BSD-3-Clause",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/use-callback-ref": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.3.tgz",

201
node_modules/@keycloak/keycloak-admin-client/LICENSE generated vendored Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

459
node_modules/@keycloak/keycloak-admin-client/README.md generated vendored Normal file
View File

@ -0,0 +1,459 @@
## Keycloak Admin Client
## Features
- TypeScript supported
- Latest Keycloak version supported
- [Complete resource definitions](./src/defs)
- [Well-tested for supported APIs](./test)
## Install
```sh
npm install @keycloak/keycloak-admin-client
```
## Usage
```js
import KcAdminClient from '@keycloak/keycloak-admin-client';
// To configure the client, pass an object to override any of these options:
// {
// baseUrl: 'http://127.0.0.1:8080',
// realmName: 'master',
// requestOptions: {
// /* Fetch request options https://developer.mozilla.org/en-US/docs/Web/API/fetch#options */
// },
// }
const kcAdminClient = new KcAdminClient();
// Authorize with username / password
await kcAdminClient.auth({
username: 'admin',
password: 'admin',
grantType: 'password',
clientId: 'admin-cli',
totp: '123456', // optional Time-based One-time Password if OTP is required in authentication flow
});
// List first page of users
const users = await kcAdminClient.users.find({ first: 0, max: 10 });
// find users by attributes
const users = await kcAdminClient.users.find({ q: "phone:123" });
// Override client configuration for all further requests:
kcAdminClient.setConfig({
realmName: 'another-realm',
});
// This operation will now be performed in 'another-realm' if the user has access.
const groups = await kcAdminClient.groups.find();
// Set a `realm` property to override the realm for only a single operation.
// For example, creating a user in another realm:
await kcAdminClient.users.create({
realm: 'a-third-realm',
username: 'username',
email: 'user@example.com',
});
```
To refresh the access token provided by Keycloak, an OpenID client like [panva/node-openid-client](https://github.com/panva/node-openid-client) can be used like this:
```js
import {Issuer} from 'openid-client';
const keycloakIssuer = await Issuer.discover(
'http://localhost:8080/realms/master',
);
const client = new keycloakIssuer.Client({
client_id: 'admin-cli', // Same as `clientId` passed to client.auth()
token_endpoint_auth_method: 'none', // to send only client_id in the header
});
// Use the grant type 'password'
let tokenSet = await client.grant({
grant_type: 'password',
username: 'admin',
password: 'admin',
});
// Periodically using refresh_token grant flow to get new access token here
setInterval(async () => {
const refreshToken = tokenSet.refresh_token;
tokenSet = await client.refresh(refreshToken);
kcAdminClient.setAccessToken(tokenSet.access_token);
}, 58 * 1000); // 58 seconds
```
In cases where you don't have a refresh token, eg. in a client credentials flow, you can simply call `kcAdminClient.auth` to get a new access token, like this:
```js
const credentials = {
grantType: 'client_credentials',
clientId: 'clientId',
clientSecret: 'some-client-secret-uuid',
};
await kcAdminClient.auth(credentials);
setInterval(() => kcAdminClient.auth(credentials), 58 * 1000); // 58 seconds
```
## Building and running the tests
To build the source do a build:
```bash
pnpm build
```
Start the Keycloak server:
```bash
pnpm server:start
```
If you started your container manually make sure there is an admin user named 'admin' with password 'admin'.
Then start the tests with:
```bash
pnpm test
```
## Supported APIs
### [Realm admin](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_realms_admin_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/realms.spec.ts
- Import a realm from a full representation of that realm (`POST /`)
- Get the top-level representation of the realm (`GET /{realm}`)
- Update the top-level information of the realm (`PUT /{realm}`)
- Delete the realm (`DELETE /{realm}`)
- Partial export of existing realm into a JSON file (`POST /{realm}/partial-export`)
- Get users management permissions (`GET /{realm}/users-management-permissions`)
- Enable users management permissions (`PUT /{realm}/users-management-permissions`)
- Get events (`GET /{realm}/events`)
- Get admin events (`GET /{realm}/admin-events`)
- Remove all user sessions (`POST /{realm}/logout-all`)
- Remove a specific user session (`DELETE /{realm}/sessions/{session}`)
- Get client policies policies (`GET /{realm}/client-policies/policies`)
- Update client policies policies (`PUT /{realm}/client-policies/policies`)
- Get client policies profiles (`GET /{realm}/client-policies/profiles`)
- Update client policies profiles (`PUT /{realm}/client-policies/profiles`)
- Get a group by path (`GET /{realm}/group-by-path/{path}`)
### [Role](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_roles_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/roles.spec.ts
- Create a new role for the realm (`POST /{realm}/roles`)
- Get all roles for the realm (`GET /{realm}/roles`)
- Get a role by name (`GET /{realm}/roles/{role-name}`)
- Update a role by name (`PUT /{realm}/roles/{role-name}`)
- Delete a role by name (`DELETE /{realm}/roles/{role-name}`)
- Get all users in a role by name for the realm (`GET /{realm}/roles/{role-name}/users`)
### [Roles (by ID)](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_roles_by_id_resource)
- Get a specific role (`GET /{realm}/roles-by-id/{role-id}`)
- Update the role (`PUT /{realm}/roles-by-id/{role-id}`)
- Delete the role (`DELETE /{realm}/roles-by-id/{role-id}`)
- Make the role a composite role by associating some child roles(`POST /{realm}/roles-by-id/{role-id}/composites`)
- Get roles children Returns a set of roles children provided the role is a composite. (`GET /{realm}/roles-by-id/{role-id}/composites`)
- Remove a set of roles from the roles composite (`DELETE /{realm}/roles-by-id/{role-id}/composites`)
- Get client-level roles for the client that are in the roles composite (`GET /{realm}/roles-by-id/{role-id}/composites/clients/{client}`)
- Get realm-level roles that are in the roles composite (`GET /{realm}/roles-by-id/{role-id}/composites/realm`)
### [User](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_users_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/users.spec.ts
- Create a new user (`POST /{realm}/users`)
- Get users Returns a list of users, filtered according to query parameters (`GET /{realm}/users`)
- Get representation of the user (`GET /{realm}/users/{id}`)
- Update the user (`PUT /{realm}/users/{id}`)
- Delete the user (`DELETE /{realm}/users/{id}`)
- Count users (`GET /{realm}/users/count`)
- Send a update account email to the user An email contains a link the user can click to perform a set of required actions. (`PUT /{realm}/users/{id}/execute-actions-email`)
- Get user groups (`GET /{realm}/users/{id}/groups`)
- Add user to group (`PUT /{realm}/users/{id}/groups/{groupId}`)
- Delete user from group (`DELETE /{realm}/users/{id}/groups/{groupId}`)
- Remove TOTP from the user (`PUT /{realm}/users/{id}/remove-totp`)
- Set up a temporary password for the user User will have to reset the temporary password next time they log in. (`PUT /{realm}/users/{id}/reset-password`)
- Send an email-verification email to the user An email contains a link the user can click to verify their email address. (`PUT /{realm}/users/{id}/send-verify-email`)
- Update a credential label for a user (`PUT /{realm}/users/{id}/credentials/{credentialId}/userLabel`)
- Move a credential to a position behind another credential (`POST /{realm}/users/{id}/credentials/{credentialId}/moveAfter/{newPreviousCredentialId}`)
- Move a credential to a first position in the credentials list of the user (`PUT /{realm}/users/{id}/credentials/{credentialId}/moveToFirst`)
### User group-mapping
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/users.spec.ts#L178
- Add user to group (`PUT /{id}/groups/{groupId}`)
- List all user groups (`GET /{id}/groups`)
- Count user groups (`GET /{id}/groups/count`)
- Remove user from group (`DELETE /{id}/groups/{groupId}`)
### User role-mapping
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/users.spec.ts#L352
- Get user role-mappings (`GET /{realm}/users/{id}/role-mappings`)
- Add realm-level role mappings to the user (`POST /{realm}/users/{id}/role-mappings/realm`)
- Get realm-level role mappings (`GET /{realm}/users/{id}/role-mappings/realm`)
- Delete realm-level role mappings (`DELETE /{realm}/users/{id}/role-mappings/realm`)
- Get realm-level roles that can be mapped (`GET /{realm}/users/{id}/role-mappings/realm/available`)
- Get effective realm-level role mappings This will recurse all composite roles to get the result. (`GET /{realm}/users/{id}/role-mappings/realm/composite`)
### [Group](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_groups_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/groups.spec.ts
- Create (`POST /{realm}/groups`)
- List (`GET /{realm}/groups`)
- Get one (`GET /{realm}/groups/{id}`)
- Update (`PUT /{realm}/groups/{id}`)
- Delete (`DELETE /{realm}/groups/{id}`)
- Count (`GET /{realm}/groups/count`)
- List members (`GET /{realm}/groups/{id}/members`)
- Set or create child (`POST /{realm}/groups/{id}/children`)
- Get children (`GET /{realm}/groups/{id}/children`)
### Group role-mapping
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/groups.spec.ts#L103
- Get group role-mappings (`GET /{realm}/groups/{id}/role-mappings`)
- Add realm-level role mappings to the group (`POST /{realm}/groups/{id}/role-mappings/realm`)
- Get realm-level role mappings (`GET /{realm}/groups/{id}/role-mappings/realm`)
- Delete realm-level role mappings (`DELETE /{realm}/groups/{id}/role-mappings/realm`)
- Get realm-level roles that can be mapped (`GET /{realm}/groups/{id}/role-mappings/realm/available`)
- Get effective realm-level role mappings This will recurse all composite roles to get the result. (`GET /{realm}/groups/{id}/role-mappings/realm/composite`)
### [Client](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_clients_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- Create a new client (`POST /{realm}/clients`)
- Get clients belonging to the realm (`GET /{realm}/clients`)
- Get representation of the client (`GET /{realm}/clients/{id}`)
- Update the client (`PUT /{realm}/clients/{id}`)
- Delete the client (`DELETE /{realm}/clients/{id}`)
### [Client roles](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_roles_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- Create a new role for the client (`POST /{realm}/clients/{id}/roles`)
- Get all roles for the client (`GET /{realm}/clients/{id}/roles`)
- Get a role by name (`GET /{realm}/clients/{id}/roles/{role-name}`)
- Update a role by name (`PUT /{realm}/clients/{id}/roles/{role-name}`)
- Delete a role by name (`DELETE /{realm}/clients/{id}/roles/{role-name}`)
### [Client role-mapping for group](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_role_mappings_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/groups.spec.ts#L192
- Add client-level roles to the group role mapping (`POST /{realm}/groups/{id}/role-mappings/clients/{client}`)
- Get client-level role mappings for the group (`GET /{realm}/groups/{id}/role-mappings/clients/{client}`)
- Delete client-level roles from group role mapping (`DELETE /{realm}/groups/{id}/role-mappings/clients/{client}`)
- Get available client-level roles that can be mapped to the group (`GET /{realm}/groups/{id}/role-mappings/clients/{client}/available`)
- Get effective client-level role mappings This will recurse all composite roles to get the result. (`GET /{realm}/groups/{id}/role-mappings/clients/{client}/composite`)
### [Client role-mapping for user](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_role_mappings_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/users.spec.ts#L352
- Add client-level roles to the user role mapping (`POST /{realm}/users/{id}/role-mappings/clients/{client}`)
- Get client-level role mappings for the user (`GET /{realm}/users/{id}/role-mappings/clients/{client}`)
- Delete client-level roles from user role mapping (`DELETE /{realm}/users/{id}/role-mappings/clients/{client}`)
- Get available client-level roles that can be mapped to the user (`GET /{realm}/users/{id}/role-mappings/clients/{client}/available`)
- Get effective client-level role mappings This will recurse all composite roles to get the result. (`GET /{realm}/users/{id}/role-mappings/clients/{client}/composite`)
### [Client Attribute Certificate](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_attribute_certificate_resource)
- Get key info (`GET /{realm}/clients/{id}/certificates/{attr}`)
- Get a keystore file for the client, containing private key and public certificate (`POST /{realm}/clients/{id}/certificates/{attr}/download`)
- Generate a new certificate with new key pair (`POST /{realm}/clients/{id}/certificates/{attr}/generate`)
- Generate a new keypair and certificate, and get the private key file Generates a keypair and certificate and serves the private key in a specified keystore format. (`POST /{realm}/clients/{id}/certificates/{attr}/generate-and-download`)
- Upload certificate and eventually private key (`POST /{realm}/clients/{id}/certificates/{attr}/upload`)
- Upload only certificate, not private key (`POST /{realm}/clients/{id}/certificates/{attr}/upload-certificate`)
### [Identity Providers](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_identity_providers_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/idp.spec.ts
- Create a new identity provider (`POST /{realm}/identity-provider/instances`)
- Get identity providers (`GET /{realm}/identity-provider/instances`)
- Get the identity provider (`GET /{realm}/identity-provider/instances/{alias}`)
- Update the identity provider (`PUT /{realm}/identity-provider/instances/{alias}`)
- Delete the identity provider (`DELETE /{realm}/identity-provider/instances/{alias}`)
- Find identity provider factory (`GET /{realm}/identity-provider/providers/{providerId}`)
- Create a new identity provider mapper (`POST /{realm}/identity-provider/instances/{alias}/mappers`)
- Get identity provider mappers (`GET /{realm}/identity-provider/instances/{alias}/mappers`)
- Get the identity provider mapper (`GET /{realm}/identity-provider/instances/{alias}/mappers/{id}`)
- Update the identity provider mapper (`PUT /{realm}/identity-provider/instances/{alias}/mappers/{id}`)
- Delete the identity provider mapper (`DELETE /{realm}/identity-provider/instances/{alias}/mappers/{id}`)
- Find the identity provider mapper types (`GET /{realm}/identity-provider/instances/{alias}/mapper-types`)
### [Client Scopes](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_scopes_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Create a new client scope (`POST /{realm}/client-scopes`)
- Get client scopes belonging to the realm (`GET /{realm}/client-scopes`)
- Get representation of the client scope (`GET /{realm}/client-scopes/{id}`)
- Update the client scope (`PUT /{realm}/client-scopes/{id}`)
- Delete the client scope (`DELETE /{realm}/client-scopes/{id}`)
### [Client Scopes for realm](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_scopes_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Get realm default client scopes (`GET /{realm}/default-default-client-scopes`)
- Add realm default client scope (`PUT /{realm}/default-default-client-scopes/{id}`)
- Delete realm default client scope (`DELETE /{realm}/default-default-client-scopes/{id}`)
- Get realm optional client scopes (`GET /{realm}/default-optional-client-scopes`)
- Add realm optional client scope (`PUT /{realm}/default-optional-client-scopes/{id}`)
- Delete realm optional client scope (`DELETE /{realm}/default-optional-client-scopes/{id}`)
### [Client Scopes for client](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_scopes_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Get default client scopes (`GET /{realm}/clients/{id}/default-client-scopes`)
- Add default client scope (`PUT /{realm}/clients/{id}/default-client-scopes/{clientScopeId}`)
- Delete default client scope (`DELETE /{realm}/clients/{id}/default-client-scopes/{clientScopeId}`)
- Get optional client scopes (`GET /{realm}/clients/{id}/optional-client-scopes`)
- Add optional client scope (`PUT /{realm}/clients/{id}/optional-client-scopes/{clientScopeId}`)
- Delete optional client scope (`DELETE /{realm}/clients/{id}/optional-client-scopes/{clientScopeId}`)
### [Scope Mappings for client scopes](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_scope_mappings_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Get all scope mappings for the client (`GET /{realm}/client-scopes/{id}/scope-mappings`)
- Add client-level roles to the clients scope (`POST /{realm}/client-scopes/{id}/scope-mappings/clients/{client}`)
- Get the roles associated with a clients scope (`GET /{realm}/client-scopes/{id}/scope-mappings/clients/{client}`)
- The available client-level roles (`GET /{realm}/client-scopes/{id}/scope-mappings/clients/{client}/available`)
- Get effective client roles (`GET /{realm}/client-scopes/{id}/scope-mappings/clients/{client}/composite`)
- Remove client-level roles from the clients scope. (`DELETE /{realm}/client-scopes/{id}/scope-mappings/clients/{client}`)
- Add a set of realm-level roles to the clients scope (`POST /{realm}/client-scopes/{id}/scope-mappings/realm`)
- Get realm-level roles associated with the clients scope (`GET /{realm}/client-scopes/{id}/scope-mappings/realm`)
- Remove a set of realm-level roles from the clients scope (`DELETE /{realm}/client-scopes/{id}/scope-mappings/realm`)
- Get realm-level roles that are available to attach to this clients scope (`GET /{realm}/client-scopes/{id}/scope-mappings/realm/available`)
- Get effective realm-level roles associated with the clients scope (`GET /{realm}/client-scopes/{id}/scope-mappings/realm/composite`)
### [Scope Mappings for clients](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_scope_mappings_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Get all scope mappings for the client (`GET /{realm}/clients/{id}/scope-mappings`)
- Add client-level roles to the clients scope (`POST /{realm}/clients/{id}/scope-mappings/clients/{client}`)
- Get the roles associated with a clients scope (`GET /{realm}/clients/{id}/scope-mappings/clients/{client}`)
- Remove client-level roles from the clients scope. (`DELETE /{realm}/clients/{id}/scope-mappings/clients/{client}`)
- The available client-level roles (`GET /{realm}/clients/{id}/scope-mappings/clients/{client}/available`)
- Get effective client roles (`GET /{realm}/clients/{id}/scope-mappings/clients/{client}/composite`)
- Add a set of realm-level roles to the clients scope (`POST /{realm}/clients/{id}/scope-mappings/realm`)
- Get realm-level roles associated with the clients scope (`GET /{realm}/clients/{id}/scope-mappings/realm`)
- Remove a set of realm-level roles from the clients scope (`DELETE /{realm}/clients/{id}/scope-mappings/realm`)
- Get realm-level roles that are available to attach to this clients scope (`GET /{realm}/clients/{id}/scope-mappings/realm/available`)
- Get effective realm-level roles associated with the clients scope (`GET /{realm}/clients/{id}/scope-mappings/realm/composite`)
### [Protocol Mappers for client scopes](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_protocol_mappers_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clientScopes.spec.ts
- Create multiple mappers (`POST /{realm}/client-scopes/{id}/protocol-mappers/add-models`)
- Create a mapper (`POST /{realm}/client-scopes/{id}/protocol-mappers/models`)
- Get mappers (`GET /{realm}/client-scopes/{id}/protocol-mappers/models`)
- Get mapper by id (`GET /{realm}/client-scopes/{id}/protocol-mappers/models/{mapperId}`)
- Update the mapper (`PUT /{realm}/client-scopes/{id}/protocol-mappers/models/{mapperId}`)
- Delete the mapper (`DELETE /{realm}/client-scopes/{id}/protocol-mappers/models/{mapperId}`)
- Get mappers by name for a specific protocol (`GET /{realm}/client-scopes/{id}/protocol-mappers/protocol/{protocol}`)
### [Protocol Mappers for clients](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_protocol_mappers_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- Create multiple mappers (`POST /{realm}/clients/{id}/protocol-mappers/add-models`)
- Create a mapper (`POST /{realm}/clients/{id}/protocol-mappers/models`)
- Get mappers (`GET /{realm}/clients/{id}/protocol-mappers/models`)
- Get mapper by id (`GET /{realm}/clients/{id}/protocol-mappers/models/{mapperId}`)
- Update the mapper (`PUT /{realm}/clients/{id}/protocol-mappers/models/{mapperId}`)
- Delete the mapper (`DELETE /{realm}/clients/{id}/protocol-mappers/models/{mapperId}`)
- Get mappers by name for a specific protocol (`GET /{realm}/clients/{id}/protocol-mappers/protocol/{protocol}`)
### [Component]()
Supported for [user federation](https://www.keycloak.org/docs/latest/server_admin/index.html#_user-storage-federation). Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/components.spec.ts
- Create (`POST /{realm}/components`)
- List (`GET /{realm}/components`)
- Get (`GET /{realm}/components/{id}`)
- Update (`PUT /{realm}/components/{id}`)
- Delete (`DELETE /{realm}/components/{id}`)
### [Sessions for clients]()
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- List user sessions for a specific client (`GET /{realm}/clients/{id}/user-sessions`)
- List offline sessions for a specific client (`GET /{realm}/clients/{id}/offline-sessions`)
- Get user session count for a specific client (`GET /{realm}/clients/{id}/session-count`)
- List offline session count for a specific client (`GET /{realm}/clients/{id}/offline-session-count`)
### [Authentication Management: Required actions](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_authentication_management_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/authenticationManagement.spec.ts
- Register a new required action (`POST /{realm}/authentication/register-required-action`)
- Get required actions. Returns a list of required actions. (`GET /{realm}/authentication/required-actions`)
- Get required action for alias (`GET /{realm}/authentication/required-actions/{alias}`)
- Update required action (`PUT /{realm}/authentication/required-actions/{alias}`)
- Delete required action (`DELETE /{realm}/authentication/required-actions/{alias}`)
- Lower required actions priority (`POST /{realm}/authentication/required-actions/{alias}/lower-priority`)
- Raise required actions priority (`POST /{realm}/authentication/required-actions/{alias}/raise-priority`)
- Get unregistered required actions Returns a list of unregistered required actions. (`GET /{realm}/authentication/unregistered-required-actions`)
### [Authorization: Permission](https://www.keycloak.org/docs/8.0/authorization_services/#_overview)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- Create permission (`POST /{realm}/clients/{id}/authz/resource-server/permission/{type}`)
- Get permission (`GET /{realm}/clients/{id}/authz/resource-server/permission/{type}/{permissionId}`)
- Update permission (`PUT /{realm}/clients/{id}/authz/resource-server/permission/{type}/{permissionId}`)
- Delete permission (`DELETE /{realm}/clients/{id}/authz/resource-server/permission/{type}/{permissionId}`)
### [Authorization: Policy](https://www.keycloak.org/docs/8.0/authorization_services/#_overview)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/clients.spec.ts
- Create policy (`POST /{realm}/clients/{id}/authz/resource-server/policy/{type}`)
- Get policy (`GET /{realm}/clients/{id}/authz/resource-server/policy/{type}/{policyId}`)
- Get policy by name (`GET /{realm}/clients/{id}/authz/resource-server/policy/search`)
- Update policy (`PUT /{realm}/clients/{id}/authz/resource-server/policy/{type}/{policyId}`)
- Delete policy (`DELETE /{realm}/clients/{id}/authz/resource-server/policy/{policyId}`)
### [Attack Detection](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_attack_detection_resource)
Demo code: https://github.com/keycloak/keycloak/blob/main/js/libs/keycloak-admin-client/test/attackDetection.spec.ts
- Clear any user login failures for all users This can release temporary disabled users (`DELETE /{realm}/attack-detection/brute-force/users`)
- Get status of a username in brute force detection (`GET /{realm}/attack-detection/brute-force/users/{userId}`)
- Clear any user login failures for the user This can release temporary disabled user (`DELETE /{realm}/attack-detection/brute-force/users/{userId}`)
## Not yet supported
- [Authentication Management](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_authentication_management_resource)
- [Client Initial Access](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_initial_access_resource)
- [Client Registration Policy](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_client_registration_policy_resource)
- [Key](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_key_resource)
- [User Storage Provider](https://www.keycloak.org/docs-api/20.0.2/rest-api/index.html#_user_storage_provider_resource)
## Maintainers
This repo is originally developed by [Canner](https://www.cannercms.com) and [InfuseAI](https://infuseai.io) before being transferred under keycloak organization.

View File

@ -0,0 +1,59 @@
import type { RequestArgs } from "./resources/agent.js";
import { AttackDetection } from "./resources/attackDetection.js";
import { AuthenticationManagement } from "./resources/authenticationManagement.js";
import { Cache } from "./resources/cache.js";
import { ClientPolicies } from "./resources/clientPolicies.js";
import { Clients } from "./resources/clients.js";
import { ClientScopes } from "./resources/clientScopes.js";
import { Components } from "./resources/components.js";
import { Groups } from "./resources/groups.js";
import { IdentityProviders } from "./resources/identityProviders.js";
import { Realms } from "./resources/realms.js";
import { Organizations } from "./resources/organizations.js";
import { Roles } from "./resources/roles.js";
import { ServerInfo } from "./resources/serverInfo.js";
import { Users } from "./resources/users.js";
import { UserStorageProvider } from "./resources/userStorageProvider.js";
import { WhoAmI } from "./resources/whoAmI.js";
import { Credentials } from "./utils/auth.js";
export interface TokenProvider {
getAccessToken: () => Promise<string | undefined>;
}
export interface ConnectionConfig {
baseUrl?: string;
realmName?: string;
requestOptions?: RequestInit;
requestArgOptions?: Pick<RequestArgs, "catchNotFound">;
}
export declare class KeycloakAdminClient {
#private;
users: Users;
userStorageProvider: UserStorageProvider;
groups: Groups;
roles: Roles;
organizations: Organizations;
clients: Clients;
realms: Realms;
clientScopes: ClientScopes;
clientPolicies: ClientPolicies;
identityProviders: IdentityProviders;
components: Components;
serverInfo: ServerInfo;
whoAmI: WhoAmI;
attackDetection: AttackDetection;
authenticationManagement: AuthenticationManagement;
cache: Cache;
baseUrl: string;
realmName: string;
scope?: string;
accessToken?: string;
refreshToken?: string;
constructor(connectionConfig?: ConnectionConfig);
auth(credentials: Credentials): Promise<void>;
registerTokenProvider(provider: TokenProvider): void;
setAccessToken(token: string): void;
getAccessToken(): Promise<string | undefined>;
getRequestOptions(): RequestInit | undefined;
getGlobalRequestArgOptions(): Pick<RequestArgs, "catchNotFound"> | undefined;
setConfig(connectionConfig: ConnectionConfig): void;
}

View File

@ -0,0 +1,112 @@
import { AttackDetection } from "./resources/attackDetection.js";
import { AuthenticationManagement } from "./resources/authenticationManagement.js";
import { Cache } from "./resources/cache.js";
import { ClientPolicies } from "./resources/clientPolicies.js";
import { Clients } from "./resources/clients.js";
import { ClientScopes } from "./resources/clientScopes.js";
import { Components } from "./resources/components.js";
import { Groups } from "./resources/groups.js";
import { IdentityProviders } from "./resources/identityProviders.js";
import { Realms } from "./resources/realms.js";
import { Organizations } from "./resources/organizations.js";
import { Roles } from "./resources/roles.js";
import { ServerInfo } from "./resources/serverInfo.js";
import { Users } from "./resources/users.js";
import { UserStorageProvider } from "./resources/userStorageProvider.js";
import { WhoAmI } from "./resources/whoAmI.js";
import { getToken } from "./utils/auth.js";
import { defaultBaseUrl, defaultRealm } from "./utils/constants.js";
export class KeycloakAdminClient {
// Resources
users;
userStorageProvider;
groups;
roles;
organizations;
clients;
realms;
clientScopes;
clientPolicies;
identityProviders;
components;
serverInfo;
whoAmI;
attackDetection;
authenticationManagement;
cache;
// Members
baseUrl;
realmName;
scope;
accessToken;
refreshToken;
#requestOptions;
#globalRequestArgOptions;
#tokenProvider;
constructor(connectionConfig) {
this.baseUrl = connectionConfig?.baseUrl || defaultBaseUrl;
this.realmName = connectionConfig?.realmName || defaultRealm;
this.#requestOptions = connectionConfig?.requestOptions;
this.#globalRequestArgOptions = connectionConfig?.requestArgOptions;
// Initialize resources
this.users = new Users(this);
this.userStorageProvider = new UserStorageProvider(this);
this.groups = new Groups(this);
this.roles = new Roles(this);
this.organizations = new Organizations(this);
this.clients = new Clients(this);
this.realms = new Realms(this);
this.clientScopes = new ClientScopes(this);
this.clientPolicies = new ClientPolicies(this);
this.identityProviders = new IdentityProviders(this);
this.components = new Components(this);
this.authenticationManagement = new AuthenticationManagement(this);
this.serverInfo = new ServerInfo(this);
this.whoAmI = new WhoAmI(this);
this.attackDetection = new AttackDetection(this);
this.cache = new Cache(this);
}
async auth(credentials) {
const { accessToken, refreshToken } = await getToken({
baseUrl: this.baseUrl,
realmName: this.realmName,
scope: this.scope,
credentials,
requestOptions: this.#requestOptions,
});
this.accessToken = accessToken;
this.refreshToken = refreshToken;
}
registerTokenProvider(provider) {
if (this.#tokenProvider) {
throw new Error("An existing token provider was already registered.");
}
this.#tokenProvider = provider;
}
setAccessToken(token) {
this.accessToken = token;
}
async getAccessToken() {
if (this.#tokenProvider) {
return this.#tokenProvider.getAccessToken();
}
return this.accessToken;
}
getRequestOptions() {
return this.#requestOptions;
}
getGlobalRequestArgOptions() {
return this.#globalRequestArgOptions;
}
setConfig(connectionConfig) {
if (typeof connectionConfig.baseUrl === "string" &&
connectionConfig.baseUrl) {
this.baseUrl = connectionConfig.baseUrl;
}
if (typeof connectionConfig.realmName === "string" &&
connectionConfig.realmName) {
this.realmName = connectionConfig.realmName;
}
this.#requestOptions = connectionConfig.requestOptions;
}
}

View File

@ -0,0 +1,4 @@
export default interface AccessTokenAccess {
roles?: string[];
verify_caller?: boolean;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
export default interface PermissionRepresentation {
claims?: {
[index: string]: string;
};
rsid?: string;
rsname?: string;
scopes?: string[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,3 @@
export default interface AccessTokenCertConf {
"x5t#S256"?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,51 @@
import type AccessTokenAccess from "./AccessTokenAccess.js";
import type AccessTokenCertConf from "./accessTokenCertConf.js";
import type AddressClaimSet from "./addressClaimSet.js";
import type { Category } from "./resourceServerRepresentation.js";
export default interface AccessTokenRepresentation {
acr?: string;
address?: AddressClaimSet;
"allowed-origins"?: string[];
at_hash?: string;
auth_time?: number;
authorization?: AccessTokenRepresentation;
azp?: string;
birthdate?: string;
c_hash?: string;
category?: Category;
claims_locales?: string;
cnf?: AccessTokenCertConf;
email?: string;
email_verified?: boolean;
exp?: number;
family_name?: string;
gender: string;
given_name?: string;
iat?: number;
iss?: string;
jti?: string;
locale?: string;
middle_name?: string;
name?: string;
nbf?: number;
nickname?: string;
nonce?: string;
otherClaims?: {
[index: string]: string;
};
phone_number?: string;
phone_number_verified?: boolean;
picture?: string;
preferred_username?: string;
profile?: string;
realm_access?: AccessTokenAccess;
s_hash?: string;
scope?: string;
session_state?: string;
sub?: string;
"trusted-certs"?: string[];
typ?: string;
updated_at?: number;
website?: string;
zoneinfo?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
export default interface AddressClaimSet {
country?: string;
formatted?: string;
locality?: string;
postal_code?: string;
region?: string;
street_address?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,12 @@
import type AuthDetailsRepresentation from "./authDetailsRepresentation.js";
export default interface AdminEventRepresentation {
authDetails?: AuthDetailsRepresentation;
error?: string;
operationType?: string;
realmId?: string;
representation?: string;
resourcePath?: string;
resourceType?: string;
time?: number;
details?: Record<string, any>;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,6 @@
export default interface AuthDetailsRepresentation {
clientId?: string;
ipAddress?: string;
realmId?: string;
userId?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,12 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticationexecutionexportrepresentation
*/
export default interface AuthenticationExecutionExportRepresentation {
flowAlias?: string;
userSetupAllowed?: boolean;
authenticatorConfig?: string;
authenticator?: string;
requirement?: string;
priority?: number;
autheticatorFlow?: boolean;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,18 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticationexecutioninforepresentation
*/
export default interface AuthenticationExecutionInfoRepresentation {
id?: string;
requirement?: string;
displayName?: string;
alias?: string;
description?: string;
requirementChoices?: string[];
configurable?: boolean;
authenticationFlow?: boolean;
providerId?: string;
authenticationConfig?: string;
flowId?: string;
level?: number;
index?: number;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,13 @@
import type AuthenticationExecutionExportRepresentation from "./authenticationExecutionExportRepresentation.js";
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticationflowrepresentation
*/
export default interface AuthenticationFlowRepresentation {
id?: string;
alias?: string;
description?: string;
providerId?: string;
topLevel?: boolean;
builtIn?: boolean;
authenticationExecutions?: AuthenticationExecutionExportRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,20 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticatorconfiginforepresentation
*/
export default interface AuthenticatorConfigInfoRepresentation {
name?: string;
providerId?: string;
helpText?: string;
properties?: ConfigPropertyRepresentation[];
}
export interface ConfigPropertyRepresentation {
name?: string;
label?: string;
helpText?: string;
type?: string;
defaultValue?: any;
options?: string[];
secret?: boolean;
required?: boolean;
placeholder?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,16 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_authenticatorconfigrepresentation
*/
export default interface AuthenticatorConfigRepresentation {
id?: string;
alias?: string;
config?: {
[index: string]: string;
};
}
export interface AuthenticationProviderRepresentation {
id?: string;
displayName?: string;
description?: string;
supportsSecret?: boolean;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,9 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/#_certificaterepresentation
*/
export default interface CertificateRepresentation {
privateKey?: string;
publicKey?: string;
certificate?: string;
kid?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,11 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_clientinitialaccesspresentation
*/
export default interface ClientInitialAccessPresentation {
id?: string;
token?: string;
timestamp?: number;
expiration?: number;
count?: number;
remainingCount?: number;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
import type ClientPolicyRepresentation from "./clientPolicyRepresentation.js";
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpoliciesrepresentation
*/
export default interface ClientPoliciesRepresentation {
globalPolicies?: ClientPolicyRepresentation[];
policies?: ClientPolicyRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,7 @@
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpolicyconditionrepresentation
*/
export default interface ClientPolicyConditionRepresentation {
condition?: string;
configuration?: object;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,7 @@
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpolicyexecutorrepresentation
*/
export default interface ClientPolicyExecutorRepresentation {
configuration?: object;
executor?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,11 @@
import type ClientPolicyConditionRepresentation from "./clientPolicyConditionRepresentation.js";
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientpolicyrepresentation
*/
export default interface ClientPolicyRepresentation {
conditions?: ClientPolicyConditionRepresentation[];
description?: string;
enabled?: boolean;
name?: string;
profiles?: string[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,9 @@
import type ClientPolicyExecutorRepresentation from "./clientPolicyExecutorRepresentation.js";
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientprofilerepresentation
*/
export default interface ClientProfileRepresentation {
description?: string;
executors?: ClientPolicyExecutorRepresentation[];
name?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
import type ClientProfileRepresentation from "./clientProfileRepresentation.js";
/**
* https://www.keycloak.org/docs-api/15.0/rest-api/#_clientprofilesrepresentation
*/
export default interface ClientProfilesRepresentation {
globalProfiles?: ClientProfileRepresentation[];
profiles?: ClientProfileRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,45 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_clientrepresentation
*/
import type ResourceServerRepresentation from "./resourceServerRepresentation.js";
import type ProtocolMapperRepresentation from "./protocolMapperRepresentation.js";
export default interface ClientRepresentation {
access?: Record<string, boolean>;
adminUrl?: string;
attributes?: Record<string, any>;
authenticationFlowBindingOverrides?: Record<string, any>;
authorizationServicesEnabled?: boolean;
authorizationSettings?: ResourceServerRepresentation;
baseUrl?: string;
bearerOnly?: boolean;
clientAuthenticatorType?: string;
clientId?: string;
consentRequired?: boolean;
defaultClientScopes?: string[];
defaultRoles?: string[];
description?: string;
directAccessGrantsEnabled?: boolean;
enabled?: boolean;
alwaysDisplayInConsole?: boolean;
frontchannelLogout?: boolean;
fullScopeAllowed?: boolean;
id?: string;
implicitFlowEnabled?: boolean;
name?: string;
nodeReRegistrationTimeout?: number;
notBefore?: number;
optionalClientScopes?: string[];
origin?: string;
protocol?: string;
protocolMappers?: ProtocolMapperRepresentation[];
publicClient?: boolean;
redirectUris?: string[];
registeredNodes?: Record<string, any>;
registrationAccessToken?: string;
rootUrl?: string;
secret?: string;
serviceAccountsEnabled?: boolean;
standardFlowEnabled?: boolean;
surrogateAuthRequired?: boolean;
webOrigins?: string[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,12 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_clientscoperepresentation
*/
import type ProtocolMapperRepresentation from "./protocolMapperRepresentation.js";
export default interface ClientScopeRepresentation {
attributes?: Record<string, any>;
description?: string;
id?: string;
name?: string;
protocol?: string;
protocolMappers?: ProtocolMapperRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,6 @@
export interface ClientSessionStat {
id: string;
clientId: string;
active: string;
offline: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,15 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componentexportrepresentation
*/
export default interface ComponentExportRepresentation {
id?: string;
name?: string;
providerId?: string;
subType?: string;
subComponents?: {
[index: string]: ComponentExportRepresentation;
};
config?: {
[index: string]: string;
};
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componentexportrepresentation
*/
export {};

View File

@ -0,0 +1,14 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componentrepresentation
*/
export default interface ComponentRepresentation {
id?: string;
name?: string;
providerId?: string;
providerType?: string;
parentId?: string;
subType?: string;
config?: {
[index: string]: string | string[];
};
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componentrepresentation
*/
export {};

View File

@ -0,0 +1,12 @@
import type { ConfigPropertyRepresentation } from "./configPropertyRepresentation.js";
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_componenttyperepresentation
*/
export default interface ComponentTypeRepresentation {
id: string;
helpText: string;
properties: ConfigPropertyRepresentation[];
metadata: {
[index: string]: any;
};
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,13 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_configpropertyrepresentation
*/
export interface ConfigPropertyRepresentation {
name?: string;
label?: string;
helpText?: string;
type?: string;
defaultValue?: object;
options?: string[];
secret?: boolean;
required?: boolean;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,15 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_credentialrepresentation
*/
export default interface CredentialRepresentation {
createdDate?: number;
credentialData?: string;
id?: string;
priority?: number;
secretData?: string;
temporary?: boolean;
type?: string;
userLabel?: string;
value?: string;
federationLink?: string;
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_credentialrepresentation
*/
export {};

View File

@ -0,0 +1,5 @@
export default interface EffectiveMessageBundleRepresentation {
key: string;
value: string;
source: "THEME" | "REALM";
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,12 @@
import type { DecisionEffect } from "./policyRepresentation.js";
import type PolicyResultRepresentation from "./policyResultRepresentation.js";
import type ResourceRepresentation from "./resourceRepresentation.js";
import type ScopeRepresentation from "./scopeRepresentation.js";
export default interface EvaluationResultRepresentation {
resource?: ResourceRepresentation;
scopes?: ScopeRepresentation[];
policies?: PolicyResultRepresentation[];
status?: DecisionEffect;
allowedScopes?: ScopeRepresentation[];
deniedScopes?: ScopeRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,15 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_eventrepresentation
*/
import type EventType from "./eventTypes.js";
export default interface EventRepresentation {
clientId?: string;
details?: Record<string, any>;
error?: string;
ipAddress?: string;
realmId?: string;
sessionId?: string;
time?: number;
type?: EventType;
userId?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,2 @@
type EventType = "LOGIN" | "LOGIN_ERROR" | "REGISTER" | "REGISTER_ERROR" | "LOGOUT" | "LOGOUT_ERROR" | "CODE_TO_TOKEN" | "CODE_TO_TOKEN_ERROR" | "CLIENT_LOGIN" | "CLIENT_LOGIN_ERROR" | "REFRESH_TOKEN" | "REFRESH_TOKEN_ERROR" | "VALIDATE_ACCESS_TOKEN" | "VALIDATE_ACCESS_TOKEN_ERROR" | "INTROSPECT_TOKEN" | "INTROSPECT_TOKEN_ERROR" | "FEDERATED_IDENTITY_LINK" | "FEDERATED_IDENTITY_LINK_ERROR" | "REMOVE_FEDERATED_IDENTITY" | "REMOVE_FEDERATED_IDENTITY_ERROR" | "UPDATE_EMAIL" | "UPDATE_EMAIL_ERROR" | "UPDATE_PROFILE" | "UPDATE_PROFILE_ERROR" | "UPDATE_PASSWORD" | "UPDATE_PASSWORD_ERROR" | "UPDATE_TOTP" | "UPDATE_TOTP_ERROR" | "VERIFY_EMAIL" | "VERIFY_EMAIL_ERROR" | "REMOVE_TOTP" | "REMOVE_TOTP_ERROR" | "REVOKE_GRANT" | "REVOKE_GRANT_ERROR" | "SEND_VERIFY_EMAIL" | "SEND_VERIFY_EMAIL_ERROR" | "SEND_RESET_PASSWORD" | "SEND_RESET_PASSWORD_ERROR" | "SEND_IDENTITY_PROVIDER_LINK" | "SEND_IDENTITY_PROVIDER_LINK_ERROR" | "RESET_PASSWORD" | "RESET_PASSWORD_ERROR" | "RESTART_AUTHENTICATION" | "RESTART_AUTHENTICATION_ERROR" | "INVALID_SIGNATURE" | "INVALID_SIGNATURE_ERROR" | "REGISTER_NODE" | "REGISTER_NODE_ERROR" | "UNREGISTER_NODE" | "UNREGISTER_NODE_ERROR" | "USER_INFO_REQUEST" | "USER_INFO_REQUEST_ERROR" | "IDENTITY_PROVIDER_LINK_ACCOUNT" | "IDENTITY_PROVIDER_LINK_ACCOUNT_ERROR" | "IDENTITY_PROVIDER_LOGIN" | "IDENTITY_PROVIDER_LOGIN_ERROR" | "IDENTITY_PROVIDER_FIRST_LOGIN" | "IDENTITY_PROVIDER_FIRST_LOGIN_ERROR" | "IDENTITY_PROVIDER_POST_LOGIN" | "IDENTITY_PROVIDER_POST_LOGIN_ERROR" | "IDENTITY_PROVIDER_RESPONSE" | "IDENTITY_PROVIDER_RESPONSE_ERROR" | "IDENTITY_PROVIDER_RETRIEVE_TOKEN" | "IDENTITY_PROVIDER_RETRIEVE_TOKEN_ERROR" | "IMPERSONATE" | "IMPERSONATE_ERROR" | "CUSTOM_REQUIRED_ACTION" | "CUSTOM_REQUIRED_ACTION_ERROR" | "EXECUTE_ACTIONS" | "EXECUTE_ACTIONS_ERROR" | "EXECUTE_ACTION_TOKEN" | "EXECUTE_ACTION_TOKEN_ERROR" | "CLIENT_INFO" | "CLIENT_INFO_ERROR" | "CLIENT_REGISTER" | "CLIENT_REGISTER_ERROR" | "CLIENT_UPDATE" | "CLIENT_UPDATE_ERROR" | "CLIENT_DELETE" | "CLIENT_DELETE_ERROR" | "CLIENT_INITIATED_ACCOUNT_LINKING" | "CLIENT_INITIATED_ACCOUNT_LINKING_ERROR" | "TOKEN_EXCHANGE" | "TOKEN_EXCHANGE_ERROR" | "PERMISSION_TOKEN" | "PERMISSION_TOKEN_ERROR" | "UPDATE_CREDENTIAL" | "UPDATE_CREDENTIAL_ERROR" | "REMOVE_CREDENTIAL" | "REMOVE_CREDENTIAL_ERROR";
export default EventType;

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,15 @@
export default interface FeatureRepresentation {
name: string;
label: string;
type: FeatureType;
enabled: boolean;
dependencies: string[];
}
export declare enum FeatureType {
Default = "DEFAULT",
DisabledByDefault = "DISABLED_BY_DEFAULT",
Preview = "PREVIEW",
PreviewDisabledByDefault = "PREVIEW_DISABLED_BY_DEFAULT",
Experimental = "EXPERIMENTAL",
Deprecated = "DEPRECATED"
}

View File

@ -0,0 +1,9 @@
export var FeatureType;
(function (FeatureType) {
FeatureType["Default"] = "DEFAULT";
FeatureType["DisabledByDefault"] = "DISABLED_BY_DEFAULT";
FeatureType["Preview"] = "PREVIEW";
FeatureType["PreviewDisabledByDefault"] = "PREVIEW_DISABLED_BY_DEFAULT";
FeatureType["Experimental"] = "EXPERIMENTAL";
FeatureType["Deprecated"] = "DEPRECATED";
})(FeatureType || (FeatureType = {}));

View File

@ -0,0 +1,8 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_federatedidentityrepresentation
*/
export default interface FederatedIdentityRepresentation {
identityProvider?: string;
userId?: string;
userName?: string;
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_federatedidentityrepresentation
*/
export {};

View File

@ -0,0 +1,7 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_globalrequestresult
*/
export default interface GlobalRequestResult {
successRequests?: string[];
failedRequests?: string[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,14 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_grouprepresentation
*/
export default interface GroupRepresentation {
id?: string;
name?: string;
path?: string;
subGroupCount?: number;
subGroups?: GroupRepresentation[];
access?: Record<string, boolean>;
attributes?: Record<string, any>;
clientRoles?: Record<string, any>;
realmRoles?: string[];
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_grouprepresentation
*/
export {};

View File

@ -0,0 +1,10 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_identityprovidermapperrepresentation
*/
export default interface IdentityProviderMapperRepresentation {
config?: any;
id?: string;
identityProviderAlias?: string;
identityProviderMapper?: string;
name?: string;
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_identityprovidermapperrepresentation
*/
export {};

View File

@ -0,0 +1,8 @@
import type { ConfigPropertyRepresentation } from "./configPropertyRepresentation.js";
export interface IdentityProviderMapperTypeRepresentation {
id?: string;
name?: string;
category?: string;
helpText?: string;
properties?: ConfigPropertyRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,19 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_identityproviderrepresentation
*/
export default interface IdentityProviderRepresentation {
addReadTokenRoleOnCreate?: boolean;
alias?: string;
config?: Record<string, any>;
displayName?: string;
enabled?: boolean;
firstBrokerLoginFlowAlias?: string;
internalId?: string;
linkOnly?: boolean;
hideOnLogin?: boolean;
postBrokerLoginFlowAlias?: string;
providerId?: string;
storeToken?: boolean;
trustEmail?: boolean;
organizationId?: string;
}

View File

@ -0,0 +1,4 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_identityproviderrepresentation
*/
export {};

View File

@ -0,0 +1,20 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_keysmetadatarepresentation-keymetadatarepresentation
*/
export default interface KeysMetadataRepresentation {
active?: {
[index: string]: string;
};
keys?: KeyMetadataRepresentation[];
}
export interface KeyMetadataRepresentation {
providerId?: string;
providerPriority?: number;
kid?: string;
status?: string;
type?: string;
algorithm?: string;
publicKey?: string;
certificate?: string;
validTo?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,11 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/#_keystoreconfig
*/
export default interface KeyStoreConfig {
realmCertificate?: boolean;
storePassword?: string;
keyPassword?: string;
keyAlias?: string;
realmAlias?: string;
format?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,5 @@
export interface ManagementPermissionReference {
enabled?: boolean;
resource?: string;
scopePermissions?: Record<string, string>;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_mappingsrepresentation
*/
import type RoleRepresentation from "./roleRepresentation.js";
export default interface MappingsRepresentation {
clientMappings?: Record<string, any>;
realmMappings?: RoleRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,4 @@
import type UserRepresentation from "./userRepresentation.js";
export default interface MemberRepresentation extends UserRepresentation {
membershipType?: string;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,4 @@
export default interface OrganizationDomainRepresentation {
name?: string;
verified?: boolean;
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,15 @@
import type OrganizationDomainRepresentation from "./organizationDomainRepresentation.js";
import type IdentityProviderRepresentation from "./identityProviderRepresentation.js";
import type MemberRepresentation from "./memberRepresentation.js";
export default interface OrganizationRepresentation {
id?: string;
name?: string;
alias?: string;
description?: string;
redirectUrl?: string;
enabled?: boolean;
attributes?: Record<string, string[]>;
domains?: OrganizationDomainRepresentation[];
members?: MemberRepresentation[];
identityProviders?: IdentityProviderRepresentation[];
}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,10 @@
/**
* https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_passwordpolicytyperepresentation
*/
export default interface PasswordPolicyTypeRepresentation {
id?: string;
displayName?: string;
configType?: string;
defaultValue?: string;
multipleSupported?: boolean;
}

Some files were not shown because too many files have changed in this diff Show More