keycloak-api-rails 0.12.1 → 0.12.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: 33430ef5e956f8a04b6e3de5b91bd4e3103fa45a005fccea305358f07936eeb3
4
- data.tar.gz: '09a89800ff5dec64ba052f666dce839593ed85e3bf5d226d00050e2850387163'
3
+ metadata.gz: 834cdb0350ed3724a6f28aed40c36b3a51d96850f49ef8a0b9946a8135f1ca56
4
+ data.tar.gz: 8ec6a52a53e688cb20feaf9762e17bde13fbbf483d0413bf95400833a79ac6e1
5
5
  SHA512:
6
- metadata.gz: 1965c3091b5a5b205e4c83dd233768889ea91a3585ddb5b81ed2d13643b0fbce2fada58ddcedb9bbb61865477395eafdd18f2fe15b4f49bbef497b130484262f
7
- data.tar.gz: 5869dd930cb4f68189f38f7bc2c7405e92b59c384a82718aed93a2d158b6ce29de563e6363b557a1ef5744ca73985d98661be4a56c901b96a0a0c17cb2a1f04a
6
+ metadata.gz: 947afe4ef457d63988f592b16a57b9dd8bf7a58e7c6f403525e5a228a992c49d51262541cd5feb6b7c3c7722fd7390f7447fb698c273f359448ed3f46b3d2fd8
7
+ data.tar.gz: efb05a679ff2c389618534e975425276c9007651b495abc19a7f381116fe81fba490571e4d751cfbd69aa8a02c685d1738b543fabd99ca9fe07dcf9319a87701
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ 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
+
9
+ ## [0.12.3] - 2024-06-20
10
+
11
+ * Add a debug log when not being able to validate a JWT
12
+
13
+ ## [0.12.2] - 2023-06-03
14
+
15
+ * Avoid methods `logger`, `service` an `config` of `Keycloak::Authentication` to conflict with other concerns, such as rails. (thanks to @mkrawc)
16
+
8
17
  ## [0.12.1] - 2023-04-15
9
18
 
10
19
  * Fixes for opt-in mode (#48) (thanks to @theSteveMitchell)
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:2.7.5-slim-bullseye
1
+ FROM ruby:3.2.2-slim-bullseye
2
2
 
3
3
  RUN apt-get update -qq && apt-get install -y build-essential git ruby-dev && apt-get clean && \
4
4
  mkdir -p /usr/src/app/lib/keycloak-api-rails
data/Gemfile.lock CHANGED
@@ -1,183 +1,219 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- keycloak-api-rails (0.12.0)
4
+ keycloak-api-rails (0.12.3)
5
5
  json-jwt (>= 1.11.0)
6
6
  rails (>= 4.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.4.3)
12
- actionpack (= 7.0.4.3)
13
- activesupport (= 7.0.4.3)
11
+ actioncable (7.1.3.4)
12
+ actionpack (= 7.1.3.4)
13
+ activesupport (= 7.1.3.4)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.4.3)
17
- actionpack (= 7.0.4.3)
18
- activejob (= 7.0.4.3)
19
- activerecord (= 7.0.4.3)
20
- activestorage (= 7.0.4.3)
21
- activesupport (= 7.0.4.3)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (7.1.3.4)
18
+ actionpack (= 7.1.3.4)
19
+ activejob (= 7.1.3.4)
20
+ activerecord (= 7.1.3.4)
21
+ activestorage (= 7.1.3.4)
22
+ activesupport (= 7.1.3.4)
22
23
  mail (>= 2.7.1)
23
24
  net-imap
24
25
  net-pop
25
26
  net-smtp
26
- actionmailer (7.0.4.3)
27
- actionpack (= 7.0.4.3)
28
- actionview (= 7.0.4.3)
29
- activejob (= 7.0.4.3)
30
- activesupport (= 7.0.4.3)
27
+ actionmailer (7.1.3.4)
28
+ actionpack (= 7.1.3.4)
29
+ actionview (= 7.1.3.4)
30
+ activejob (= 7.1.3.4)
31
+ activesupport (= 7.1.3.4)
31
32
  mail (~> 2.5, >= 2.5.4)
32
33
  net-imap
33
34
  net-pop
34
35
  net-smtp
35
- rails-dom-testing (~> 2.0)
36
- actionpack (7.0.4.3)
37
- actionview (= 7.0.4.3)
38
- activesupport (= 7.0.4.3)
39
- rack (~> 2.0, >= 2.2.0)
36
+ rails-dom-testing (~> 2.2)
37
+ actionpack (7.1.3.4)
38
+ actionview (= 7.1.3.4)
39
+ activesupport (= 7.1.3.4)
40
+ nokogiri (>= 1.8.5)
41
+ racc
42
+ rack (>= 2.2.4)
43
+ rack-session (>= 1.0.1)
40
44
  rack-test (>= 0.6.3)
41
- rails-dom-testing (~> 2.0)
42
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.4.3)
44
- actionpack (= 7.0.4.3)
45
- activerecord (= 7.0.4.3)
46
- activestorage (= 7.0.4.3)
47
- activesupport (= 7.0.4.3)
45
+ rails-dom-testing (~> 2.2)
46
+ rails-html-sanitizer (~> 1.6)
47
+ actiontext (7.1.3.4)
48
+ actionpack (= 7.1.3.4)
49
+ activerecord (= 7.1.3.4)
50
+ activestorage (= 7.1.3.4)
51
+ activesupport (= 7.1.3.4)
48
52
  globalid (>= 0.6.0)
49
53
  nokogiri (>= 1.8.5)
50
- actionview (7.0.4.3)
51
- activesupport (= 7.0.4.3)
54
+ actionview (7.1.3.4)
55
+ activesupport (= 7.1.3.4)
52
56
  builder (~> 3.1)
53
- erubi (~> 1.4)
54
- rails-dom-testing (~> 2.0)
55
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.4.3)
57
- activesupport (= 7.0.4.3)
57
+ erubi (~> 1.11)
58
+ rails-dom-testing (~> 2.2)
59
+ rails-html-sanitizer (~> 1.6)
60
+ activejob (7.1.3.4)
61
+ activesupport (= 7.1.3.4)
58
62
  globalid (>= 0.3.6)
59
- activemodel (7.0.4.3)
60
- activesupport (= 7.0.4.3)
61
- activerecord (7.0.4.3)
62
- activemodel (= 7.0.4.3)
63
- activesupport (= 7.0.4.3)
64
- activestorage (7.0.4.3)
65
- actionpack (= 7.0.4.3)
66
- activejob (= 7.0.4.3)
67
- activerecord (= 7.0.4.3)
68
- activesupport (= 7.0.4.3)
63
+ activemodel (7.1.3.4)
64
+ activesupport (= 7.1.3.4)
65
+ activerecord (7.1.3.4)
66
+ activemodel (= 7.1.3.4)
67
+ activesupport (= 7.1.3.4)
68
+ timeout (>= 0.4.0)
69
+ activestorage (7.1.3.4)
70
+ actionpack (= 7.1.3.4)
71
+ activejob (= 7.1.3.4)
72
+ activerecord (= 7.1.3.4)
73
+ activesupport (= 7.1.3.4)
69
74
  marcel (~> 1.0)
70
- mini_mime (>= 1.1.0)
71
- activesupport (7.0.4.3)
75
+ activesupport (7.1.3.4)
76
+ base64
77
+ bigdecimal
72
78
  concurrent-ruby (~> 1.0, >= 1.0.2)
79
+ connection_pool (>= 2.2.5)
80
+ drb
73
81
  i18n (>= 1.6, < 2)
74
82
  minitest (>= 5.1)
83
+ mutex_m
75
84
  tzinfo (~> 2.0)
76
85
  aes_key_wrap (1.1.0)
77
- bindata (2.4.15)
78
- builder (3.2.4)
86
+ base64 (0.2.0)
87
+ bigdecimal (3.1.8)
88
+ bindata (2.5.0)
89
+ builder (3.3.0)
79
90
  byebug (11.1.3)
80
- concurrent-ruby (1.2.2)
91
+ concurrent-ruby (1.3.3)
92
+ connection_pool (2.4.1)
81
93
  crass (1.0.6)
82
- date (3.3.3)
83
- diff-lcs (1.5.0)
84
- erubi (1.12.0)
85
- faraday (2.7.4)
86
- faraday-net_http (>= 2.0, < 3.1)
87
- ruby2_keywords (>= 0.0.4)
94
+ date (3.3.4)
95
+ diff-lcs (1.5.1)
96
+ drb (2.2.1)
97
+ erubi (1.13.0)
98
+ faraday (2.9.2)
99
+ faraday-net_http (>= 2.0, < 3.2)
88
100
  faraday-follow_redirects (0.3.0)
89
101
  faraday (>= 1, < 3)
90
- faraday-net_http (3.0.2)
91
- globalid (1.1.0)
92
- activesupport (>= 5.0)
93
- i18n (1.12.0)
102
+ faraday-net_http (3.1.0)
103
+ net-http
104
+ globalid (1.2.1)
105
+ activesupport (>= 6.1)
106
+ i18n (1.14.5)
94
107
  concurrent-ruby (~> 1.0)
95
- json-jwt (1.16.3)
108
+ io-console (0.7.2)
109
+ irb (1.13.2)
110
+ rdoc (>= 4.0.0)
111
+ reline (>= 0.4.2)
112
+ json-jwt (1.16.6)
96
113
  activesupport (>= 4.2)
97
114
  aes_key_wrap
115
+ base64
98
116
  bindata
99
117
  faraday (~> 2.0)
100
118
  faraday-follow_redirects
101
- loofah (2.20.0)
119
+ loofah (2.22.0)
102
120
  crass (~> 1.0.2)
103
- nokogiri (>= 1.5.9)
121
+ nokogiri (>= 1.12.0)
104
122
  mail (2.8.1)
105
123
  mini_mime (>= 0.1.1)
106
124
  net-imap
107
125
  net-pop
108
126
  net-smtp
109
- marcel (1.0.2)
110
- method_source (1.0.0)
111
- mini_mime (1.1.2)
112
- mini_portile2 (2.8.1)
113
- minitest (5.18.0)
114
- net-imap (0.3.4)
127
+ marcel (1.0.4)
128
+ mini_mime (1.1.5)
129
+ mini_portile2 (2.8.7)
130
+ minitest (5.24.0)
131
+ mutex_m (0.2.0)
132
+ net-http (0.4.1)
133
+ uri
134
+ net-imap (0.4.13)
115
135
  date
116
136
  net-protocol
117
137
  net-pop (0.1.2)
118
138
  net-protocol
119
- net-protocol (0.2.1)
139
+ net-protocol (0.2.2)
120
140
  timeout
121
- net-smtp (0.3.3)
141
+ net-smtp (0.5.0)
122
142
  net-protocol
123
- nio4r (2.5.9)
124
- nokogiri (1.14.3)
125
- mini_portile2 (~> 2.8.0)
143
+ nio4r (2.7.3)
144
+ nokogiri (1.16.6)
145
+ mini_portile2 (~> 2.8.2)
126
146
  racc (~> 1.4)
127
- racc (1.6.2)
128
- rack (2.2.6.4)
147
+ psych (5.1.2)
148
+ stringio
149
+ racc (1.8.0)
150
+ rack (3.1.3)
151
+ rack-session (2.0.0)
152
+ rack (>= 3.0.0)
129
153
  rack-test (2.1.0)
130
154
  rack (>= 1.3)
131
- rails (7.0.4.3)
132
- actioncable (= 7.0.4.3)
133
- actionmailbox (= 7.0.4.3)
134
- actionmailer (= 7.0.4.3)
135
- actionpack (= 7.0.4.3)
136
- actiontext (= 7.0.4.3)
137
- actionview (= 7.0.4.3)
138
- activejob (= 7.0.4.3)
139
- activemodel (= 7.0.4.3)
140
- activerecord (= 7.0.4.3)
141
- activestorage (= 7.0.4.3)
142
- activesupport (= 7.0.4.3)
155
+ rackup (2.1.0)
156
+ rack (>= 3)
157
+ webrick (~> 1.8)
158
+ rails (7.1.3.4)
159
+ actioncable (= 7.1.3.4)
160
+ actionmailbox (= 7.1.3.4)
161
+ actionmailer (= 7.1.3.4)
162
+ actionpack (= 7.1.3.4)
163
+ actiontext (= 7.1.3.4)
164
+ actionview (= 7.1.3.4)
165
+ activejob (= 7.1.3.4)
166
+ activemodel (= 7.1.3.4)
167
+ activerecord (= 7.1.3.4)
168
+ activestorage (= 7.1.3.4)
169
+ activesupport (= 7.1.3.4)
143
170
  bundler (>= 1.15.0)
144
- railties (= 7.0.4.3)
145
- rails-dom-testing (2.0.3)
146
- activesupport (>= 4.2.0)
171
+ railties (= 7.1.3.4)
172
+ rails-dom-testing (2.2.0)
173
+ activesupport (>= 5.0.0)
174
+ minitest
147
175
  nokogiri (>= 1.6)
148
- rails-html-sanitizer (1.5.0)
149
- loofah (~> 2.19, >= 2.19.1)
150
- railties (7.0.4.3)
151
- actionpack (= 7.0.4.3)
152
- activesupport (= 7.0.4.3)
153
- method_source
176
+ rails-html-sanitizer (1.6.0)
177
+ loofah (~> 2.21)
178
+ nokogiri (~> 1.14)
179
+ railties (7.1.3.4)
180
+ actionpack (= 7.1.3.4)
181
+ activesupport (= 7.1.3.4)
182
+ irb
183
+ rackup (>= 1.0.0)
154
184
  rake (>= 12.2)
155
- thor (~> 1.0)
156
- zeitwerk (~> 2.5)
157
- rake (13.0.6)
185
+ thor (~> 1.0, >= 1.2.2)
186
+ zeitwerk (~> 2.6)
187
+ rake (13.2.1)
188
+ rdoc (6.7.0)
189
+ psych (>= 4.0.0)
190
+ reline (0.5.9)
191
+ io-console (~> 0.5)
158
192
  rspec (3.12.0)
159
193
  rspec-core (~> 3.12.0)
160
194
  rspec-expectations (~> 3.12.0)
161
195
  rspec-mocks (~> 3.12.0)
162
- rspec-core (3.12.1)
196
+ rspec-core (3.12.3)
163
197
  rspec-support (~> 3.12.0)
164
- rspec-expectations (3.12.2)
198
+ rspec-expectations (3.12.4)
165
199
  diff-lcs (>= 1.2.0, < 2.0)
166
200
  rspec-support (~> 3.12.0)
167
- rspec-mocks (3.12.5)
201
+ rspec-mocks (3.12.7)
168
202
  diff-lcs (>= 1.2.0, < 2.0)
169
203
  rspec-support (~> 3.12.0)
170
- rspec-support (3.12.0)
171
- ruby2_keywords (0.0.5)
172
- thor (1.2.1)
204
+ rspec-support (3.12.2)
205
+ stringio (3.1.1)
206
+ thor (1.3.1)
173
207
  timecop (0.9.6)
174
- timeout (0.3.2)
208
+ timeout (0.4.1)
175
209
  tzinfo (2.0.6)
176
210
  concurrent-ruby (~> 1.0)
177
- websocket-driver (0.7.5)
211
+ uri (0.13.0)
212
+ webrick (1.8.1)
213
+ websocket-driver (0.7.6)
178
214
  websocket-extensions (>= 0.1.0)
179
215
  websocket-extensions (0.1.5)
180
- zeitwerk (2.6.7)
216
+ zeitwerk (2.6.16)
181
217
 
182
218
  PLATFORMS
183
219
  ruby
@@ -189,4 +225,4 @@ DEPENDENCIES
189
225
  timecop (= 0.9.6)
190
226
 
191
227
  BUNDLED WITH
192
- 2.1.4
228
+ 2.4.13
data/README.md CHANGED
@@ -5,7 +5,7 @@ This gem validates Keycloak JWT token for Ruby On Rails APIs.
5
5
  ## Install
6
6
 
7
7
  ```ruby
8
- gem "keycloak-api-rails", "0.12.0"
8
+ gem "keycloak-api-rails", "0.12.3"
9
9
  ```
10
10
 
11
11
  ## Token validation
@@ -219,4 +219,5 @@ From the `keycloak-rails-api` directory:
219
219
 
220
220
  ## Next developments
221
221
 
222
- * Manage multiple realms
222
+ * Manage multiple realms
223
+ * Avoid duplicate code in Keycloak::Middleware and `Keycloak::Authentication`
@@ -11,23 +11,21 @@ module Keycloak
11
11
  protected
12
12
 
13
13
  def keycloak_authenticate
14
-
15
14
  env = request.env
16
15
  method = env["REQUEST_METHOD"]
17
16
  path = env["PATH_INFO"]
18
17
  uri = env["REQUEST_URI"]
19
18
 
20
- logger.debug("Start authentication for #{method} : #{path}")
21
- token = service.read_token(uri, env)
22
- decoded_token = service.decode_and_verify(token)
19
+ Keycloak.logger.debug("Start authentication for #{method} : #{path}")
20
+ token = Keycloak.service.read_token(uri, env)
21
+ decoded_token = Keycloak.service.decode_and_verify(token)
23
22
  authentication_succeeded(env, decoded_token)
24
-
25
23
  rescue TokenError => e
26
24
  authentication_failed(e.message)
27
25
  end
28
26
 
29
27
  def authentication_failed(message)
30
- logger.info(message)
28
+ Keycloak.logger.info(message)
31
29
  render status: :unauthorized, json: { error: message }
32
30
  end
33
31
 
@@ -36,22 +34,10 @@ module Keycloak
36
34
  Helper.assign_current_authorized_party(env, decoded_token)
37
35
  Helper.assign_current_user_email(env, decoded_token)
38
36
  Helper.assign_current_user_locale(env, decoded_token)
39
- Helper.assign_current_user_custom_attributes(env, decoded_token, config.custom_attributes)
37
+ Helper.assign_current_user_custom_attributes(env, decoded_token, Keycloak.config.custom_attributes)
40
38
  Helper.assign_realm_roles(env, decoded_token)
41
39
  Helper.assign_resource_roles(env, decoded_token)
42
40
  Helper.assign_keycloak_token(env, decoded_token)
43
41
  end
44
-
45
- def service
46
- Keycloak.service
47
- end
48
-
49
- def logger
50
- Keycloak.logger
51
- end
52
-
53
- def config
54
- Keycloak.config
55
- end
56
42
  end
57
- end
43
+ end
@@ -20,11 +20,11 @@ module Keycloak
20
20
  @app.call(env)
21
21
  end
22
22
  rescue TokenError => e
23
+ logger.debug("The error causing the Token to fail: #{e.original_error&.message || e.message}")
23
24
  authentication_failed(e.message)
24
25
  end
25
26
 
26
27
  def authentication_failed(message)
27
- logger.info(message)
28
28
  [401, {"Content-Type" => "application/json"}, [ { error: message }.to_json]]
29
29
  end
30
30
 
@@ -1,3 +1,3 @@
1
1
  module Keycloak
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keycloak-api-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorent Lempereur
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-15 00:00:00.000000000 Z
11
+ date: 2024-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -120,7 +120,7 @@ homepage: https://github.com/looorent/keycloak-api-rails
120
120
  licenses:
121
121
  - MIT
122
122
  metadata: {}
123
- post_install_message:
123
+ post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
126
126
  - lib
@@ -135,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.0.3.1
139
- signing_key:
138
+ rubygems_version: 3.5.11
139
+ signing_key:
140
140
  specification_version: 4
141
141
  summary: Rails middleware that validates Authorization token emitted by Keycloak
142
142
  test_files: []