gitlab-omniauth-openid-connect 0.6.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/CONTRIBUTING.md +40 -0
- data/README.md +2 -0
- data/lib/omniauth/openid_connect/version.rb +1 -1
- data/lib/omniauth/strategies/openid_connect.rb +27 -17
- data/test/lib/omniauth/strategies/openid_connect_test.rb +30 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe87cbb7313b1a3d1c25fa167d6a400b076043eb029b603f201e9c8f2bc06a0
|
4
|
+
data.tar.gz: 7386c0d5374abd0e310b28bd4a7cca97b0fa71e3a0e66f34d1e650ac16c8c8dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34b17d1e9911b4e262efcddc65b7b3f83e9eda3285ca8a3309d37abb3128b9319c1d35a9666b78bf6401d9d02e1ff89011b3b4d7fcb2278fda9187d9d972a56a
|
7
|
+
data.tar.gz: ef6276095ef55576545620e9de38098872990a280b9e3c4ea38de48e25755c94dc272b5bce90d04a09c14be6ba758aeb6a141ef5078d7b80d97f3d42f79b852c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# v0.9.1 (01.03.2022)
|
2
|
+
|
3
|
+
- [Assume public key encryption unless HMAC is specified](https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect/-/merge_requests/19)
|
4
|
+
|
5
|
+
# v0.9.0 (01.03.2022)
|
6
|
+
|
7
|
+
- [Add support for ES[256|384|512|256K] algorithms](https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect/-/merge_requests/17)
|
8
|
+
|
9
|
+
# v0.8.0 (07.16.2021)
|
10
|
+
|
11
|
+
- [Add `jwt_secret_base64` option to support binary secrets](https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect/-/merge_requests/12)
|
12
|
+
|
13
|
+
# v0.7.0 (07.16.2021)
|
14
|
+
|
15
|
+
- [Add `jwt_secret` option to support Keycloak private key](https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect/-/merge_requests/10)
|
16
|
+
|
1
17
|
# v0.6.0 (07.08.2021)
|
2
18
|
|
3
19
|
- [Support verification of HS256-signed JWTs](https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect/-/merge_requests/8)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## Developer Certificate of Origin and License
|
2
|
+
|
3
|
+
By contributing to GitLab B.V., you accept and agree to the following terms and
|
4
|
+
conditions for your present and future contributions submitted to GitLab B.V.
|
5
|
+
Except for the license granted herein to GitLab B.V. and recipients of software
|
6
|
+
distributed by GitLab B.V., you reserve all right, title, and interest in and to
|
7
|
+
your Contributions.
|
8
|
+
|
9
|
+
All contributions are subject to the Developer Certificate of Origin and license set out at [docs.gitlab.com/ce/legal/developer_certificate_of_origin](https://docs.gitlab.com/ce/legal/developer_certificate_of_origin).
|
10
|
+
|
11
|
+
_This notice should stay as the first item in the CONTRIBUTING.md file._
|
12
|
+
|
13
|
+
## Code of conduct
|
14
|
+
|
15
|
+
As contributors and maintainers of this project, we pledge to respect all people
|
16
|
+
who contribute through reporting issues, posting feature requests, updating
|
17
|
+
documentation, submitting pull requests or patches, and other activities.
|
18
|
+
|
19
|
+
We are committed to making participation in this project a harassment-free
|
20
|
+
experience for everyone, regardless of level of experience, gender, gender
|
21
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
22
|
+
body size, race, ethnicity, age, or religion.
|
23
|
+
|
24
|
+
Examples of unacceptable behavior by participants include the use of sexual
|
25
|
+
language or imagery, derogatory comments or personal attacks, trolling, public
|
26
|
+
or private harassment, insults, or other unprofessional conduct.
|
27
|
+
|
28
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
29
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
30
|
+
not aligned to this Code of Conduct. Project maintainers who do not follow the
|
31
|
+
Code of Conduct may be removed from the project team.
|
32
|
+
|
33
|
+
This code of conduct applies both within project spaces and in public spaces
|
34
|
+
when an individual is representing the project or its community.
|
35
|
+
|
36
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior can be
|
37
|
+
reported by emailing contact@gitlab.com.
|
38
|
+
|
39
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://contributor-covenant.org), version 1.1.0,
|
40
|
+
available at [https://contributor-covenant.org/version/1/1/0/](https://contributor-covenant.org/version/1/1/0/).
|
data/README.md
CHANGED
@@ -66,6 +66,8 @@ config.omniauth :openid_connect, {
|
|
66
66
|
| post_logout_redirect_uri | The logout redirect uri to use per the [session management draft](https://openid.net/specs/openid-connect-session-1_0.html) | no | empty | https://myapp.com/logout/callback |
|
67
67
|
| uid_field | The field of the user info response to be used as a unique id | no | 'sub' | "sub", "preferred_username" |
|
68
68
|
| client_options | A hash of client options detailed in its own section | yes | | |
|
69
|
+
| jwt_secret | For HMAC with SHA2 (e.g. HS256) signing algorithms, specify the secret used to sign the JWT token. Defaults to the OAuth2 client secret if not specified. For secrets in binary, use `jwt_secret_base64`. | no | client_options.secret | "mysecret" |
|
70
|
+
| jwt_secret_base64 | For HMAC with SHA2 (e.g. HS256) signing algorithms, specify the base64-encoded secret used to sign the JWT token. Defaults to the OAuth2 client secret if not specified. `jwt_secret` takes precedence. | no | client_options.secret | "bXlzZWNyZXQ=\n"
|
69
71
|
|
70
72
|
### Client Config Options
|
71
73
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'addressable/uri'
|
4
|
+
require 'base64'
|
4
5
|
require 'timeout'
|
5
6
|
require 'net/http'
|
6
7
|
require 'open-uri'
|
@@ -36,7 +37,9 @@ module OmniAuth
|
|
36
37
|
|
37
38
|
option :issuer
|
38
39
|
option :discovery, false
|
39
|
-
option :client_signing_alg
|
40
|
+
option :client_signing_alg # Deprecated since we detect what is used to sign the JWT
|
41
|
+
option :jwt_secret
|
42
|
+
option :jwt_secret_base64
|
40
43
|
option :client_jwk_signing_key
|
41
44
|
option :client_x509_signing_key
|
42
45
|
option :scope, [:openid]
|
@@ -181,16 +184,28 @@ module OmniAuth
|
|
181
184
|
@public_key ||= begin
|
182
185
|
if options.discovery
|
183
186
|
config.jwks
|
184
|
-
elsif
|
185
|
-
|
187
|
+
elsif configured_public_key
|
188
|
+
configured_public_key
|
186
189
|
elsif client_options.jwks_uri
|
187
190
|
fetch_key
|
188
191
|
end
|
189
192
|
end
|
190
193
|
end
|
191
194
|
|
195
|
+
# Some OpenID providers use the OAuth2 client secret as the shared secret, but
|
196
|
+
# Keycloak uses a separate key that's stored inside the database.
|
197
|
+
def secret
|
198
|
+
options.jwt_secret || base64_decoded_jwt_secret || client_options.secret
|
199
|
+
end
|
200
|
+
|
192
201
|
private
|
193
202
|
|
203
|
+
def base64_decoded_jwt_secret
|
204
|
+
return unless options.jwt_secret_base64
|
205
|
+
|
206
|
+
Base64.decode64(options.jwt_secret_base64)
|
207
|
+
end
|
208
|
+
|
194
209
|
def fetch_key
|
195
210
|
@fetch_key ||= parse_jwk_key(::OpenIDConnect.http_client.get_content(client_options.jwks_uri))
|
196
211
|
end
|
@@ -250,10 +265,10 @@ module OmniAuth
|
|
250
265
|
|
251
266
|
keyset =
|
252
267
|
case algorithm
|
253
|
-
when :RS256, :RS384, :RS512
|
254
|
-
public_key
|
255
268
|
when :HS256, :HS384, :HS512
|
256
|
-
|
269
|
+
secret
|
270
|
+
else
|
271
|
+
public_key
|
257
272
|
end
|
258
273
|
|
259
274
|
decoded.verify!(keyset)
|
@@ -327,17 +342,12 @@ module OmniAuth
|
|
327
342
|
super
|
328
343
|
end
|
329
344
|
|
330
|
-
def
|
331
|
-
@
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
if options.client_jwk_signing_key
|
337
|
-
parse_jwk_key(options.client_jwk_signing_key)
|
338
|
-
elsif options.client_x509_signing_key
|
339
|
-
parse_x509_key(options.client_x509_signing_key)
|
340
|
-
end
|
345
|
+
def configured_public_key
|
346
|
+
@configured_public_key ||= begin
|
347
|
+
if options.client_jwk_signing_key
|
348
|
+
parse_jwk_key(options.client_jwk_signing_key)
|
349
|
+
elsif options.client_x509_signing_key
|
350
|
+
parse_x509_key(options.client_x509_signing_key)
|
341
351
|
end
|
342
352
|
end
|
343
353
|
end
|
@@ -297,6 +297,34 @@ module OmniAuth
|
|
297
297
|
strategy.callback_phase
|
298
298
|
end
|
299
299
|
|
300
|
+
def test_callback_phase_with_hs256_jwt_secret
|
301
|
+
state = SecureRandom.hex(16)
|
302
|
+
request.stubs(:params).returns('id_token' => jwt_with_hs256.to_s, 'state' => state)
|
303
|
+
request.stubs(:path_info).returns('')
|
304
|
+
|
305
|
+
strategy.options.issuer = issuer
|
306
|
+
strategy.options.jwt_secret = hmac_secret
|
307
|
+
strategy.options.response_type = 'id_token'
|
308
|
+
|
309
|
+
strategy.unstub(:user_info)
|
310
|
+
strategy.call!('rack.session' => { 'omniauth.state' => state, 'omniauth.nonce' => nonce })
|
311
|
+
strategy.callback_phase
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_callback_phase_with_hs256_base64_jwt_secret
|
315
|
+
state = SecureRandom.hex(16)
|
316
|
+
request.stubs(:params).returns('id_token' => jwt_with_hs256.to_s, 'state' => state)
|
317
|
+
request.stubs(:path_info).returns('')
|
318
|
+
|
319
|
+
strategy.options.issuer = issuer
|
320
|
+
strategy.options.jwt_secret_base64 = Base64.encode64(hmac_secret)
|
321
|
+
strategy.options.response_type = 'id_token'
|
322
|
+
|
323
|
+
strategy.unstub(:user_info)
|
324
|
+
strategy.call!('rack.session' => { 'omniauth.state' => state, 'omniauth.nonce' => nonce })
|
325
|
+
strategy.callback_phase
|
326
|
+
end
|
327
|
+
|
300
328
|
def test_callback_phase_with_id_token_no_matching_key
|
301
329
|
rsa_private = OpenSSL::PKey::RSA.generate(2048)
|
302
330
|
other_rsa_private = OpenSSL::PKey::RSA.generate(2048)
|
@@ -692,10 +720,10 @@ module OmniAuth
|
|
692
720
|
assert_equal OpenSSL::PKey::RSA, strategy.public_key.class
|
693
721
|
end
|
694
722
|
|
695
|
-
def
|
723
|
+
def test_secret_with_hmac
|
696
724
|
strategy.options.client_options.secret = 'secret'
|
697
725
|
strategy.options.client_signing_alg = :HS256
|
698
|
-
assert_equal strategy.options.client_options.secret, strategy.
|
726
|
+
assert_equal strategy.options.client_options.secret, strategy.secret
|
699
727
|
end
|
700
728
|
|
701
729
|
def test_id_token_auth_hash
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-omniauth-openid-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bohn
|
8
8
|
- Ilya Shcherbinin
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -209,6 +209,7 @@ files:
|
|
209
209
|
- ".rubocop.yml"
|
210
210
|
- ".travis.yml"
|
211
211
|
- CHANGELOG.md
|
212
|
+
- CONTRIBUTING.md
|
212
213
|
- Gemfile
|
213
214
|
- Guardfile
|
214
215
|
- LICENSE.txt
|
@@ -229,7 +230,7 @@ homepage: https://gitlab.com/gitlab-org/gitlab-omniauth-openid-connect
|
|
229
230
|
licenses:
|
230
231
|
- MIT
|
231
232
|
metadata: {}
|
232
|
-
post_install_message:
|
233
|
+
post_install_message:
|
233
234
|
rdoc_options: []
|
234
235
|
require_paths:
|
235
236
|
- lib
|
@@ -244,8 +245,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
245
|
- !ruby/object:Gem::Version
|
245
246
|
version: '0'
|
246
247
|
requirements: []
|
247
|
-
rubygems_version: 3.
|
248
|
-
signing_key:
|
248
|
+
rubygems_version: 3.2.28
|
249
|
+
signing_key:
|
249
250
|
specification_version: 4
|
250
251
|
summary: OpenID Connect Strategy for OmniAuth
|
251
252
|
test_files:
|