keycloak-admin 1.0.20 → 1.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e12b29d601e1a543c15d2d23820a1834088d4ab03fdde20ab81905ee0236309
4
- data.tar.gz: 1d42e0333e35bf0c6faca2a1439533f2a35d5e85a0494b2fa0901d98b37ae99e
3
+ metadata.gz: 1a01d12df8eb75fcedbf128aacae50192983a47cb4cfac6c52b1dff4d999aa08
4
+ data.tar.gz: dae8911b975b7aea1989fc8df565047c144da55868569da02039c53fbc8d6963
5
5
  SHA512:
6
- metadata.gz: 74e45f56d4ec1adca533d8c41fc9ae519a359a63c3632560c17fb927425b5e0f1e22519b6d8c99894b034acdd8c3b7a1229430a95a00e42fa024376b72bd8298
7
- data.tar.gz: 662228969795e4fa165be24480714e662ac4e178c5ad1e3eaae14be90ffd245796db80bd0bedb02761e8d228a7b023dd426b52884029de449ebf2f8a02e7a8d9
6
+ metadata.gz: 8f44444327adcb4622856a7397401b5eaeaa10ad55943cce4606f4539340795a2e444f48613c35cdedb41c34431516b9137fec07f163d51c5e7c691ce3a7db17
7
+ data.tar.gz: 2210584caebc4c01e67a7da99740910755759a1edb22fb5c48002c0e51eb3d672460a74723db38bdc0bc639c2effd1cc42e4a8d30b79e185ce0d31a3a6c8ea72
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.21] - 2023-02-03
9
+
10
+ * List users who are a member of a group (thanks to @tlloydthwaites)
11
+
8
12
  ## [1.0.20] - 2022-12-26
9
13
 
10
14
  * Create subgroups (thanks to @neckhair)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- keycloak-admin (1.0.20)
4
+ keycloak-admin (1.0.21)
5
5
  http-cookie (~> 1.0, >= 1.0.3)
6
6
  rest-client (~> 2.1)
7
7
 
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.0.20"
15
+ gem "keycloak-admin", "1.0.21"
16
16
  ```
17
17
 
18
18
  ## Login
@@ -119,6 +119,7 @@ All options have a default value. However, all of them can be changed in your in
119
119
  * Get list of roles, save a role
120
120
  * Get list of realms, save/update/delete a realm
121
121
  * Get list of client role mappings for a user/group
122
+ * Get list of members of a group
122
123
  * Save client role mappings for a user/group
123
124
  * Save realm-level role mappings for a user/group
124
125
  * Add a Group on a User
@@ -320,6 +321,20 @@ group_name = "test"
320
321
  sub_group_id = KeycloakAdmin.realm("a_realm").groups.create_subgroup!(parent_id, group_name)
321
322
  ```
322
323
 
324
+ ### Get list of members of a group
325
+
326
+ Returns an array of `KeycloakAdmin::UserRepresentation`.
327
+
328
+ ```ruby
329
+ KeycloakAdmin.realm("a_realm").group("group_id").members
330
+ ```
331
+
332
+ You can specify paging with `first` and `max`:
333
+
334
+ ```ruby
335
+ KeycloakAdmin.realm("a_realm").group("group_id").members(first:0, max:100)
336
+ ```
337
+
323
338
  ### Get list of roles in a realm
324
339
 
325
340
  Returns an array of `KeycloakAdmin::RoleRepresentation`.
@@ -35,6 +35,19 @@ module KeycloakAdmin
35
35
  end
36
36
  created_id(response)
37
37
  end
38
+
39
+ def members(group_id, first=0, max=100)
40
+ url = "#{groups_url(group_id)}/members"
41
+ query = {first: first.try(:to_i), max: max.try(:to_i)}.compact
42
+ unless query.empty?
43
+ query_string = query.to_a.map { |e| "#{e[0]}=#{e[1]}" }.join("&")
44
+ url = "#{url}?#{query_string}"
45
+ end
46
+ response = execute_http do
47
+ RestClient::Resource.new(url, @configuration.rest_client_options).get(headers)
48
+ end
49
+ JSON.parse(response).map { |user_as_hash| UserRepresentation.from_hash(user_as_hash) }
50
+ end
38
51
 
39
52
  def groups_url(id=nil)
40
53
  if id
@@ -3,5 +3,9 @@ module KeycloakAdmin
3
3
  def resources_name
4
4
  "groups"
5
5
  end
6
+
7
+ def members(first:0, max:100)
8
+ @realm_client.groups.members(@resource_id, first, max)
9
+ end
6
10
  end
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module KeycloakAdmin
2
- VERSION = "1.0.20"
2
+ VERSION = "1.0.21"
3
3
  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.20
4
+ version: 1.0.21
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-12-26 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-cookie