keycloak-admin 1.0.3 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/keycloak-admin/client/client.rb +10 -0
- data/lib/keycloak-admin/client/client_client.rb +12 -1
- data/lib/keycloak-admin/client/client_role_mappings_client.rb +1 -1
- data/lib/keycloak-admin/client/group_client.rb +1 -1
- data/lib/keycloak-admin/client/identity_provider_client.rb +2 -2
- data/lib/keycloak-admin/client/realm_client.rb +2 -2
- data/lib/keycloak-admin/client/role_client.rb +1 -1
- data/lib/keycloak-admin/client/role_mapper_client.rb +1 -1
- data/lib/keycloak-admin/client/user_client.rb +3 -3
- data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +7 -7
- data/lib/keycloak-admin/version.rb +1 -1
- data/spec/representation/client_representation_spec.rb +1 -1
- data/spec/representation/identity_provider_mapper_representation_spec.rb +1 -1
- data/spec/representation/protocol_mapper_representation_spec.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a78897f6f30b684a57e9233d436c4cd338061729abc161e0afd8c904ca8890d7
|
4
|
+
data.tar.gz: 75c438cf89337f0823d0cd4b7f0379dc5d40dcf090309b319e02ee5145b92f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f43d6a122d6e5ce869a38773293fc8bb913865c4febef40904cb660b7440dede79fdb477476bf4f73b001999fc4adb4eb662677b74b8c908baa0370538a09e
|
7
|
+
data.tar.gz: bc883a362f07cbec20df4ae07fd0fbabe5b5d9056fc0df443df65d768c0887dd33a0b0c3127b45efa80f5d60231a09cab3e45358cf969ea097b2bfa5173df431
|
data/CHANGELOG.md
CHANGED
@@ -5,11 +5,16 @@ 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.
|
8
|
+
## [1.0.6] - 2022-03-13
|
9
|
+
|
10
|
+
* When serializing an array to JSON, force the serialization to use `to_json` for each element. In several contexts (e.g. Rails), `to_json` is not used.
|
11
|
+
|
12
|
+
## [1.0.5] - 2022-03-11
|
9
13
|
|
10
14
|
* Create `Client`
|
11
15
|
* Create `Identity Provider` (Breaking change: `IdentityProviderRepresentation.configuration` has been renamed to `IdentityProviderRepresentation.config`)
|
12
16
|
* Add `Identity Provider Mapping`
|
17
|
+
* Find service account for a `Client`
|
13
18
|
|
14
19
|
## [1.0.1] - 2021-10-14
|
15
20
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ module KeycloakAdmin
|
|
9
9
|
def save(client_representation)
|
10
10
|
execute_http do
|
11
11
|
RestClient::Resource.new(clients_url, @configuration.rest_client_options).post(
|
12
|
-
client_representation
|
12
|
+
create_payload(client_representation), headers
|
13
13
|
)
|
14
14
|
end
|
15
15
|
end
|
@@ -21,6 +21,13 @@ module KeycloakAdmin
|
|
21
21
|
JSON.parse(response).map { |client_as_hash| ClientRepresentation.from_hash(client_as_hash) }
|
22
22
|
end
|
23
23
|
|
24
|
+
def get_service_account_user(client_id)
|
25
|
+
response = execute_http do
|
26
|
+
RestClient::Resource.new(service_account_user_url(client_id), @configuration.rest_client_options).get(headers)
|
27
|
+
end
|
28
|
+
UserRepresentation.from_hash(JSON.parse(response))
|
29
|
+
end
|
30
|
+
|
24
31
|
def clients_url(id=nil)
|
25
32
|
if id
|
26
33
|
"#{@realm_client.realm_admin_url}/clients/#{id}"
|
@@ -28,5 +35,9 @@ module KeycloakAdmin
|
|
28
35
|
"#{@realm_client.realm_admin_url}/clients"
|
29
36
|
end
|
30
37
|
end
|
38
|
+
|
39
|
+
def service_account_user_url(client_id)
|
40
|
+
"#{clients_url(client_id)}/service-account-user"
|
41
|
+
end
|
31
42
|
end
|
32
43
|
end
|
@@ -16,7 +16,7 @@ module KeycloakAdmin
|
|
16
16
|
def save(role_representation_list)
|
17
17
|
execute_http do
|
18
18
|
RestClient::Resource.new(base_url, @configuration.rest_client_options).post(
|
19
|
-
role_representation_list
|
19
|
+
create_payload(role_representation_list), headers
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -21,7 +21,7 @@ module KeycloakAdmin
|
|
21
21
|
def save(group_representation)
|
22
22
|
execute_http do
|
23
23
|
RestClient::Resource.new(groups_url, @configuration.rest_client_options).post(
|
24
|
-
group_representation
|
24
|
+
create_payload(group_representation), headers
|
25
25
|
)
|
26
26
|
end
|
27
27
|
end
|
@@ -9,7 +9,7 @@ module KeycloakAdmin
|
|
9
9
|
def create(identity_provider_representation)
|
10
10
|
execute_http do
|
11
11
|
RestClient::Resource.new(identity_providers_url, @configuration.rest_client_options).post(
|
12
|
-
identity_provider_representation
|
12
|
+
create_payload(identity_provider_representation), headers
|
13
13
|
)
|
14
14
|
end
|
15
15
|
end
|
@@ -17,7 +17,7 @@ module KeycloakAdmin
|
|
17
17
|
def add_mapping(identity_provider_alias, identity_provider_mapping_representation)
|
18
18
|
execute_http do
|
19
19
|
RestClient::Resource.new(identity_provider_mappers_url(identity_provider_alias), @configuration.rest_client_options).post(
|
20
|
-
identity_provider_mapping_representation
|
20
|
+
create_payload(identity_provider_mapping_representation), headers
|
21
21
|
)
|
22
22
|
end
|
23
23
|
end
|
@@ -22,7 +22,7 @@ module KeycloakAdmin
|
|
22
22
|
def save(realm_representation)
|
23
23
|
execute_http do
|
24
24
|
RestClient::Resource.new(realm_list_url, @configuration.rest_client_options).post(
|
25
|
-
realm_representation
|
25
|
+
create_payload(realm_representation), headers
|
26
26
|
)
|
27
27
|
end
|
28
28
|
end
|
@@ -30,7 +30,7 @@ module KeycloakAdmin
|
|
30
30
|
def update(realm_representation_body)
|
31
31
|
execute_http do
|
32
32
|
RestClient::Resource.new(realm_admin_url, @configuration.rest_client_options).put(
|
33
|
-
realm_representation_body
|
33
|
+
create_payload(realm_representation_body), headers
|
34
34
|
)
|
35
35
|
end
|
36
36
|
end
|
@@ -16,7 +16,7 @@ module KeycloakAdmin
|
|
16
16
|
def save(role_representation)
|
17
17
|
execute_http do
|
18
18
|
RestClient::Resource.new(roles_url, @configuration.rest_client_options).post(
|
19
|
-
role_representation
|
19
|
+
create_payload(role_representation), headers
|
20
20
|
)
|
21
21
|
end
|
22
22
|
end
|
@@ -8,7 +8,7 @@ module KeycloakAdmin
|
|
8
8
|
def save_realm_level(role_representation_list)
|
9
9
|
execute_http do
|
10
10
|
RestClient::Resource.new(realm_level_url, @configuration.rest_client_options).post(
|
11
|
-
role_representation_list
|
11
|
+
create_payload(role_representation_list), headers
|
12
12
|
)
|
13
13
|
end
|
14
14
|
end
|
@@ -14,7 +14,7 @@ module KeycloakAdmin
|
|
14
14
|
def save(user_representation)
|
15
15
|
execute_http do
|
16
16
|
RestClient::Resource.new(users_url, @configuration.rest_client_options).post(
|
17
|
-
user_representation
|
17
|
+
create_payload(user_representation), headers
|
18
18
|
)
|
19
19
|
end
|
20
20
|
user_representation
|
@@ -25,7 +25,7 @@ module KeycloakAdmin
|
|
25
25
|
@configuration.rest_client_options.merge(
|
26
26
|
method: :put,
|
27
27
|
url: users_url(user_id),
|
28
|
-
payload: user_representation_body
|
28
|
+
payload: create_payload(user_representation_body),
|
29
29
|
headers: headers
|
30
30
|
)
|
31
31
|
)
|
@@ -120,7 +120,7 @@ module KeycloakAdmin
|
|
120
120
|
def execute_actions_email(user_id, actions=[], lifespan=nil)
|
121
121
|
execute_http do
|
122
122
|
lifespan_param = lifespan.nil? ? "" : "lifespan=#{lifespan.seconds}"
|
123
|
-
RestClient.put("#{execute_actions_email_url(user_id)}?#{lifespan_param}", actions
|
123
|
+
RestClient.put("#{execute_actions_email_url(user_id)}?#{lifespan_param}", create_payload(actions), headers)
|
124
124
|
end
|
125
125
|
user_id
|
126
126
|
end
|
@@ -4,15 +4,15 @@ module KeycloakAdmin
|
|
4
4
|
:id,
|
5
5
|
:name,
|
6
6
|
:protocol,
|
7
|
-
:
|
7
|
+
:protocolMapper
|
8
8
|
|
9
9
|
def self.from_hash(hash)
|
10
|
-
rep
|
11
|
-
rep.id
|
12
|
-
rep.config
|
13
|
-
rep.name
|
14
|
-
rep.protocol
|
15
|
-
rep.
|
10
|
+
rep = new
|
11
|
+
rep.id = hash["id"]
|
12
|
+
rep.config = hash["config"]
|
13
|
+
rep.name = hash["name"]
|
14
|
+
rep.protocol = hash["protocol"]
|
15
|
+
rep.protocolMapper = hash["protocolMapper"]
|
16
16
|
rep
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
RSpec.describe KeycloakAdmin::ProtocolMapperRepresentation do
|
2
|
+
describe "#to_json" do
|
3
|
+
before(:each) do
|
4
|
+
@mapper = KeycloakAdmin::ProtocolMapperRepresentation.from_hash(
|
5
|
+
{
|
6
|
+
"id" => "hello",
|
7
|
+
"name" => "abcd",
|
8
|
+
"protocol" => "openid-connect",
|
9
|
+
"protocolMapper" => "oidc-hardcoded-claim-mapper",
|
10
|
+
"consentRequired" => false,
|
11
|
+
"config" => {
|
12
|
+
"claim.value" => "123456",
|
13
|
+
"userinfo.token.claim" => "false",
|
14
|
+
"id.token.claim" => "false",
|
15
|
+
"access.token.claim" => "true",
|
16
|
+
"claim.name" => "abcd",
|
17
|
+
"jsonType.label" => "String",
|
18
|
+
"access.tokenResponse.claim" => "false"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "can convert to json" do
|
25
|
+
expect(@mapper.to_json).to eq "{\"id\":\"hello\",\"config\":{\"claim.value\":\"123456\",\"userinfo.token.claim\":\"false\",\"id.token.claim\":\"false\",\"access.token.claim\":\"true\",\"claim.name\":\"abcd\",\"jsonType.label\":\"String\",\"access.tokenResponse.claim\":\"false\"},\"name\":\"abcd\",\"protocol\":\"openid-connect\",\"protocolMapper\":\"oidc-hardcoded-claim-mapper\"}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "array#to_json" do
|
30
|
+
before(:each) do
|
31
|
+
@mapper = [
|
32
|
+
KeycloakAdmin::ProtocolMapperRepresentation.from_hash(
|
33
|
+
{
|
34
|
+
"id" => "hello",
|
35
|
+
"name" => "abcd",
|
36
|
+
"protocol" => "openid-connect",
|
37
|
+
"protocolMapper" => "oidc-hardcoded-claim-mapper",
|
38
|
+
"consentRequired" => false,
|
39
|
+
"config" => {
|
40
|
+
"claim.value" => "123456",
|
41
|
+
"userinfo.token.claim" => "false",
|
42
|
+
"id.token.claim" => "false",
|
43
|
+
"access.token.claim" => "true",
|
44
|
+
"claim.name" => "abcd",
|
45
|
+
"jsonType.label" => "String",
|
46
|
+
"access.tokenResponse.claim" => "false"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
)
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "can convert to json" do
|
54
|
+
expect(@mapper.to_json).to eq "[{\"id\":\"hello\",\"config\":{\"claim.value\":\"123456\",\"userinfo.token.claim\":\"false\",\"id.token.claim\":\"false\",\"access.token.claim\":\"true\",\"claim.name\":\"abcd\",\"jsonType.label\":\"String\",\"access.tokenResponse.claim\":\"false\"},\"name\":\"abcd\",\"protocol\":\"openid-connect\",\"protocolMapper\":\"oidc-hardcoded-claim-mapper\"}]"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
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.6
|
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-03-
|
11
|
+
date: 2022-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-cookie
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- spec/representation/identity_provider_mapper_representation_spec.rb
|
137
137
|
- spec/representation/identity_provider_representation_spec.rb
|
138
138
|
- spec/representation/impersonation_representation_spec.rb
|
139
|
+
- spec/representation/protocol_mapper_representation_spec.rb
|
139
140
|
- spec/representation/user_representation_spec.rb
|
140
141
|
- spec/resource/group_resource_spec.rb
|
141
142
|
- spec/resource/user_resource_spec.rb
|