keycloak-admin 1.0.17 → 1.0.19
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/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/keycloak-admin/client/role_client.rb +12 -0
- data/lib/keycloak-admin/client/role_mapper_client.rb +18 -0
- data/lib/keycloak-admin/version.rb +1 -1
- data/spec/client/role_mapper_client_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ccb78dc55dca61ad8dd44cb0f131dbe1b7a6b6c6449dd68c51fc981ef5439c
|
4
|
+
data.tar.gz: 7d3d483d4c1d26b430abc1accb326a7a371cc18c39fdde00845c2ed53dc79593
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef5313937cb5b1442aaf182f10d020a893c86b6d5ce88950f9caa9bde8c115345c48b47b1a2598b49d85e76dbad1d7eea967a8dbc3655d07cfbf152d83471a9
|
7
|
+
data.tar.gz: a0373bba411c1e642220b61b25dc790727aad1738a60ca8e0141539eb7f8468eaae73d963255d7fd845072c9feca9530336da658c2a12e041c07218a61d1cf3a
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,15 @@ 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.0.19] - 2022-12-03
|
9
|
+
|
10
|
+
* Remove specific realm roles from user (thanks to @Kazhuu)
|
11
|
+
* Get role by name (thanks to @Kazhuu)
|
12
|
+
|
13
|
+
## [1.0.18] - 2022-11-24
|
14
|
+
|
15
|
+
* List user realm-level role mappings (thanks to @Kazhuu)
|
16
|
+
|
8
17
|
## [1.0.17] - 2022-11-02
|
9
18
|
|
10
19
|
* Delete `Client`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,13 @@ module KeycloakAdmin
|
|
12
12
|
end
|
13
13
|
JSON.parse(response).map { |role_as_hash| RoleRepresentation.from_hash(role_as_hash) }
|
14
14
|
end
|
15
|
+
|
16
|
+
def get(name)
|
17
|
+
response = execute_http do
|
18
|
+
RestClient::Resource.new(role_name_url(name), @configuration.rest_client_options).get(headers)
|
19
|
+
end
|
20
|
+
RoleRepresentation.from_hash JSON.parse(response)
|
21
|
+
end
|
15
22
|
|
16
23
|
def save(role_representation)
|
17
24
|
execute_http do
|
@@ -28,5 +35,10 @@ module KeycloakAdmin
|
|
28
35
|
"#{@realm_client.realm_admin_url}/roles"
|
29
36
|
end
|
30
37
|
end
|
38
|
+
|
39
|
+
def role_name_url(name)
|
40
|
+
"#{@realm_client.realm_admin_url}/roles/#{name}"
|
41
|
+
end
|
42
|
+
|
31
43
|
end
|
32
44
|
end
|
@@ -5,6 +5,13 @@ module KeycloakAdmin
|
|
5
5
|
@user_resource = user_resource
|
6
6
|
end
|
7
7
|
|
8
|
+
def list
|
9
|
+
response = execute_http do
|
10
|
+
RestClient::Resource.new(realm_level_url, @configuration.rest_client_options).get(headers)
|
11
|
+
end
|
12
|
+
JSON.parse(response).map { |role_as_hash| RoleRepresentation.from_hash(role_as_hash) }
|
13
|
+
end
|
14
|
+
|
8
15
|
def save_realm_level(role_representation_list)
|
9
16
|
execute_http do
|
10
17
|
RestClient::Resource.new(realm_level_url, @configuration.rest_client_options).post(
|
@@ -13,6 +20,17 @@ module KeycloakAdmin
|
|
13
20
|
end
|
14
21
|
end
|
15
22
|
|
23
|
+
def remove_realm_level(role_representation_list)
|
24
|
+
execute_http do
|
25
|
+
RestClient::Request.execute(
|
26
|
+
method: :delete,
|
27
|
+
url: realm_level_url,
|
28
|
+
payload: create_payload(role_representation_list),
|
29
|
+
headers: headers
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
16
34
|
def remove_all_realm_roles
|
17
35
|
execute_http do
|
18
36
|
RestClient::Resource.new(realm_level_url, @configuration.rest_client_options).delete(headers)
|
@@ -12,6 +12,27 @@ RSpec.describe KeycloakAdmin::RoleMapperClient do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "#list" do
|
16
|
+
let(:realm_name) { "valid-realm" }
|
17
|
+
let(:user_id) { "test_user" }
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
@role_mapper_client = KeycloakAdmin.realm(realm_name).user(user_id).role_mapper
|
21
|
+
|
22
|
+
stub_token_client
|
23
|
+
allow_any_instance_of(RestClient::Resource).to receive(:get)
|
24
|
+
.and_return '[{"id":"test_role_id","name":"test_role_name","composite": false}]'
|
25
|
+
end
|
26
|
+
|
27
|
+
it "list user realm-level role mappings" do
|
28
|
+
roles = @role_mapper_client.list
|
29
|
+
expect(roles.length).to eq 1
|
30
|
+
expect(roles[0].id).to eq "test_role_id"
|
31
|
+
expect(roles[0].name).to eq "test_role_name"
|
32
|
+
expect(roles[0].composite).to be false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
15
36
|
describe "#save_realm_level" do
|
16
37
|
let(:realm_name) { "valid-realm" }
|
17
38
|
let(:user_id) { "test_user" }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keycloak-admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorent Lempereur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-cookie
|