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.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/actions/get-prerelease/action.yml +30 -0
- data/.github/actions/get-release-notes/action.yml +42 -0
- data/.github/actions/get-version/action.yml +21 -0
- data/.github/actions/release-create/action.yml +47 -0
- data/.github/actions/rl-scanner/action.yml +71 -0
- data/.github/actions/rubygems-publish/action.yml +30 -0
- data/.github/actions/setup/action.yml +28 -0
- data/.github/actions/tag-exists/action.yml +36 -0
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/codeql.yml +53 -0
- data/.github/workflows/matrix.json +7 -0
- data/.github/workflows/publish.yml +33 -0
- data/.github/workflows/rl-scanner.yml +65 -0
- data/.github/workflows/ruby-release.yml +72 -0
- data/.github/workflows/snyk.yml +40 -0
- data/.github/workflows/test.yml +69 -0
- data/.shiprc +2 -1
- data/.version +1 -0
- data/CHANGELOG.md +10 -5
- data/Gemfile +1 -2
- data/Gemfile.lock +117 -84
- data/README.md +42 -1
- data/lib/omniauth/auth0/jwt_token.rb +38 -0
- data/lib/omniauth/auth0/jwt_validator.rb +2 -2
- data/lib/omniauth/strategies/auth0.rb +48 -14
- data/lib/omniauth-auth0/version.rb +1 -1
- data/omniauth-auth0.gemspec +1 -0
- data/spec/omniauth/auth0/jwt_token_spec.rb +87 -0
- data/spec/omniauth/strategies/auth0_spec.rb +478 -230
- metadata +39 -9
- data/.circleci/config.yml +0 -63
- data/.gemrelease +0 -2
- data/.github/workflows/semgrep.yml +0 -24
data/.shiprc
CHANGED
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) (
|
|
4
|
-
[Full Changelog](https://github.com/auth0/omniauth-auth0/compare/v3.1.
|
|
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
|
-
-
|
|
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
|
-
**
|
|
10
|
-
-
|
|
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', '~>
|
|
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.
|
|
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.
|
|
12
|
-
public_suffix (>= 2.0.2, <
|
|
13
|
-
ast (2.4.
|
|
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.
|
|
20
|
+
crack (1.0.1)
|
|
21
|
+
bigdecimal
|
|
16
22
|
rexml
|
|
17
23
|
daemons (1.4.1)
|
|
18
|
-
diff-lcs (1.
|
|
19
|
-
docile (1.4.
|
|
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.
|
|
23
|
-
faraday-net_http (>= 2.0, < 3.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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.
|
|
44
|
-
hashie (5.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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.
|
|
62
|
-
|
|
63
|
-
|
|
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.
|
|
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.
|
|
73
|
-
oauth2 (>=
|
|
95
|
+
omniauth-oauth2 (1.9.0)
|
|
96
|
+
oauth2 (>= 2.0.2, < 3)
|
|
74
97
|
omniauth (~> 2.0)
|
|
75
|
-
parallel (1.
|
|
76
|
-
parser (3.
|
|
98
|
+
parallel (1.28.0)
|
|
99
|
+
parser (3.3.11.1)
|
|
77
100
|
ast (~> 2.4.1)
|
|
78
101
|
racc
|
|
79
|
-
|
|
102
|
+
prism (1.9.0)
|
|
103
|
+
pry (0.16.0)
|
|
80
104
|
coderay (~> 1.1)
|
|
81
105
|
method_source (~> 1.0)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
rack
|
|
86
|
-
|
|
87
|
-
|
|
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.
|
|
116
|
+
rake (13.4.2)
|
|
91
117
|
rb-fsevent (0.11.2)
|
|
92
|
-
rb-inotify (0.
|
|
118
|
+
rb-inotify (0.11.1)
|
|
93
119
|
ffi (~> 1.0)
|
|
94
|
-
regexp_parser (2.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
rspec-
|
|
100
|
-
|
|
101
|
-
rspec-
|
|
102
|
-
rspec-
|
|
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.
|
|
105
|
-
rspec-mocks (3.
|
|
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.
|
|
108
|
-
rspec-support (3.
|
|
109
|
-
rubocop (1.
|
|
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 (
|
|
112
|
-
|
|
113
|
-
|
|
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 (>=
|
|
116
|
-
|
|
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, <
|
|
120
|
-
rubocop-ast (1.
|
|
121
|
-
parser (>= 3.
|
|
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 (
|
|
159
|
+
simplecov-cobertura (3.1.0)
|
|
132
160
|
rexml
|
|
133
161
|
simplecov (~> 0.19)
|
|
134
|
-
simplecov-html (0.
|
|
162
|
+
simplecov-html (0.13.2)
|
|
135
163
|
simplecov_json_formatter (0.1.4)
|
|
136
|
-
sinatra (3.0
|
|
164
|
+
sinatra (3.2.0)
|
|
137
165
|
mustermann (~> 3.0)
|
|
138
166
|
rack (~> 2.2, >= 2.2.4)
|
|
139
|
-
rack-protection (= 3.0
|
|
167
|
+
rack-protection (= 3.2.0)
|
|
140
168
|
tilt (~> 2.0)
|
|
141
|
-
snaky_hash (2.0.
|
|
142
|
-
hashie
|
|
143
|
-
version_gem (
|
|
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.
|
|
149
|
-
tilt (2.
|
|
150
|
-
unicode-display_width (2.
|
|
151
|
-
|
|
152
|
-
|
|
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 (~>
|
|
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
|
[](https://codecov.io/gh/auth0/omniauth-auth0)
|
|
6
6
|
[](https://badge.fury.io/rb/omniauth-auth0)
|
|
7
7
|
[](https://github.com/auth0/omniauth-auth0/blob/master/LICENSE)
|
|
8
|
+
[](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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
data/omniauth-auth0.gemspec
CHANGED
|
@@ -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
|
|