keycloak-admin 1.1.4 → 1.1.6
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.
- checksums.yaml +4 -4
- data/.github/workflows/Dockerfile +24 -24
- data/.github/workflows/ci.yml +80 -80
- data/.gitignore +9 -9
- data/.rspec +2 -2
- data/CHANGELOG.md +23 -0
- data/Dockerfile +12 -12
- data/Gemfile +3 -3
- data/Gemfile.lock +1 -1
- data/MIT-LICENSE +20 -20
- data/README.md +20 -1
- data/bin/console +9 -9
- data/keycloak-admin.gemspec +24 -24
- data/lib/keycloak-admin/client/attack_detection_client.rb +41 -41
- data/lib/keycloak-admin/client/client.rb +56 -56
- data/lib/keycloak-admin/client/client_authz_permission_client.rb +80 -80
- data/lib/keycloak-admin/client/client_authz_policy_client.rb +75 -75
- data/lib/keycloak-admin/client/client_authz_resource_client.rb +92 -92
- data/lib/keycloak-admin/client/client_authz_scope_client.rb +70 -70
- data/lib/keycloak-admin/client/client_client.rb +71 -71
- data/lib/keycloak-admin/client/client_role_client.rb +20 -20
- data/lib/keycloak-admin/client/client_role_mappings_client.rb +32 -32
- data/lib/keycloak-admin/client/configurable_token_client.rb +35 -35
- data/lib/keycloak-admin/client/group_client.rb +148 -148
- data/lib/keycloak-admin/client/identity_provider_client.rb +51 -51
- data/lib/keycloak-admin/client/organization_client.rb +245 -0
- data/lib/keycloak-admin/client/realm_client.rb +126 -122
- data/lib/keycloak-admin/client/role_client.rb +59 -59
- data/lib/keycloak-admin/client/role_mapper_client.rb +47 -47
- data/lib/keycloak-admin/client/token_client.rb +29 -29
- data/lib/keycloak-admin/client/user_client.rb +278 -266
- data/lib/keycloak-admin/configuration.rb +52 -52
- data/lib/keycloak-admin/representation/attack_detection_representation.rb +17 -17
- data/lib/keycloak-admin/representation/camel_json.rb +12 -12
- data/lib/keycloak-admin/representation/client_authz_permission_representation.rb +33 -33
- data/lib/keycloak-admin/representation/client_authz_policy_config_representation.rb +14 -14
- data/lib/keycloak-admin/representation/client_authz_policy_representation.rb +26 -26
- data/lib/keycloak-admin/representation/client_authz_resource_representation.rb +25 -25
- data/lib/keycloak-admin/representation/client_authz_scope_representation.rb +16 -16
- data/lib/keycloak-admin/representation/client_representation.rb +71 -71
- data/lib/keycloak-admin/representation/credential_representation.rb +71 -38
- data/lib/keycloak-admin/representation/federated_identity_representation.rb +15 -15
- data/lib/keycloak-admin/representation/group_representation.rb +21 -21
- data/lib/keycloak-admin/representation/identity_provider_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/identity_provider_representation.rb +71 -67
- data/lib/keycloak-admin/representation/impersonation_redirection_representation.rb +16 -16
- data/lib/keycloak-admin/representation/impersonation_representation.rb +43 -43
- data/lib/keycloak-admin/representation/member_representation.rb +11 -0
- data/lib/keycloak-admin/representation/organization_domain_representation.rb +18 -0
- data/lib/keycloak-admin/representation/organization_representation.rb +30 -0
- data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +19 -19
- data/lib/keycloak-admin/representation/realm_representation.rb +14 -14
- data/lib/keycloak-admin/representation/representation.rb +23 -23
- data/lib/keycloak-admin/representation/role_representation.rb +19 -19
- data/lib/keycloak-admin/representation/session_representation.rb +22 -22
- data/lib/keycloak-admin/representation/token_representation.rb +39 -39
- data/lib/keycloak-admin/representation/user_representation.rb +47 -47
- data/lib/keycloak-admin/resource/base_role_containing_resource.rb +28 -28
- data/lib/keycloak-admin/resource/group_resource.rb +11 -11
- data/lib/keycloak-admin/resource/user_resource.rb +7 -7
- data/lib/keycloak-admin/version.rb +3 -3
- data/lib/keycloak-admin.rb +88 -84
- data/spec/client/attack_detection_client_spec.rb +102 -102
- data/spec/client/client_authz_permission_client_spec.rb +170 -170
- data/spec/client/client_authz_policy_client_spec.rb +169 -169
- data/spec/client/client_authz_resource_client_spec.rb +150 -150
- data/spec/client/client_authz_scope_client_spec.rb +133 -133
- data/spec/client/client_client_spec.rb +133 -133
- data/spec/client/client_role_mappings_client_spec.rb +82 -82
- data/spec/client/client_spec.rb +28 -28
- data/spec/client/configurable_token_client_spec.rb +34 -34
- data/spec/client/group_client_spec.rb +328 -328
- data/spec/client/identity_provider_client_spec.rb +92 -92
- data/spec/client/organization_client_spec.rb +595 -0
- data/spec/client/realm_client_spec.rb +155 -155
- data/spec/client/role_client_spec.rb +79 -79
- data/spec/client/role_mapper_client_spec.rb +113 -113
- data/spec/client/token_client_spec.rb +68 -68
- data/spec/client/user_client_spec.rb +418 -373
- data/spec/configuration_spec.rb +113 -113
- data/spec/integration/client_authorization_spec.rb +93 -93
- data/spec/representation/attack_detection_representation_spec.rb +15 -15
- data/spec/representation/client_authz_permission_representation_spec.rb +52 -52
- data/spec/representation/client_authz_policy_representation_spec.rb +46 -46
- data/spec/representation/client_authz_resource_representation_spec.rb +33 -33
- data/spec/representation/client_authz_scope_representation_spec.rb +18 -18
- data/spec/representation/client_representation_spec.rb +119 -119
- data/spec/representation/credential_representation_spec.rb +68 -0
- data/spec/representation/group_representation_spec.rb +22 -22
- data/spec/representation/identity_provider_mapper_representation_spec.rb +24 -24
- data/spec/representation/identity_provider_representation_spec.rb +113 -113
- data/spec/representation/impersonation_representation_spec.rb +163 -163
- data/spec/representation/organization_representation_spec.rb +64 -0
- data/spec/representation/protocol_mapper_representation_spec.rb +57 -57
- data/spec/representation/role_representation_spec.rb +37 -37
- data/spec/representation/session_representation_spec.rb +15 -15
- data/spec/representation/user_representation_spec.rb +15 -15
- data/spec/resource/group_resource_spec.rb +14 -14
- data/spec/resource/user_resource_spec.rb +14 -14
- data/spec/spec_helper.rb +37 -37
- metadata +13 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db97e606c0a299c2daff7be37a2df4a1c2a7261d2430b62dd196b8d29dc9117d
|
|
4
|
+
data.tar.gz: a1581e41e26b30d576273036ccf87abf463db0e4a80cd1f3a0961b87f874c373
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33416a0ad66f8f054a2192f560fbd72d6d68d1a29101521d8bfa2be5bd705888f46740d325ee265ef0e983bbd611901e7902db2a14f5693bd066c250692bb417
|
|
7
|
+
data.tar.gz: 6e17f0a84457d4bf8ce7332b756b0892fbe51a606a8895e5434fca458d9b936594006057820fb3e753d1713b5fdd895fe546f82f90a60fea948f3065e4905bed
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
### Dockerfile for: tillawy/keycloak-github-actions
|
|
2
|
-
##
|
|
3
|
-
## To build & push
|
|
4
|
-
# docker buildx build . --platform linux/amd64 -t tillawy/keycloak-github-actions:25.0.1
|
|
5
|
-
# docker push tillawy/keycloak-github-actions:25.0.1
|
|
6
|
-
#
|
|
7
|
-
## To Run Locally
|
|
8
|
-
# docker run \
|
|
9
|
-
# --rm \
|
|
10
|
-
# -p 8080:8080 \
|
|
11
|
-
# -e KEYCLOAK_ADMIN="admin" \
|
|
12
|
-
# -e KEYCLOAK_ADMIN_PASSWORD="admin" \
|
|
13
|
-
# -e KC_HOSTNAME="http://localhost:8080" \
|
|
14
|
-
# -e KC_HOSTNAME_ADMIN="http://localhost:8080" \
|
|
15
|
-
# -e KC_HTTP_ENABLED="true" \
|
|
16
|
-
# -e KC_DB="dev-file" \
|
|
17
|
-
# tillawy/keycloak-github-actions:25.0.1
|
|
18
|
-
|
|
19
|
-
FROM quay.io/keycloak/keycloak:25.0.1
|
|
20
|
-
|
|
21
|
-
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
|
|
22
|
-
|
|
23
|
-
CMD ["start-dev", "--hostname=http://localhost:8080" , "--hostname-admin=http://localhost:8080" , "--http-enabled=true", "--verbose"]
|
|
24
|
-
|
|
1
|
+
### Dockerfile for: tillawy/keycloak-github-actions
|
|
2
|
+
##
|
|
3
|
+
## To build & push
|
|
4
|
+
# docker buildx build . --platform linux/amd64 -t tillawy/keycloak-github-actions:25.0.1
|
|
5
|
+
# docker push tillawy/keycloak-github-actions:25.0.1
|
|
6
|
+
#
|
|
7
|
+
## To Run Locally
|
|
8
|
+
# docker run \
|
|
9
|
+
# --rm \
|
|
10
|
+
# -p 8080:8080 \
|
|
11
|
+
# -e KEYCLOAK_ADMIN="admin" \
|
|
12
|
+
# -e KEYCLOAK_ADMIN_PASSWORD="admin" \
|
|
13
|
+
# -e KC_HOSTNAME="http://localhost:8080" \
|
|
14
|
+
# -e KC_HOSTNAME_ADMIN="http://localhost:8080" \
|
|
15
|
+
# -e KC_HTTP_ENABLED="true" \
|
|
16
|
+
# -e KC_DB="dev-file" \
|
|
17
|
+
# tillawy/keycloak-github-actions:25.0.1
|
|
18
|
+
|
|
19
|
+
FROM quay.io/keycloak/keycloak:25.0.1
|
|
20
|
+
|
|
21
|
+
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
|
|
22
|
+
|
|
23
|
+
CMD ["start-dev", "--hostname=http://localhost:8080" , "--hostname-admin=http://localhost:8080" , "--http-enabled=true", "--verbose"]
|
|
24
|
+
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
-
# They are provided by a third-party and are governed by
|
|
3
|
-
# separate terms of service, privacy policy, and support
|
|
4
|
-
# documentation.
|
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
-
|
|
8
|
-
name: Ruby
|
|
9
|
-
|
|
10
|
-
on:
|
|
11
|
-
push:
|
|
12
|
-
branches: [ "main" ]
|
|
13
|
-
pull_request:
|
|
14
|
-
branches: [ "main" ]
|
|
15
|
-
|
|
16
|
-
permissions:
|
|
17
|
-
contents: read
|
|
18
|
-
|
|
19
|
-
jobs:
|
|
20
|
-
test:
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
services:
|
|
23
|
-
keycloak:
|
|
24
|
-
image: tillawy/keycloak-github-actions:25.0.1
|
|
25
|
-
ports:
|
|
26
|
-
- 8080:8080
|
|
27
|
-
options: '--health-cmd "exec 3<>/dev/tcp/localhost/8080" --health-interval 5s --health-timeout 5s --health-retries 10 --health-start-period 100s'
|
|
28
|
-
env:
|
|
29
|
-
KEYCLOAK_ADMIN: "admin"
|
|
30
|
-
KEYCLOAK_ADMIN_PASSWORD: "admin"
|
|
31
|
-
KC_HOSTNAME: "http://localhost:8080"
|
|
32
|
-
KC_HOSTNAME_ADMIN: "http://localhost:8080"
|
|
33
|
-
KC_HTTP_ENABLED: "true"
|
|
34
|
-
KC_DB: "dev-file"
|
|
35
|
-
|
|
36
|
-
strategy:
|
|
37
|
-
matrix:
|
|
38
|
-
ruby-version: ['3.2']
|
|
39
|
-
|
|
40
|
-
steps:
|
|
41
|
-
- name: create realm
|
|
42
|
-
run: |
|
|
43
|
-
TOKEN=$(curl --silent --location --request POST "http://localhost:8080/realms/master/protocol/openid-connect/token" \
|
|
44
|
-
--header 'Content-Type: application/x-www-form-urlencoded' \
|
|
45
|
-
--data-urlencode 'grant_type=password' \
|
|
46
|
-
--data-urlencode 'username=admin' \
|
|
47
|
-
--data-urlencode 'password=admin' \
|
|
48
|
-
--data-urlencode 'client_id=admin-cli' | jq -r '.access_token')
|
|
49
|
-
|
|
50
|
-
curl --silent --show-error -L -X POST "http://localhost:8080/admin/realms" \
|
|
51
|
-
--header "Content-Type: application/json" \
|
|
52
|
-
--header "Authorization: Bearer ${TOKEN}" \
|
|
53
|
-
--data '{"realm":"dummy","enabled":true}'
|
|
54
|
-
|
|
55
|
-
curl --silent --show-error --request POST 'http://localhost:8080/admin/realms/dummy/clients' \
|
|
56
|
-
--header 'Authorization: Bearer '$TOKEN \
|
|
57
|
-
--header 'Content-Type: application/json' \
|
|
58
|
-
--data-raw '{
|
|
59
|
-
"clientId":"dummy-client",
|
|
60
|
-
"enabled":true,
|
|
61
|
-
"consentRequired": false,
|
|
62
|
-
"attributes":{},
|
|
63
|
-
"serviceAccountsEnabled": true,
|
|
64
|
-
"protocol":"openid-connect",
|
|
65
|
-
"publicClient":false,
|
|
66
|
-
"authorizationServicesEnabled": true,
|
|
67
|
-
"clientAuthenticatorType":"client-secret",
|
|
68
|
-
"redirectUris":["http://localhost:8180/demo"]
|
|
69
|
-
}'
|
|
70
|
-
|
|
71
|
-
- uses: actions/checkout@v4
|
|
72
|
-
- name: Set up Ruby
|
|
73
|
-
uses: ruby/setup-ruby@v1
|
|
74
|
-
with:
|
|
75
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
76
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
77
|
-
- name: Run tests
|
|
78
|
-
run: bundle exec rspec
|
|
79
|
-
env:
|
|
80
|
-
GITHUB_ACTIONS: true
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
2
|
+
# They are provided by a third-party and are governed by
|
|
3
|
+
# separate terms of service, privacy policy, and support
|
|
4
|
+
# documentation.
|
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
|
7
|
+
|
|
8
|
+
name: Ruby
|
|
9
|
+
|
|
10
|
+
on:
|
|
11
|
+
push:
|
|
12
|
+
branches: [ "main" ]
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [ "main" ]
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
test:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
services:
|
|
23
|
+
keycloak:
|
|
24
|
+
image: tillawy/keycloak-github-actions:25.0.1
|
|
25
|
+
ports:
|
|
26
|
+
- 8080:8080
|
|
27
|
+
options: '--health-cmd "exec 3<>/dev/tcp/localhost/8080" --health-interval 5s --health-timeout 5s --health-retries 10 --health-start-period 100s'
|
|
28
|
+
env:
|
|
29
|
+
KEYCLOAK_ADMIN: "admin"
|
|
30
|
+
KEYCLOAK_ADMIN_PASSWORD: "admin"
|
|
31
|
+
KC_HOSTNAME: "http://localhost:8080"
|
|
32
|
+
KC_HOSTNAME_ADMIN: "http://localhost:8080"
|
|
33
|
+
KC_HTTP_ENABLED: "true"
|
|
34
|
+
KC_DB: "dev-file"
|
|
35
|
+
|
|
36
|
+
strategy:
|
|
37
|
+
matrix:
|
|
38
|
+
ruby-version: ['3.2']
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- name: create realm
|
|
42
|
+
run: |
|
|
43
|
+
TOKEN=$(curl --silent --location --request POST "http://localhost:8080/realms/master/protocol/openid-connect/token" \
|
|
44
|
+
--header 'Content-Type: application/x-www-form-urlencoded' \
|
|
45
|
+
--data-urlencode 'grant_type=password' \
|
|
46
|
+
--data-urlencode 'username=admin' \
|
|
47
|
+
--data-urlencode 'password=admin' \
|
|
48
|
+
--data-urlencode 'client_id=admin-cli' | jq -r '.access_token')
|
|
49
|
+
|
|
50
|
+
curl --silent --show-error -L -X POST "http://localhost:8080/admin/realms" \
|
|
51
|
+
--header "Content-Type: application/json" \
|
|
52
|
+
--header "Authorization: Bearer ${TOKEN}" \
|
|
53
|
+
--data '{"realm":"dummy","enabled":true}'
|
|
54
|
+
|
|
55
|
+
curl --silent --show-error --request POST 'http://localhost:8080/admin/realms/dummy/clients' \
|
|
56
|
+
--header 'Authorization: Bearer '$TOKEN \
|
|
57
|
+
--header 'Content-Type: application/json' \
|
|
58
|
+
--data-raw '{
|
|
59
|
+
"clientId":"dummy-client",
|
|
60
|
+
"enabled":true,
|
|
61
|
+
"consentRequired": false,
|
|
62
|
+
"attributes":{},
|
|
63
|
+
"serviceAccountsEnabled": true,
|
|
64
|
+
"protocol":"openid-connect",
|
|
65
|
+
"publicClient":false,
|
|
66
|
+
"authorizationServicesEnabled": true,
|
|
67
|
+
"clientAuthenticatorType":"client-secret",
|
|
68
|
+
"redirectUris":["http://localhost:8180/demo"]
|
|
69
|
+
}'
|
|
70
|
+
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- name: Set up Ruby
|
|
73
|
+
uses: ruby/setup-ruby@v1
|
|
74
|
+
with:
|
|
75
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
76
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
77
|
+
- name: Run tests
|
|
78
|
+
run: bundle exec rspec
|
|
79
|
+
env:
|
|
80
|
+
GITHUB_ACTIONS: true
|
data/.gitignore
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
.bundle/
|
|
2
|
-
log/*.log
|
|
3
|
-
pkg/
|
|
4
|
-
test/dummy/db/*.sqlite3
|
|
5
|
-
test/dummy/db/*.sqlite3-journal
|
|
6
|
-
test/dummy/log/*.log
|
|
7
|
-
test/dummy/tmp/
|
|
8
|
-
*.gem
|
|
9
|
-
.idea/
|
|
1
|
+
.bundle/
|
|
2
|
+
log/*.log
|
|
3
|
+
pkg/
|
|
4
|
+
test/dummy/db/*.sqlite3
|
|
5
|
+
test/dummy/db/*.sqlite3-journal
|
|
6
|
+
test/dummy/log/*.log
|
|
7
|
+
test/dummy/tmp/
|
|
8
|
+
*.gem
|
|
9
|
+
.idea/
|
|
10
10
|
.byebug_history
|
data/.rspec
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
--color
|
|
2
|
-
--require spec_helper
|
|
1
|
+
--color
|
|
2
|
+
--require spec_helper
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.6] - 2026-01-05
|
|
9
|
+
|
|
10
|
+
* [Feature] Support for Organizations (Multi-tenancy):
|
|
11
|
+
* **Organization Management**:
|
|
12
|
+
* Supported operations: `create!`, `update`, `get`, `delete`, `list`, and `count`.
|
|
13
|
+
* Supported searching and filtering via `exact`, `query`, and `search` parameters.
|
|
14
|
+
* **Member Management**:
|
|
15
|
+
* Added ability to list organization members with pagination and filtering (`members`).
|
|
16
|
+
* Added `members_count` to retrieve the total number of members.
|
|
17
|
+
* Added `get_member`, `add_member` (by user ID), and `delete_member`.
|
|
18
|
+
* Added helper to find all organizations associated with a specific user: `associated_with_member`.
|
|
19
|
+
* **Invitations**:
|
|
20
|
+
* Added `invite_user`: Invites a new user via email/name.
|
|
21
|
+
* Added `invite_existing_user`: Invites an existing Keycloak user to the organization by ID.
|
|
22
|
+
* **Identity Provider (IdP) Linking**:
|
|
23
|
+
* Added methods to manage IdPs linked to an organization: `identity_providers`, `get_identity_provider`, `add_identity_provider`, and `delete_identity_provider`.
|
|
24
|
+
|
|
25
|
+
## [1.1.5] - 2026-01-05
|
|
26
|
+
|
|
27
|
+
* [Feature] Added the ability to list credentials for a given user.
|
|
28
|
+
* [Fix] Implemented safe parsing for nested JSON elements within `CredentialRepresentation` (handling both `credentialData` and `secretData` fields). Please refer to [the official documentation](https://www.keycloak.org/docs-api/latest/rest-api/index.html#CredentialRepresentation).
|
|
29
|
+
* [Breaking] Renamed `CredentialRepresentation` attribute `created_date` $\rightarrow$ `createdDate` to align with the Keycloak Admin API.
|
|
30
|
+
|
|
8
31
|
## [1.1.4] - 2025-11-08
|
|
9
32
|
|
|
10
33
|
* Add remove_realm_level_role_name! action on a GroupClient (thanks to @mkrawc)
|
data/Dockerfile
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
FROM ruby:3.2.2-slim-bullseye
|
|
2
|
-
|
|
3
|
-
RUN apt-get update -qq && apt-get install -y build-essential git ruby-dev && apt-get clean && \
|
|
4
|
-
mkdir -p /usr/src/app/lib/keycloak-admin
|
|
5
|
-
WORKDIR /usr/src/app
|
|
6
|
-
|
|
7
|
-
COPY Gemfile /usr/src/app/
|
|
8
|
-
COPY Gemfile.lock /usr/src/app/
|
|
9
|
-
COPY keycloak-admin.gemspec /usr/src/app/
|
|
10
|
-
COPY lib/keycloak-admin/version.rb /usr/src/app/lib/keycloak-admin/
|
|
11
|
-
RUN bundle install
|
|
12
|
-
COPY . /usr/src/app
|
|
1
|
+
FROM ruby:3.2.2-slim-bullseye
|
|
2
|
+
|
|
3
|
+
RUN apt-get update -qq && apt-get install -y build-essential git ruby-dev && apt-get clean && \
|
|
4
|
+
mkdir -p /usr/src/app/lib/keycloak-admin
|
|
5
|
+
WORKDIR /usr/src/app
|
|
6
|
+
|
|
7
|
+
COPY Gemfile /usr/src/app/
|
|
8
|
+
COPY Gemfile.lock /usr/src/app/
|
|
9
|
+
COPY keycloak-admin.gemspec /usr/src/app/
|
|
10
|
+
COPY lib/keycloak-admin/version.rb /usr/src/app/lib/keycloak-admin/
|
|
11
|
+
RUN bundle install
|
|
12
|
+
COPY . /usr/src/app
|
|
13
13
|
RUN bundle install
|
data/Gemfile
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
data/MIT-LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Copyright 2018
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright 2018
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -12,7 +12,7 @@ This gem *does not* require Rails.
|
|
|
12
12
|
For example, using `bundle`, add this line to your Gemfile.
|
|
13
13
|
|
|
14
14
|
```ruby
|
|
15
|
-
gem "keycloak-admin", "1.1.
|
|
15
|
+
gem "keycloak-admin", "1.1.6"
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Login
|
|
@@ -112,6 +112,7 @@ All options have a default value. However, all of them can be changed in your in
|
|
|
112
112
|
* Get an access token
|
|
113
113
|
* Create/update/get/delete a user
|
|
114
114
|
* Get list of users, search for user(s)
|
|
115
|
+
* List credentials of a user
|
|
115
116
|
* Reset credentials
|
|
116
117
|
* Impersonate a user
|
|
117
118
|
* Exchange a configurable token
|
|
@@ -134,6 +135,11 @@ All options have a default value. However, all of them can be changed in your in
|
|
|
134
135
|
* Execute actions emails
|
|
135
136
|
* Send forgot passsword mail
|
|
136
137
|
* Client Authorization, create, update, get, delete Resource, Scope, Policy, Permission, Policy Enforcer
|
|
138
|
+
* Get list of organizations, create/update/get/delete an organization
|
|
139
|
+
* Get list of members of an organization, add/remove members
|
|
140
|
+
* Invite new or existing users to an organization
|
|
141
|
+
* List, add, and remove Identity Providers for an organization
|
|
142
|
+
* Get list of organizations associated with a specific user
|
|
137
143
|
|
|
138
144
|
### Get an access token
|
|
139
145
|
|
|
@@ -226,6 +232,13 @@ new_password = "coco"
|
|
|
226
232
|
KeycloakAdmin.realm("a_realm").users.update_password(user_id, new_password)
|
|
227
233
|
```
|
|
228
234
|
|
|
235
|
+
### List credentials
|
|
236
|
+
|
|
237
|
+
```ruby
|
|
238
|
+
user_id = "95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
239
|
+
KeycloakAdmin.realm("a_realm").users.credentials(user_id)
|
|
240
|
+
```
|
|
241
|
+
|
|
229
242
|
### Impersonate a password directly
|
|
230
243
|
|
|
231
244
|
Returns an instance of `KeycloakAdmin::ImpersonationRepresentation`.
|
|
@@ -244,6 +257,12 @@ user_id = "95985b21-d884-4bbd-b852-cb8cd365afc2"
|
|
|
244
257
|
KeycloakAdmin.realm("a_realm").users.get_redirect_impersonation(user_id)
|
|
245
258
|
```
|
|
246
259
|
|
|
260
|
+
### List all the organizations of a realm
|
|
261
|
+
|
|
262
|
+
```ruby
|
|
263
|
+
KeycloakAdmin.realm("a_realm").organizations.list
|
|
264
|
+
```
|
|
265
|
+
|
|
247
266
|
### Exchange a configurable token
|
|
248
267
|
|
|
249
268
|
*Requires your Keycloak server to have deployed the Custom REST API `configurable-token`* (https://github.com/looorent/keycloak-configurable-token-api)
|
data/bin/console
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "bundler/setup"
|
|
5
|
-
require "keycloak-admin"
|
|
6
|
-
require "byebug"
|
|
7
|
-
|
|
8
|
-
require "irb"
|
|
9
|
-
IRB.start
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "keycloak-admin"
|
|
6
|
+
require "byebug"
|
|
7
|
+
|
|
8
|
+
require "irb"
|
|
9
|
+
IRB.start
|
data/keycloak-admin.gemspec
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
-
|
|
3
|
-
require "keycloak-admin/version"
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name = "keycloak-admin"
|
|
7
|
-
spec.version = KeycloakAdmin::VERSION
|
|
8
|
-
spec.authors = ["Lorent Lempereur"]
|
|
9
|
-
spec.email = ["lorent.lempereur.dev@gmail.com"]
|
|
10
|
-
spec.homepage = "https://github.com/looorent/keycloak-admin-ruby"
|
|
11
|
-
spec.summary = "Keycloak Admin REST API client written in Ruby"
|
|
12
|
-
spec.description = "Keycloak Admin REST API client written in Ruby"
|
|
13
|
-
spec.license = "MIT"
|
|
14
|
-
|
|
15
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
16
|
-
spec.require_paths = ["lib"]
|
|
17
|
-
|
|
18
|
-
spec.required_ruby_version = '>= 2.3'
|
|
19
|
-
|
|
20
|
-
spec.add_dependency "http-cookie", "~> 1.0", ">= 1.0.3"
|
|
21
|
-
spec.add_dependency "rest-client", "~> 2.0"
|
|
22
|
-
spec.add_development_dependency "rspec", "3.13.2"
|
|
23
|
-
spec.add_development_dependency "byebug", "12.0.0"
|
|
24
|
-
end
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
2
|
+
|
|
3
|
+
require "keycloak-admin/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "keycloak-admin"
|
|
7
|
+
spec.version = KeycloakAdmin::VERSION
|
|
8
|
+
spec.authors = ["Lorent Lempereur"]
|
|
9
|
+
spec.email = ["lorent.lempereur.dev@gmail.com"]
|
|
10
|
+
spec.homepage = "https://github.com/looorent/keycloak-admin-ruby"
|
|
11
|
+
spec.summary = "Keycloak Admin REST API client written in Ruby"
|
|
12
|
+
spec.description = "Keycloak Admin REST API client written in Ruby"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
16
|
+
spec.require_paths = ["lib"]
|
|
17
|
+
|
|
18
|
+
spec.required_ruby_version = '>= 2.3'
|
|
19
|
+
|
|
20
|
+
spec.add_dependency "http-cookie", "~> 1.0", ">= 1.0.3"
|
|
21
|
+
spec.add_dependency "rest-client", "~> 2.0"
|
|
22
|
+
spec.add_development_dependency "rspec", "3.13.2"
|
|
23
|
+
spec.add_development_dependency "byebug", "12.0.0"
|
|
24
|
+
end
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
module KeycloakAdmin
|
|
2
|
-
class AttackDetectionClient < Client
|
|
3
|
-
def initialize(configuration, realm_client)
|
|
4
|
-
super(configuration)
|
|
5
|
-
raise ArgumentError.new("realm must be defined") unless realm_client.name_defined?
|
|
6
|
-
@realm_client = realm_client
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def lock_status(user_id)
|
|
10
|
-
raise ArgumentError.new("user_id must be defined") if user_id.nil?
|
|
11
|
-
|
|
12
|
-
response = execute_http do
|
|
13
|
-
RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).get(headers)
|
|
14
|
-
end
|
|
15
|
-
AttackDetectionRepresentation.from_hash(JSON.parse(response))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def unlock_user(user_id)
|
|
19
|
-
raise ArgumentError.new("user_id must be defined") if user_id.nil?
|
|
20
|
-
|
|
21
|
-
execute_http do
|
|
22
|
-
RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).delete(headers)
|
|
23
|
-
end
|
|
24
|
-
true
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def unlock_users
|
|
28
|
-
execute_http do
|
|
29
|
-
RestClient::Resource.new(brute_force_url, @configuration.rest_client_options).delete(headers)
|
|
30
|
-
end
|
|
31
|
-
true
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def brute_force_url(user_id = nil)
|
|
35
|
-
if user_id
|
|
36
|
-
"#{@realm_client.realm_admin_url}/attack-detection/brute-force/users/#{user_id}"
|
|
37
|
-
else
|
|
38
|
-
"#{@realm_client.realm_admin_url}/attack-detection/brute-force/users"
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
1
|
+
module KeycloakAdmin
|
|
2
|
+
class AttackDetectionClient < Client
|
|
3
|
+
def initialize(configuration, realm_client)
|
|
4
|
+
super(configuration)
|
|
5
|
+
raise ArgumentError.new("realm must be defined") unless realm_client.name_defined?
|
|
6
|
+
@realm_client = realm_client
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def lock_status(user_id)
|
|
10
|
+
raise ArgumentError.new("user_id must be defined") if user_id.nil?
|
|
11
|
+
|
|
12
|
+
response = execute_http do
|
|
13
|
+
RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).get(headers)
|
|
14
|
+
end
|
|
15
|
+
AttackDetectionRepresentation.from_hash(JSON.parse(response))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def unlock_user(user_id)
|
|
19
|
+
raise ArgumentError.new("user_id must be defined") if user_id.nil?
|
|
20
|
+
|
|
21
|
+
execute_http do
|
|
22
|
+
RestClient::Resource.new(brute_force_url(user_id), @configuration.rest_client_options).delete(headers)
|
|
23
|
+
end
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def unlock_users
|
|
28
|
+
execute_http do
|
|
29
|
+
RestClient::Resource.new(brute_force_url, @configuration.rest_client_options).delete(headers)
|
|
30
|
+
end
|
|
31
|
+
true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def brute_force_url(user_id = nil)
|
|
35
|
+
if user_id
|
|
36
|
+
"#{@realm_client.realm_admin_url}/attack-detection/brute-force/users/#{user_id}"
|
|
37
|
+
else
|
|
38
|
+
"#{@realm_client.realm_admin_url}/attack-detection/brute-force/users"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
42
|
end
|