sqsc-keycloak-ruby 1.0.1 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a6e6ffe4d42fd40302fbaa10e4e00373576fbbd1aed495b09371bc37b7e09b3
4
- data.tar.gz: 8947ad39d88f909278b601c03cdd756ff8517e18abacf3bacdc46fc5eccec72b
3
+ metadata.gz: fa232a9b7fcad28283ba2dff4a0b666731bfa566b8a2a98fdf102e3bc850d3c4
4
+ data.tar.gz: f47e1429a8fa86f030cba93f6a25787ac5dee5240352a675f9347c478d80332b
5
5
  SHA512:
6
- metadata.gz: e3d04dfce599fb9c71249e717450552850cd5bb405101d70c4b27700486454ac34df133b9377b0b13eabfda3eab503a94ac583e5b52a53680255fb5ede0c0dc4
7
- data.tar.gz: 66d0464de05084e71f7562dd47e17371a4b24bf4751c02b8cb5a3b9151e39ef3ba04875088aa43cb3a1afed8b44602b2c6b103f0c03cd37ac6c15c4f7362d548
6
+ metadata.gz: 0d019a221ca5b369285defca16924aa88d6b136b6bd5d3acef32388ffe21b1b0134fe55e22684741140c2a3f387b1c4742c2a580169ddab26942776033dcea0e
7
+ data.tar.gz: c1d3ed1e1c921b25afcb31e83c5a001ba6f7e4b52fe931e9594f835d5e6696906de08052a1b12b0ed861724c9436e04ef4ea56b7af22a174d43d656e6445d2dd
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6.x
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rspec
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rspec ./spec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sqsc-keycloak-ruby (1.0.0)
4
+ sqsc-keycloak-ruby (1.0.1)
5
5
  json
6
6
  jwt
7
7
  rest-client
@@ -15,11 +15,11 @@ GEM
15
15
  http-accept (1.7.0)
16
16
  http-cookie (1.0.3)
17
17
  domain_name (~> 0.5)
18
- json (2.3.0)
19
- jwt (2.2.1)
20
- mime-types (3.3)
18
+ json (2.3.1)
19
+ jwt (2.2.2)
20
+ mime-types (3.3.1)
21
21
  mime-types-data (~> 3.2015)
22
- mime-types-data (3.2019.1009)
22
+ mime-types-data (3.2020.0512)
23
23
  netrc (0.11.0)
24
24
  rake (13.0.1)
25
25
  rest-client (2.1.0)
@@ -42,7 +42,7 @@ GEM
42
42
  rspec-support (3.9.0)
43
43
  unf (0.1.4)
44
44
  unf_ext
45
- unf_ext (0.0.7.6)
45
+ unf_ext (0.0.7.7)
46
46
 
47
47
  PLATFORMS
48
48
  ruby
data/README.md CHANGED
@@ -380,6 +380,12 @@ Keycloak::Admin.get_client_level_role_for_user_and_app(id, client, access_token
380
380
 
381
381
  `get_client_level_role_for_user_and_app` return a list of [RoleRepresentation](http://www.keycloak.org/docs-api/3.2/rest-api/index.html#_rolerepresentation) of client <b>Client-Roles</b>, represented by `client` parameter linked to the user represented by the `id` parameter.
382
382
 
383
+ ```ruby
384
+ # GET /admin/realms/{realm}/clients/{client_id}/offline-sessions
385
+ Keycloak::Admin.list_offline_session(client_id, access_token)
386
+ ```
387
+
388
+ `list_offline_session` return the list of [offline sessions](https://github.com/keycloak/keycloak-documentation/blob/master/server_admin/topics/sessions/offline.adoc) for a given client.
383
389
 
384
390
  ```ruby
385
391
  Keycloak::Admin.update_effective_user_roles(id, client_id, roles_names, access_token = nil)
@@ -8,5 +8,7 @@ Keycloak.keycloak_controller = 'session'
8
8
  Keycloak.realm = ''
9
9
  # relm url (only if the installation file is not present)
10
10
  Keycloak.auth_server_url = ''
11
+ # if present, will be used to override `Host` header in request. This is usefull when Keycloack has an internal and an external domain name.
12
+ Keycloak.custom_host_header = nil
11
13
  # The introspect of the token will be executed every time the Keycloak::Client.has_role? method is invoked, if this setting is set to true.
12
14
  Keycloak.validate_token_when_call_has_role = false
@@ -1,3 +1,3 @@
1
1
  module Keycloak
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.3'.freeze
3
3
  end
@@ -16,7 +16,7 @@ module Keycloak
16
16
  class << self
17
17
  attr_accessor :proxy, :generate_request_exception, :keycloak_controller,
18
18
  :proc_cookie_token, :proc_external_attributes,
19
- :realm, :auth_server_url, :validate_token_when_call_has_role
19
+ :realm, :auth_server_url, :validate_token_when_call_has_role, :custom_host_header
20
20
  end
21
21
 
22
22
  def self.explode_exception
@@ -86,6 +86,11 @@ module Keycloak
86
86
 
87
87
  payload = { 'client_id' => client_id, 'client_secret' => secret, 'audience' => client_id, 'grant_type' => 'urn:ietf:params:oauth:grant-type:token-exchange', 'subject_token_type' => 'urn:ietf:params:oauth:token-type:access_token', 'subject_issuer' => issuer, 'subject_token' => issuer_token }
88
88
  header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
89
+
90
+ if !@custom_host_header.nil?
91
+ header['Host'] = @custom_host_header
92
+ end
93
+
89
94
  _request = -> do
90
95
  RestClient.post(token_endpoint, payload, header){|response, request, result|
91
96
  # case response.code
@@ -161,6 +166,10 @@ module Keycloak
161
166
  header = { 'Content-Type' => 'application/x-www-form-urlencoded',
162
167
  'authorization' => authorization }
163
168
 
169
+ if !@custom_host_header.nil?
170
+ header['Host'] = @custom_host_header
171
+ end
172
+
164
173
  _request = -> do
165
174
  RestClient.post(token_introspection_endpoint, payload, header){|response, request, result|
166
175
  case response.code
@@ -208,6 +217,10 @@ module Keycloak
208
217
 
209
218
  header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
210
219
 
220
+ if !@custom_host_header.nil?
221
+ header['Host'] = @custom_host_header
222
+ end
223
+
211
224
  final_url = if redirect_uri.empty?
212
225
  end_session_endpoint
213
226
  else
@@ -241,6 +254,10 @@ module Keycloak
241
254
 
242
255
  header = { 'Content-Type' => 'application/x-www-form-urlencoded' }
243
256
 
257
+ if !@custom_host_header.nil?
258
+ header['Host'] = @custom_host_header
259
+ end
260
+
244
261
  _request = -> do
245
262
  RestClient.post(userinfo_endpoint, payload, header){ |response, request, result|
246
263
  case response.code
@@ -343,6 +360,7 @@ module Keycloak
343
360
  @secret = installation["credentials"]["secret"]
344
361
  @public_key = installation["realm-public-key"]
345
362
  @auth_server_url = installation["auth-server-url"]
363
+ @custom_host_header = installation["custom_host_header"]
346
364
  else
347
365
  raise "#{Keycloak.installation_file} and relm settings not found." if isempty?(Keycloak.realm) || isempty?(Keycloak.auth_server_url)
348
366
 
@@ -397,6 +415,10 @@ module Keycloak
397
415
  def self.mount_request_token(payload)
398
416
  header = {'Content-Type' => 'application/x-www-form-urlencoded'}
399
417
 
418
+ if !@custom_host_header.nil?
419
+ header['Host'] = @custom_host_header
420
+ end
421
+
400
422
  _request = -> do
401
423
  RestClient.post(@configuration['token_endpoint'], payload, header){|response, request, result|
402
424
  case response.code
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqsc-keycloak-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guilherme Portugues
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-12-26 00:00:00.000000000 Z
12
+ date: 2020-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -103,6 +103,7 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
+ - ".github/workflows/ruby.yml"
106
107
  - ".gitignore"
107
108
  - ".rspec"
108
109
  - ".travis.yml"