omniauth-auth0 3.1.1 → 3.2.0

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.
data/.shiprc CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "files": {
3
- "lib/omniauth-auth0/version.rb": []
3
+ "lib/omniauth-auth0/version.rb": [],
4
+ ".version": []
4
5
  },
5
6
  "prebump": "bundle install && bundle exec rake test",
6
7
  "postbump": "bundle update"
data/.version ADDED
@@ -0,0 +1 @@
1
+ v3.2.0
data/CHANGELOG.md CHANGED
@@ -1,17 +1,22 @@
1
1
  # Change Log
2
2
 
3
- ## [v3.2.0](https://github.com/auth0/omniauth-auth0/tree/v3.2.0) (2023-07-14)
4
- [Full Changelog](https://github.com/auth0/omniauth-auth0/compare/v3.1.0...v3.2.0)
3
+ ## [v3.2.0](https://github.com/auth0/omniauth-auth0/tree/v3.2.0) (2026-05-27)
4
+ [Full Changelog](https://github.com/auth0/omniauth-auth0/compare/v3.1.1...v3.2.0)
5
5
 
6
6
  **Added**
7
- - [SDK-4410] Support Organization Name in JWT validation [\#184](https://github.com/auth0/omniauth-auth0/pull/184) ([stevehobbsdev](https://github.com/stevehobbsdev))
7
+ - Add support for client assertion signing key authentication [\#203](https://github.com/auth0/omniauth-auth0/pull/203) ([kaczowkad](https://github.com/kaczowkad))
8
8
 
9
- **Fixed**
10
- - fix: upgrade to Sinatra 3 and use Rack::Session::Cookie in tests [\#165](https://github.com/auth0/omniauth-auth0/pull/165) ([stevehobbsdev](https://github.com/stevehobbsdev))
9
+ **Dependency Bumps**
10
+ - Bump faraday from 2.7.10 to 2.14.1 [\#215](https://github.com/auth0/omniauth-auth0/pull/215) ([dependabot[bot]](https://github.com/apps/dependabot))
11
+ - Bump rack from 2.2.7 to 2.2.23 [\#217](https://github.com/auth0/omniauth-auth0/pull/217) ([dependabot[bot]](https://github.com/apps/dependabot))
12
+ - Bump rexml from 3.2.5 to 3.3.9 [\#206](https://github.com/auth0/omniauth-auth0/pull/206) ([arpit-jn](https://github.com/arpit-jn))
11
13
 
12
14
  ## [v3.1.1](https://github.com/auth0/omniauth-auth0/tree/v3.1.1) (2023-03-01)
13
15
  [Full Changelog](https://github.com/auth0/omniauth-auth0/compare/v3.1.0...v3.1.1)
14
16
 
17
+ **Added**
18
+ - [SDK-4410] Support Organization Name in JWT validation [\#184](https://github.com/auth0/omniauth-auth0/pull/184) ([stevehobbsdev](https://github.com/stevehobbsdev))
19
+
15
20
  **Fixed**
16
21
  - fix: upgrade to Sinatra 3 and use Rack::Session::Cookie in tests [\#165](https://github.com/auth0/omniauth-auth0/pull/165) ([stevehobbsdev](https://github.com/stevehobbsdev))
17
22
 
data/Gemfile CHANGED
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'gem-release', '~> 2'
6
5
  gem 'jwt', '~> 2'
7
6
  gem 'rake', '~> 13'
8
7
 
@@ -20,7 +19,7 @@ group :test do
20
19
  gem 'listen', '~> 3'
21
20
  gem 'rack-test', '~> 2', '>= 2.0.2'
22
21
  gem 'rspec', '~> 3'
23
- gem 'simplecov-cobertura', '~> 2'
22
+ gem 'simplecov-cobertura', '~> 3.0'
24
23
  gem 'webmock', '~> 3'
25
24
  gem 'multi_json', '~> 1'
26
25
  end
data/Gemfile.lock CHANGED
@@ -1,34 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-auth0 (3.1.1)
4
+ omniauth-auth0 (3.2.0)
5
+ jwt (~> 2)
5
6
  omniauth (~> 2)
6
7
  omniauth-oauth2 (~> 1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- addressable (2.8.4)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- ast (2.4.2)
12
+ addressable (2.9.0)
13
+ public_suffix (>= 2.0.2, < 8.0)
14
+ ast (2.4.3)
15
+ auth-sanitizer (0.1.4)
16
+ version_gem (~> 1.1, >= 1.1.9)
17
+ base64 (0.3.0)
18
+ bigdecimal (4.1.2)
14
19
  coderay (1.1.3)
15
- crack (0.4.5)
20
+ crack (1.0.1)
21
+ bigdecimal
16
22
  rexml
17
23
  daemons (1.4.1)
18
- diff-lcs (1.5.0)
19
- docile (1.4.0)
24
+ diff-lcs (1.6.2)
25
+ docile (1.4.1)
20
26
  dotenv (2.8.1)
21
27
  eventmachine (1.2.7)
22
- faraday (2.7.10)
23
- faraday-net_http (>= 2.0, < 3.1)
24
- ruby2_keywords (>= 0.0.4)
25
- faraday-net_http (3.0.2)
26
- ffi (1.15.5)
27
- formatador (1.1.0)
28
- gem-release (2.2.2)
29
- guard (2.18.0)
28
+ faraday (2.14.2)
29
+ faraday-net_http (>= 2.0, < 3.5)
30
+ json
31
+ logger
32
+ faraday-net_http (3.4.3)
33
+ net-http (~> 0.5)
34
+ ffi (1.17.4-aarch64-linux-gnu)
35
+ ffi (1.17.4-arm64-darwin)
36
+ ffi (1.17.4-x86_64-darwin)
37
+ ffi (1.17.4-x86_64-linux-gnu)
38
+ formatador (1.2.3)
39
+ reline
40
+ guard (2.20.1)
30
41
  formatador (>= 0.2.4)
31
42
  listen (>= 2.7, < 4.0)
43
+ logger (~> 1.6)
32
44
  lumberjack (>= 1.0.12, < 2.0)
33
45
  nenv (~> 0.1)
34
46
  notiffany (~> 0.0)
@@ -40,87 +52,103 @@ GEM
40
52
  guard (~> 2.1)
41
53
  guard-compat (~> 1.1)
42
54
  rspec (>= 2.99.0, < 4.0)
43
- hashdiff (1.0.1)
44
- hashie (5.0.0)
45
- json (2.6.3)
46
- jwt (2.7.1)
47
- language_server-protocol (3.17.0.3)
48
- listen (3.8.0)
55
+ hashdiff (1.2.1)
56
+ hashie (5.1.0)
57
+ logger
58
+ io-console (0.8.2)
59
+ json (2.19.7)
60
+ jwt (2.10.3)
61
+ base64
62
+ language_server-protocol (3.17.0.5)
63
+ lint_roller (1.1.0)
64
+ listen (3.10.0)
65
+ logger
49
66
  rb-fsevent (~> 0.10, >= 0.10.3)
50
67
  rb-inotify (~> 0.9, >= 0.9.10)
51
- lumberjack (1.2.8)
52
- method_source (1.0.0)
53
- multi_json (1.15.0)
54
- multi_xml (0.6.0)
55
- mustermann (3.0.0)
56
- ruby2_keywords (~> 0.0.1)
68
+ logger (1.7.0)
69
+ lumberjack (1.4.2)
70
+ method_source (1.1.0)
71
+ multi_json (1.21.1)
72
+ multi_xml (0.9.1)
73
+ bigdecimal (>= 3.1, < 5)
74
+ mustermann (3.1.1)
57
75
  nenv (0.3.0)
76
+ net-http (0.9.1)
77
+ uri (>= 0.11.1)
58
78
  notiffany (0.1.3)
59
79
  nenv (~> 0.1)
60
80
  shellany (~> 0.0)
61
- oauth2 (2.0.9)
62
- faraday (>= 0.17.3, < 3.0)
63
- jwt (>= 1.0, < 3.0)
81
+ oauth2 (2.0.20)
82
+ auth-sanitizer (~> 0.1, >= 0.1.3)
83
+ faraday (>= 0.17.3, < 4.0)
84
+ jwt (>= 1.0, < 4.0)
85
+ logger (~> 1.2)
64
86
  multi_xml (~> 0.5)
65
87
  rack (>= 1.2, < 4)
66
- snaky_hash (~> 2.0)
67
- version_gem (~> 1.1)
68
- omniauth (2.1.1)
88
+ snaky_hash (~> 2.0, >= 2.0.4)
89
+ version_gem (~> 1.1, >= 1.1.9)
90
+ omniauth (2.1.4)
69
91
  hashie (>= 3.4.6)
92
+ logger
70
93
  rack (>= 2.2.3)
71
94
  rack-protection
72
- omniauth-oauth2 (1.8.0)
73
- oauth2 (>= 1.4, < 3)
95
+ omniauth-oauth2 (1.9.0)
96
+ oauth2 (>= 2.0.2, < 3)
74
97
  omniauth (~> 2.0)
75
- parallel (1.23.0)
76
- parser (3.2.2.3)
98
+ parallel (1.28.0)
99
+ parser (3.3.11.1)
77
100
  ast (~> 2.4.1)
78
101
  racc
79
- pry (0.14.2)
102
+ prism (1.9.0)
103
+ pry (0.16.0)
80
104
  coderay (~> 1.1)
81
105
  method_source (~> 1.0)
82
- public_suffix (5.0.3)
83
- racc (1.7.1)
84
- rack (2.2.7)
85
- rack-protection (3.0.6)
86
- rack
87
- rack-test (2.1.0)
106
+ reline (>= 0.6.0)
107
+ public_suffix (7.0.5)
108
+ racc (1.8.1)
109
+ rack (2.2.23)
110
+ rack-protection (3.2.0)
111
+ base64 (>= 0.1.0)
112
+ rack (~> 2.2, >= 2.2.4)
113
+ rack-test (2.2.0)
88
114
  rack (>= 1.3)
89
115
  rainbow (3.1.1)
90
- rake (13.0.6)
116
+ rake (13.4.2)
91
117
  rb-fsevent (0.11.2)
92
- rb-inotify (0.10.1)
118
+ rb-inotify (0.11.1)
93
119
  ffi (~> 1.0)
94
- regexp_parser (2.8.1)
95
- rexml (3.2.5)
96
- rspec (3.12.0)
97
- rspec-core (~> 3.12.0)
98
- rspec-expectations (~> 3.12.0)
99
- rspec-mocks (~> 3.12.0)
100
- rspec-core (3.12.2)
101
- rspec-support (~> 3.12.0)
102
- rspec-expectations (3.12.3)
120
+ regexp_parser (2.12.0)
121
+ reline (0.6.3)
122
+ io-console (~> 0.5)
123
+ rexml (3.4.4)
124
+ rspec (3.13.2)
125
+ rspec-core (~> 3.13.0)
126
+ rspec-expectations (~> 3.13.0)
127
+ rspec-mocks (~> 3.13.0)
128
+ rspec-core (3.13.6)
129
+ rspec-support (~> 3.13.0)
130
+ rspec-expectations (3.13.5)
103
131
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.12.0)
105
- rspec-mocks (3.12.6)
132
+ rspec-support (~> 3.13.0)
133
+ rspec-mocks (3.13.8)
106
134
  diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.12.0)
108
- rspec-support (3.12.1)
109
- rubocop (1.54.2)
135
+ rspec-support (~> 3.13.0)
136
+ rspec-support (3.13.7)
137
+ rubocop (1.86.2)
110
138
  json (~> 2.3)
111
- language_server-protocol (>= 3.17.0)
112
- parallel (~> 1.10)
113
- parser (>= 3.2.2.3)
139
+ language_server-protocol (~> 3.17.0.2)
140
+ lint_roller (~> 1.1.0)
141
+ parallel (>= 1.10)
142
+ parser (>= 3.3.0.2)
114
143
  rainbow (>= 2.2.2, < 4.0)
115
- regexp_parser (>= 1.8, < 3.0)
116
- rexml (>= 3.2.5, < 4.0)
117
- rubocop-ast (>= 1.28.0, < 2.0)
144
+ regexp_parser (>= 2.9.3, < 3.0)
145
+ rubocop-ast (>= 1.49.0, < 2.0)
118
146
  ruby-progressbar (~> 1.7)
119
- unicode-display_width (>= 2.4.0, < 3.0)
120
- rubocop-ast (1.29.0)
121
- parser (>= 3.2.1.0)
147
+ unicode-display_width (>= 2.4.0, < 4.0)
148
+ rubocop-ast (1.49.1)
149
+ parser (>= 3.3.7.2)
150
+ prism (~> 1.7)
122
151
  ruby-progressbar (1.13.0)
123
- ruby2_keywords (0.0.5)
124
152
  shellany (0.0.1)
125
153
  shotgun (0.9.2)
126
154
  rack (>= 1.0)
@@ -128,28 +156,31 @@ GEM
128
156
  docile (~> 1.1)
129
157
  simplecov-html (~> 0.11)
130
158
  simplecov_json_formatter (~> 0.1)
131
- simplecov-cobertura (2.1.0)
159
+ simplecov-cobertura (3.1.0)
132
160
  rexml
133
161
  simplecov (~> 0.19)
134
- simplecov-html (0.12.3)
162
+ simplecov-html (0.13.2)
135
163
  simplecov_json_formatter (0.1.4)
136
- sinatra (3.0.6)
164
+ sinatra (3.2.0)
137
165
  mustermann (~> 3.0)
138
166
  rack (~> 2.2, >= 2.2.4)
139
- rack-protection (= 3.0.6)
167
+ rack-protection (= 3.2.0)
140
168
  tilt (~> 2.0)
141
- snaky_hash (2.0.1)
142
- hashie
143
- version_gem (~> 1.1, >= 1.1.1)
169
+ snaky_hash (2.0.4)
170
+ hashie (>= 0.1.0, < 6)
171
+ version_gem (>= 1.1.8, < 3)
144
172
  thin (1.8.2)
145
173
  daemons (~> 1.0, >= 1.0.9)
146
174
  eventmachine (~> 1.0, >= 1.0.4)
147
175
  rack (>= 1, < 3)
148
- thor (1.2.2)
149
- tilt (2.2.0)
150
- unicode-display_width (2.4.2)
151
- version_gem (1.1.3)
152
- webmock (3.18.1)
176
+ thor (1.5.0)
177
+ tilt (2.7.0)
178
+ unicode-display_width (3.2.0)
179
+ unicode-emoji (~> 4.1)
180
+ unicode-emoji (4.2.0)
181
+ uri (1.1.1)
182
+ version_gem (1.1.9)
183
+ webmock (3.26.2)
153
184
  addressable (>= 2.8.0)
154
185
  crack (>= 0.3.2)
155
186
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -157,13 +188,15 @@ GEM
157
188
  PLATFORMS
158
189
  aarch64-linux
159
190
  arm64-darwin-21
191
+ arm64-darwin-22
192
+ arm64-darwin-23
193
+ arm64-darwin-25
160
194
  x86_64-darwin-22
161
195
  x86_64-linux
162
196
 
163
197
  DEPENDENCIES
164
198
  bundler
165
199
  dotenv (~> 2)
166
- gem-release (~> 2)
167
200
  guard-rspec (~> 4)
168
201
  jwt (~> 2)
169
202
  listen (~> 3)
@@ -175,7 +208,7 @@ DEPENDENCIES
175
208
  rspec (~> 3)
176
209
  rubocop (~> 1)
177
210
  shotgun (~> 0, >= 0.9.2)
178
- simplecov-cobertura (~> 2)
211
+ simplecov-cobertura (~> 3.0)
179
212
  sinatra (~> 3)
180
213
  thin (~> 1)
181
214
  webmock (~> 3)
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![codecov](https://codecov.io/gh/auth0/omniauth-auth0/branch/master/graph/badge.svg)](https://codecov.io/gh/auth0/omniauth-auth0)
6
6
  [![Gem Version](https://badge.fury.io/rb/omniauth-auth0.svg)](https://badge.fury.io/rb/omniauth-auth0)
7
7
  [![MIT licensed](https://img.shields.io/dub/l/vibe-d.svg?style=flat)](https://github.com/auth0/omniauth-auth0/blob/master/LICENSE)
8
+ [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/omniauth-auth0)
8
9
 
9
10
  <div>
10
11
  📚 <a href="#documentation">Documentation</a> - 🚀 <a href="#getting-started">Getting started</a> - 💻 <a href="https://www.rubydoc.info/gems/omniauth-auth0">API reference</a> - 💬 <a href="#feedback">Feedback</a>
@@ -53,6 +54,8 @@ Adding the SDK to your Rails app requires a few steps:
53
54
 
54
55
  Create the file `./config/auth0.yml` within your application directory with the following content:
55
56
 
57
+ ### For client secret authentication
58
+
56
59
  ```yml
57
60
  development:
58
61
  auth0_domain: <YOUR_DOMAIN>
@@ -60,10 +63,25 @@ development:
60
63
  auth0_client_secret: <YOUR AUTH0 CLIENT SECRET>
61
64
  ```
62
65
 
66
+ #### For client assertion signing key authentication
67
+
68
+ ```yml
69
+ development:
70
+ auth0_domain: <YOUR_DOMAIN>
71
+ auth0_client_id: <YOUR_CLIENT_ID>
72
+ auth0_client_assertion_signing_key: <YOUR AUTH0 CLIENT ASSERTION SIGNING PRIVATE KEY>
73
+ auth0_client_assertion_signing_algorithm: <YOUR AUTH0 CLIENT ASSERTION SIGNING ALGORITHM>
74
+ ```
75
+ **Note**: you must upload the corresponding public key to your Auth0 tenant, so that Auth0 is able to verify the JWT signature.
76
+
77
+ client_assertion_signing_algorithm is optional and defaults to RS256.
78
+
63
79
  ### Create the initializer
64
80
 
65
81
  Create a new Ruby file in `./config/initializers/auth0.rb` to configure the OmniAuth middleware:
66
82
 
83
+ ### For client secret authentication
84
+
67
85
  ```ruby
68
86
  AUTH0_CONFIG = Rails.application.config_for(:auth0)
69
87
 
@@ -81,6 +99,29 @@ Rails.application.config.middleware.use OmniAuth::Builder do
81
99
  end
82
100
  ```
83
101
 
102
+ #### For client assertion signing key authentication
103
+
104
+ ```ruby
105
+ AUTH0_CONFIG = Rails.application.config_for(:auth0)
106
+
107
+ Rails.application.config.middleware.use OmniAuth::Builder do
108
+ provider(
109
+ :auth0,
110
+ AUTH0_CONFIG['auth0_client_id'],
111
+ nil,
112
+ AUTH0_CONFIG['auth0_domain'],
113
+ callback_path: '/auth/auth0/callback',
114
+ authorize_params: {
115
+ scope: 'openid profile'
116
+ },
117
+ client_assertion_signing_key: OpenSSL::PKey::RSA.new(AUTH0_CONFIG[:auth0_client_assertion_signing_key]),
118
+ client_assertion_signing_algorithm: AUTH0_CONFIG[:auth0_client_assertion_signing_algorithm]
119
+ )
120
+ end
121
+ ```
122
+
123
+ **Note**: The client_assertion_signing_key must be provided as a PKey object.
124
+
84
125
  ### Create the callback controller
85
126
 
86
127
  Create a new controller `./app/controllers/auth0_controller.rb` to handle the callback from Auth0.
@@ -165,4 +206,4 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
165
206
  </p>
166
207
  <p align="center">
167
208
  This project is licensed under the MIT license. See the <a href="https://github.com/auth0/omniauth-auth0/blob/master/LICENSE"> LICENSE</a> file for more info.
168
- </p>
209
+ </p>
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jwt'
4
+ require 'securerandom'
5
+
6
+ module OmniAuth
7
+ module Auth0
8
+ # JWTToken class to generate a JWT token for client assertion
9
+ # as per the OAuth 2.0 Client Credentials Grant specification.
10
+ class JWTToken
11
+ attr_reader :client_id, :domain_url, :client_assertion_signing_key, :client_assertion_signing_algorithm
12
+
13
+ def initialize(client_id, domain_url, client_assertion_signing_key, client_assertion_signing_algorithm = nil)
14
+ @client_id = client_id
15
+ @domain_url = domain_url
16
+ @client_assertion_signing_key = client_assertion_signing_key
17
+ @client_assertion_signing_algorithm = client_assertion_signing_algorithm || 'RS256'
18
+ end
19
+
20
+ def jwt_token
21
+ JWT.encode(jwt_payload, client_assertion_signing_key, client_assertion_signing_algorithm)
22
+ end
23
+
24
+ private
25
+
26
+ def jwt_payload
27
+ {
28
+ iss: client_id,
29
+ sub: client_id,
30
+ aud: File.join(domain_url, '/oauth/token'),
31
+ iat: Time.now.utc.to_i,
32
+ exp: Time.now.utc.to_i + 60,
33
+ jti: SecureRandom.uuid
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -272,10 +272,10 @@ module OmniAuth
272
272
  if validate_as_id
273
273
  org_id = id_token['org_id']
274
274
  if !org_id || !org_id.is_a?(String)
275
- raise OmniAuth::Auth0::TokenValidationError,
275
+ raise OmniAuth::Auth0::TokenValidationError,
276
276
  'Organization Id (org_id) claim must be a string present in the ID token'
277
277
  elsif org_id != organization
278
- raise OmniAuth::Auth0::TokenValidationError,
278
+ raise OmniAuth::Auth0::TokenValidationError,
279
279
  "Organization Id (org_id) claim value mismatch in the ID token; expected '#{organization}', found '#{org_id}'"
280
280
  end
281
281
  else
@@ -4,6 +4,7 @@ require 'base64'
4
4
  require 'uri'
5
5
  require 'securerandom'
6
6
  require 'omniauth-oauth2'
7
+ require 'omniauth/auth0/jwt_token'
7
8
  require 'omniauth/auth0/jwt_validator'
8
9
  require 'omniauth/auth0/telemetry'
9
10
  require 'omniauth/auth0/errors'
@@ -13,6 +14,8 @@ module OmniAuth
13
14
  # Auth0 OmniAuth strategy
14
15
  class Auth0 < OmniAuth::Strategies::OAuth2
15
16
  include OmniAuth::Auth0::Telemetry
17
+ AUTHORIZATION_CODE_GRANT_TYPE = 'authorization_code'
18
+ CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
16
19
 
17
20
  option :name, 'auth0'
18
21
 
@@ -28,6 +31,8 @@ module OmniAuth
28
31
  options.client_options.authorize_url = '/authorize'
29
32
  options.client_options.token_url = '/oauth/token'
30
33
  options.client_options.userinfo_url = '/userinfo'
34
+ setup_client_options_auth_scheme
35
+
31
36
  super
32
37
  end
33
38
 
@@ -100,25 +105,20 @@ module OmniAuth
100
105
  end
101
106
 
102
107
  def build_access_token
108
+ options.token_params.merge!(client_assertion_signing_key_token_params) if client_assertion_signing_key_auth?
103
109
  options.token_params[:headers] = { 'Auth0-Client' => telemetry_encoded }
104
110
  super
105
111
  end
106
112
 
107
113
  # Declarative override for the request phase of authentication
108
114
  def request_phase
109
- if no_client_id?
110
- # Do we have a client_id for this Application?
111
- fail!(:missing_client_id)
112
- elsif no_client_secret?
113
- # Do we have a client_secret for this Application?
114
- fail!(:missing_client_secret)
115
- elsif no_domain?
116
- # Do we have a domain for this Application?
117
- fail!(:missing_domain)
118
- else
119
- # All checks pass, run the Oauth2 request_phase method.
120
- super
121
- end
115
+ return fail!(:missing_client_id) if no_client_id?
116
+ return fail!(:missing_client_secret) if no_client_secret?
117
+ return fail!(:missing_domain) if no_domain?
118
+ return fail!(:missing_client_assertion_signing_key) if no_client_assertion_signing_key?
119
+
120
+ # All checks pass, run the Oauth2 request_phase method.
121
+ super
122
122
  end
123
123
 
124
124
  def callback_phase
@@ -128,10 +128,32 @@ module OmniAuth
128
128
  end
129
129
 
130
130
  private
131
+
132
+ def client_assertion_signing_key_auth?
133
+ options['client_assertion_signing_key']
134
+ end
135
+
136
+ def client_assertion_signing_key_token_params
137
+ {
138
+ grant_type: AUTHORIZATION_CODE_GRANT_TYPE,
139
+ client_id: options.client_id,
140
+ client_assertion_type: CLIENT_ASSERTION_TYPE,
141
+ client_assertion: jwt_token
142
+ }
143
+ end
144
+
131
145
  def jwt_validator
132
146
  @jwt_validator ||= OmniAuth::Auth0::JWTValidator.new(options)
133
147
  end
134
148
 
149
+ def jwt_token
150
+ OmniAuth::Auth0::JWTToken.new(options.client_id,
151
+ domain_url,
152
+ options.client_assertion_signing_key,
153
+ options.client_assertion_signing_algorithm)
154
+ .jwt_token
155
+ end
156
+
135
157
  # Parse the raw user info.
136
158
  def raw_info
137
159
  return @raw_info if @raw_info
@@ -154,7 +176,7 @@ module OmniAuth
154
176
 
155
177
  # Check if the options include a client_secret
156
178
  def no_client_secret?
157
- ['', nil].include?(options.client_secret)
179
+ ['', nil].include?(options.client_secret) && !options.key?('client_assertion_signing_key')
158
180
  end
159
181
 
160
182
  # Check if the options include a domain
@@ -162,12 +184,24 @@ module OmniAuth
162
184
  ['', nil].include?(options.domain)
163
185
  end
164
186
 
187
+ # Check if the options include a client_assertion_signing_key
188
+ def no_client_assertion_signing_key?
189
+ options.key?('client_assertion_signing_key') && ['', nil].include?(options.client_assertion_signing_key)
190
+ end
191
+
165
192
  # Normalize a domain to a URL.
166
193
  def domain_url
167
194
  domain_url = URI(options.domain)
168
195
  domain_url = URI("https://#{domain_url}") if domain_url.scheme.nil?
169
196
  domain_url.to_s
170
197
  end
198
+
199
+ # Setup the auth_scheme for the client options if using client assertion signing key
200
+ def setup_client_options_auth_scheme
201
+ return unless client_assertion_signing_key_auth?
202
+
203
+ options.client_options.auth_scheme = :request_body
204
+ end
171
205
  end
172
206
  end
173
207
  end
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Auth0
3
- VERSION = '3.1.1'.freeze
3
+ VERSION = '3.2.0'.freeze
4
4
  end
5
5
  end
@@ -21,6 +21,7 @@ omniauth-auth0 is the OmniAuth strategy for Auth0.
21
21
  s.executables = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) }
22
22
  s.require_paths = ['lib']
23
23
 
24
+ s.add_runtime_dependency 'jwt', '~> 2'
24
25
  s.add_runtime_dependency 'omniauth', '~> 2'
25
26
  s.add_runtime_dependency 'omniauth-oauth2', '~> 1'
26
27