keycloak-admin 1.0.7 → 1.0.13
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 +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/keycloak-admin/client/client_role_client.rb +20 -0
- data/lib/keycloak-admin/client/realm_client.rb +4 -0
- data/lib/keycloak-admin/client/user_client.rb +16 -4
- data/lib/keycloak-admin/representation/protocol_mapper_representation.rb +2 -2
- data/lib/keycloak-admin/version.rb +1 -1
- data/lib/keycloak-admin.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ccf7a2ad66682e3a4ed21b48fb816b8b3b179fc20b22d77ee5e6081381b360d
|
4
|
+
data.tar.gz: 497ca95848d65d72164b121210b122c1a068fce5c8123614b2801ff878ee9395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c9feea764166e7880cc964a03901e4cd4fa271ee97a3cb84cd23f7f87be650ffd7002bb82dd78fe2a34611083542445440e368216ee2ec3df22dc0a9457fa8
|
7
|
+
data.tar.gz: 63baea81ba99dfb815aa6e6dc41256fb1d21c385f59db22f1128a8916356bd5b850f42a4874438c7a2a806edcb8c2b287f76c8db0030d22f9e689b3b8cf3a4cc
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ 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.13] - 2022-03-13
|
9
|
+
|
10
|
+
* Add client role on users
|
11
|
+
* List client roles
|
8
12
|
|
9
13
|
## [1.0.7] - 2022-03-13
|
10
14
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module KeycloakAdmin
|
2
|
+
class ClientRoleClient < 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 list(client_id)
|
10
|
+
response = execute_http do
|
11
|
+
RestClient::Resource.new(clients_url(client_id), @configuration.rest_client_options).get(headers)
|
12
|
+
end
|
13
|
+
JSON.parse(response).map { |role_as_hash| RoleRepresentation.from_hash(role_as_hash) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def clients_url(id)
|
17
|
+
"#{@realm_client.realm_admin_url}/clients/#{id}/roles"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -6,8 +6,8 @@ module KeycloakAdmin
|
|
6
6
|
@realm_client = realm_client
|
7
7
|
end
|
8
8
|
|
9
|
-
def create!(username, email, password, email_verified, locale)
|
10
|
-
user = save(build(username, email, password, email_verified, locale))
|
9
|
+
def create!(username, email, password, email_verified, locale, attributes={})
|
10
|
+
user = save(build(username, email, password, email_verified, locale, attributes))
|
11
11
|
search(user.email)&.first
|
12
12
|
end
|
13
13
|
|
@@ -52,6 +52,14 @@ module KeycloakAdmin
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def add_client_roles_on_user(user_id, client_id, role_representations)
|
56
|
+
execute_http do
|
57
|
+
RestClient::Resource.new(user_client_role_mappings_url(user_id, client_id), @configuration.rest_client_options).post(
|
58
|
+
create_payload(role_representations), headers
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
55
63
|
def get(user_id)
|
56
64
|
response = execute_http do
|
57
65
|
RestClient::Resource.new(users_url(user_id), @configuration.rest_client_options).get(headers)
|
@@ -176,6 +184,10 @@ module KeycloakAdmin
|
|
176
184
|
end
|
177
185
|
end
|
178
186
|
|
187
|
+
def user_client_role_mappings_url(user_id, client_id)
|
188
|
+
"#{users_url(user_id)}/role-mappings/clients/#{client_id}"
|
189
|
+
end
|
190
|
+
|
179
191
|
def reset_password_url(user_id)
|
180
192
|
raise ArgumentError.new("user_id must be defined") if user_id.nil?
|
181
193
|
"#{users_url(user_id)}/reset-password"
|
@@ -204,13 +216,13 @@ module KeycloakAdmin
|
|
204
216
|
|
205
217
|
private
|
206
218
|
|
207
|
-
def build(username, email, password, email_verified, locale)
|
219
|
+
def build(username, email, password, email_verified, locale, attributes={})
|
208
220
|
user = UserRepresentation.new
|
209
221
|
user.email = email
|
210
222
|
user.username = username
|
211
223
|
user.email_verified = email_verified
|
212
224
|
user.enabled = true
|
213
|
-
user.attributes = {}
|
225
|
+
user.attributes = attributes || {}
|
214
226
|
user.attributes[:locale] = locale if locale
|
215
227
|
user.add_credential(CredentialRepresentation.from_password(password))
|
216
228
|
user
|
@@ -4,7 +4,7 @@ module KeycloakAdmin
|
|
4
4
|
:id,
|
5
5
|
:name,
|
6
6
|
:protocol,
|
7
|
-
:
|
7
|
+
:protocolMapper
|
8
8
|
|
9
9
|
def self.from_hash(hash)
|
10
10
|
rep = new
|
@@ -12,7 +12,7 @@ module KeycloakAdmin
|
|
12
12
|
rep.config = hash["config"]
|
13
13
|
rep.name = hash["name"]
|
14
14
|
rep.protocol = hash["protocol"]
|
15
|
-
rep.
|
15
|
+
rep.protocolMapper = hash["protocolMapper"]
|
16
16
|
rep
|
17
17
|
end
|
18
18
|
end
|
data/lib/keycloak-admin.rb
CHANGED
@@ -3,6 +3,7 @@ require "logger"
|
|
3
3
|
require_relative "keycloak-admin/configuration"
|
4
4
|
require_relative "keycloak-admin/client/client"
|
5
5
|
require_relative "keycloak-admin/client/client_client"
|
6
|
+
require_relative "keycloak-admin/client/client_role_client"
|
6
7
|
require_relative "keycloak-admin/client/client_role_mappings_client"
|
7
8
|
require_relative "keycloak-admin/client/group_client"
|
8
9
|
require_relative "keycloak-admin/client/realm_client"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorent Lempereur
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/keycloak-admin.rb
|
92
92
|
- lib/keycloak-admin/client/client.rb
|
93
93
|
- lib/keycloak-admin/client/client_client.rb
|
94
|
+
- lib/keycloak-admin/client/client_role_client.rb
|
94
95
|
- lib/keycloak-admin/client/client_role_mappings_client.rb
|
95
96
|
- lib/keycloak-admin/client/configurable_token_client.rb
|
96
97
|
- lib/keycloak-admin/client/group_client.rb
|