keycloak-admin 0.7.8 → 0.7.9
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 +11 -2
- data/lib/keycloak-admin/client/user_client.rb +15 -1
- data/lib/keycloak-admin/version.rb +1 -1
- data/spec/client/user_client_spec.rb +13 -1
- 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: ddc2a67d3273ab4353daeb48dce261f5ba27a310fa91e9947e751da86d55a124
|
4
|
+
data.tar.gz: 5850f80b6f5c1f76ade40a92bba444559fcc1f637bee0eaf1cb4b917cbfd7f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210d92708eb39e0f221cd54f7c5d1fec917f8a1cab5bafb6ec1b1f706b60e634acf55bd38396bf5017ac95eef4aaed2d3892700ec9cbcc84757128ed02f2d46f
|
7
|
+
data.tar.gz: 45e19fa08576cb1f468f0fc9dd6841da93e0bafe91002361ad78610637a41e438bfc7e7a04f5741eab87bc161cab4982b7d9fd88a482862ede548c03b2e3c287
|
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
|
+
## [0.7.9] - 2020-10-22
|
9
|
+
|
10
|
+
* Extend `search` function to use complex queries (thanks to @hobbypunk90)
|
11
|
+
|
8
12
|
## [0.7.8] - 2020-10-15
|
9
13
|
|
10
14
|
* Bug: `rest_client_options` default value does not match the documentation (was `nil` by default, should be `{}`)
|
data/Gemfile.lock
CHANGED
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", "0.7.
|
15
|
+
gem "keycloak-admin", "0.7.9"
|
16
16
|
```
|
17
17
|
|
18
18
|
## Login
|
@@ -91,7 +91,8 @@ All options have a default value. However, all of them can be changed in your in
|
|
91
91
|
|
92
92
|
| Option | Default Value | Type | Required? | Description | Example |
|
93
93
|
| ---- | ----- | ------ | ----- | ------ | ----- |
|
94
|
-
| `server_url` | `nil
|
94
|
+
| `server_url` | `nil` | String | Required | The base url where your Keycloak server is located (a URL that starts with `http` and that ends with `/auth`). This value can be retrieved in your Keycloak client configuration. | `http://auth:8080/auth`
|
95
|
+
| `server_domain` | `nil`| String | Required | Public domain that identify your authentication cookies. | `auth.service.io` |
|
95
96
|
| `client_realm_name` | `""`| String | Required | Name of the realm that contains the admin client. | `master` |
|
96
97
|
| `client_id` | `admin-cli`| String | Required | Client that should be used to access admin capabilities. | `api-cli` |
|
97
98
|
| `client_secret` | `nil`| String | Optional | If your client is `confidential`, this parameter must be specified. | `4e3c481c-f823-4a6a-b8a7-bf8c86e3eac3` |
|
@@ -144,10 +145,18 @@ KeycloakAdmin.realm("a_realm").users.get(user_id)
|
|
144
145
|
|
145
146
|
Returns an array of `KeycloakAdmin::UserRepresentation`.
|
146
147
|
|
148
|
+
According to [the documentation](https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_users_resource):
|
149
|
+
* When providing a `String` parameter, this produces an arbitrary search string
|
150
|
+
* When providing a `Hash`, you can search for specific field (_e.g_ an email)
|
151
|
+
|
147
152
|
```ruby
|
148
153
|
KeycloakAdmin.realm("a_realm").users.search("a_username_or_an_email")
|
149
154
|
```
|
150
155
|
|
156
|
+
```ruby
|
157
|
+
KeycloakAdmin.realm("a_realm").users.search({ email: "john@doe.com" })
|
158
|
+
```
|
159
|
+
|
151
160
|
### List all users in a realm
|
152
161
|
|
153
162
|
Returns an array of `KeycloakAdmin::UserRepresentation`.
|
@@ -38,8 +38,22 @@ module KeycloakAdmin
|
|
38
38
|
UserRepresentation.from_hash(JSON.parse(response))
|
39
39
|
end
|
40
40
|
|
41
|
+
##
|
42
|
+
# Query can be a string or a hash.
|
43
|
+
# * String: It's used as search query
|
44
|
+
# * Hash: Used for complex search queries.
|
45
|
+
# For its documentation see: https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_users_resource
|
46
|
+
##
|
41
47
|
def search(query)
|
42
|
-
derived_headers =
|
48
|
+
derived_headers = case query
|
49
|
+
when String
|
50
|
+
headers.merge({params: { search: query }})
|
51
|
+
when Hash
|
52
|
+
headers.merge({params: query })
|
53
|
+
else
|
54
|
+
headers
|
55
|
+
end
|
56
|
+
|
43
57
|
response = execute_http do
|
44
58
|
RestClient::Resource.new(users_url, @configuration.rest_client_options).get(derived_headers)
|
45
59
|
end
|
@@ -192,12 +192,24 @@ RSpec.describe KeycloakAdmin::TokenClient do
|
|
192
192
|
allow_any_instance_of(RestClient::Resource).to receive(:get).and_return '[{"username":"test_username","createdTimestamp":1559347200}]'
|
193
193
|
end
|
194
194
|
|
195
|
-
it "finds a user" do
|
195
|
+
it "finds a user using a string" do
|
196
196
|
users = @user_client.search("test_username")
|
197
197
|
expect(users.length).to eq 1
|
198
198
|
expect(users[0].username).to eq "test_username"
|
199
199
|
end
|
200
200
|
|
201
|
+
it "finds a user using nil does not fail" do
|
202
|
+
users = @user_client.search(nil)
|
203
|
+
expect(users.length).to eq 1
|
204
|
+
expect(users[0].username).to eq "test_username"
|
205
|
+
end
|
206
|
+
|
207
|
+
it "finds a user using a hash" do
|
208
|
+
users = @user_client.search({ search: "test_username"})
|
209
|
+
expect(users.length).to eq 1
|
210
|
+
expect(users[0].username).to eq "test_username"
|
211
|
+
end
|
212
|
+
|
201
213
|
it "passes rest client options" do
|
202
214
|
rest_client_options = {verify_ssl: OpenSSL::SSL::VERIFY_NONE}
|
203
215
|
allow_any_instance_of(KeycloakAdmin::Configuration).to receive(:rest_client_options).and_return rest_client_options
|
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: 0.7.
|
4
|
+
version: 0.7.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lorent Lempereur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-cookie
|