auth0 4.10.0 → 4.15.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/.env.example +2 -0
- data/CHANGELOG.md +55 -0
- data/DEPLOYMENT.md +14 -0
- data/Gemfile.lock +58 -53
- data/README.md +105 -25
- data/auth0.gemspec +2 -0
- data/lib/auth0.rb +1 -0
- data/lib/auth0/algorithm.rb +5 -0
- data/lib/auth0/api/authentication_endpoints.rb +38 -2
- data/lib/auth0/api/v1/clients.rb +12 -2
- data/lib/auth0/api/v1/connections.rb +15 -0
- data/lib/auth0/api/v1/logs.rb +9 -0
- data/lib/auth0/api/v1/rules.rb +12 -0
- data/lib/auth0/api/v1/users.rb +63 -0
- data/lib/auth0/api/v2.rb +4 -0
- data/lib/auth0/api/v2/log_streams.rb +78 -0
- data/lib/auth0/api/v2/prompts.rb +70 -0
- data/lib/auth0/exception.rb +2 -0
- data/lib/auth0/mixins/httpproxy.rb +1 -1
- data/lib/auth0/mixins/validation.rb +307 -0
- data/lib/auth0/version.rb +1 -1
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +37 -10
- data/spec/lib/auth0/api/v2/log_streams_spec.rb +84 -0
- data/spec/lib/auth0/api/v2/prompts_spec.rb +88 -0
- data/spec/lib/auth0/mixins/validation_spec.rb +466 -0
- data/spec/spec_helper.rb +4 -0
- metadata +43 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d5a0bd117bd194aa40c596db3da2cce8f1d73e155e725408fad834453b9c8bc
|
4
|
+
data.tar.gz: bb572e0e64599762214ea303a943dba8f0ac6685c9e2241a6a5381b9a63a8591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6905e324867b2d9f5127d05a2bbcbefb00f781bb472c572d0f81903aca19602676b22f05b5933d34364758b1cca72fde4b2ee3474c1299203e18a93e528f84e5
|
7
|
+
data.tar.gz: 441bfbbc17cbb148b11a11885f6fe41fd9157a93909b9cbb476aba5fde96419a89eb478d4ead1075d1689068164f4f26d509b0b5c6e8d15c6d6a44f9b1540f3d
|
data/.env.example
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,60 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v4.15.0](https://github.com/auth0/ruby-auth0/tree/v4.15.0) (2020-09-04)
|
4
|
+
|
5
|
+
**Added**
|
6
|
+
|
7
|
+
- Add log streaming endpoints [\#233](https://github.com/auth0/ruby-auth0/pull/233) ([davidpatrick](https://github.com/davidpatrick))
|
8
|
+
|
9
|
+
## [v4.14.0](https://github.com/auth0/ruby-auth0/tree/v4.14.0) (2020-07-20)
|
10
|
+
|
11
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.13.0...v4.14.0)
|
12
|
+
|
13
|
+
**Deprecated**
|
14
|
+
|
15
|
+
- Deprecate mgmt v1 calls [\#230](https://github.com/auth0/ruby-auth0/pull/230) ([davidpatrick](https://github.com/davidpatrick))
|
16
|
+
|
17
|
+
**Removed**
|
18
|
+
|
19
|
+
- Remove iat claim value check [\#229](https://github.com/auth0/ruby-auth0/pull/229) ([lbalmaceda](https://github.com/lbalmaceda))
|
20
|
+
|
21
|
+
**Fixed**
|
22
|
+
|
23
|
+
- Handle missing reset header [\#228](https://github.com/auth0/ruby-auth0/pull/228) ([Widcket](https://github.com/Widcket))
|
24
|
+
|
25
|
+
## [v4.13.0](https://github.com/auth0/ruby-auth0/tree/v4.13.0) (2020-06-18)
|
26
|
+
|
27
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.12.0...v4.13.0)
|
28
|
+
|
29
|
+
**Added**
|
30
|
+
|
31
|
+
- Add prompts endpoints [\#205](https://github.com/auth0/ruby-auth0/pull/205) ([unhappychoice](https://github.com/unhappychoice))
|
32
|
+
|
33
|
+
**Fixed**
|
34
|
+
|
35
|
+
- Fix missing to_json [\#212](https://github.com/auth0/ruby-auth0/pull/212) ([qortex](https://github.com/qortex))
|
36
|
+
|
37
|
+
## [v4.12.0](https://github.com/auth0/ruby-auth0/tree/v4.12.0) (2020-06-10)
|
38
|
+
|
39
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.11.0...v4.12.0)
|
40
|
+
|
41
|
+
**Added**
|
42
|
+
|
43
|
+
- Improve OIDC compliance [SDK-987] [\#225](https://github.com/auth0/ruby-auth0/pull/225) ([Widcket](https://github.com/Widcket))
|
44
|
+
|
45
|
+
**Security**
|
46
|
+
|
47
|
+
- Bump activesupport from 6.0.3 to 6.0.3.1 [\#221](https://github.com/auth0/ruby-auth0/pull/221) ([dependabot[bot]](https://github.com/apps/dependabot))
|
48
|
+
- Bump actionpack from 6.0.3 to 6.0.3.1 [\#220](https://github.com/auth0/ruby-auth0/pull/220) ([dependabot[bot]](https://github.com/apps/dependabot))
|
49
|
+
|
50
|
+
## [v4.11.0](https://github.com/auth0/ruby-auth0/tree/v4.11.0) (2020-05-06)
|
51
|
+
|
52
|
+
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.10.0...v4.11.0)
|
53
|
+
|
54
|
+
**Added**
|
55
|
+
|
56
|
+
- [SDK-1542] Add client secret to Passwordless flow since it is now required [\#217](https://github.com/auth0/ruby-auth0/pull/217) ([stevehobbsdev](https://github.com/stevehobbsdev))
|
57
|
+
|
3
58
|
## [v4.10.0](https://github.com/auth0/ruby-auth0/tree/v4.10.0) (2020-04-23)
|
4
59
|
|
5
60
|
[Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.9.0...v4.10.0)
|
data/DEPLOYMENT.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# Releasing the gem
|
2
|
+
|
3
|
+
## Credentials set up
|
4
|
+
|
5
|
+
Make sure you have access in https://rubygems.org/gems/auth0/ and that your Ruby Gems tokens are set in `~/.gem/credentials`.
|
6
|
+
|
7
|
+
In order to generate the required changelog entry, define an environment variable `GITHUB_READ_TOKEN` with a Github API token that has READ access to `repo:public_repo`. You can generate a Github API Token [here](https://github.com/settings/tokens/new?description=GitHub%20Changelog%20Generator%20token).
|
8
|
+
|
9
|
+
Create a new Github Milestone with the version name prefixed with `v`. i.e. `v4.10.2`. Assign every Issue and Pull Request to be included on this release to that Milestone, and tag them with the `CH:xxxxxx` labels, depending on the type of change fixed or introduced there.
|
10
|
+
|
11
|
+
Finally, follow the next steps:
|
12
|
+
|
1
13
|
```bash
|
2
14
|
# Install gems for exec commands
|
3
15
|
bundle install
|
@@ -45,3 +57,5 @@ git push origin vX.X.X
|
|
45
57
|
# Rubygems token can be updated in ~/.gem/credentials
|
46
58
|
bundle exec gem release
|
47
59
|
```
|
60
|
+
|
61
|
+
The steps above were tested with Ruby `v2.5.7`.
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
auth0 (4.
|
4
|
+
auth0 (4.15.0)
|
5
|
+
jwt (~> 2.2.0)
|
5
6
|
rest-client (~> 2.0.0)
|
7
|
+
zache (~> 0.12.0)
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: https://rubygems.org/
|
9
11
|
specs:
|
10
|
-
actionpack (6.0.
|
11
|
-
actionview (= 6.0.
|
12
|
-
activesupport (= 6.0.
|
12
|
+
actionpack (6.0.3.2)
|
13
|
+
actionview (= 6.0.3.2)
|
14
|
+
activesupport (= 6.0.3.2)
|
13
15
|
rack (~> 2.0, >= 2.0.8)
|
14
16
|
rack-test (>= 0.6.3)
|
15
17
|
rails-dom-testing (~> 2.0)
|
16
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
17
|
-
actionview (6.0.
|
18
|
-
activesupport (= 6.0.
|
19
|
+
actionview (6.0.3.2)
|
20
|
+
activesupport (= 6.0.3.2)
|
19
21
|
builder (~> 3.1)
|
20
22
|
erubi (~> 1.4)
|
21
23
|
rails-dom-testing (~> 2.0)
|
22
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
23
|
-
activesupport (6.0.
|
25
|
+
activesupport (6.0.3.2)
|
24
26
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
25
27
|
i18n (>= 0.7, < 2)
|
26
28
|
minitest (~> 5.1)
|
27
29
|
tzinfo (~> 1.1)
|
28
|
-
zeitwerk (~> 2.2)
|
30
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
29
31
|
addressable (2.7.0)
|
30
32
|
public_suffix (>= 2.0.2, < 5.0)
|
31
|
-
ast (2.4.
|
33
|
+
ast (2.4.1)
|
32
34
|
builder (3.2.4)
|
33
|
-
codecov (0.
|
35
|
+
codecov (0.2.9)
|
34
36
|
json
|
35
37
|
simplecov
|
36
|
-
|
37
|
-
|
38
|
-
concurrent-ruby (1.1.6)
|
38
|
+
coderay (1.1.3)
|
39
|
+
concurrent-ruby (1.1.7)
|
39
40
|
coveralls (0.7.1)
|
40
41
|
multi_json (~> 1.3)
|
41
42
|
rest-client
|
@@ -45,18 +46,18 @@ GEM
|
|
45
46
|
crack (0.4.3)
|
46
47
|
safe_yaml (~> 1.0.0)
|
47
48
|
crass (1.0.6)
|
48
|
-
diff-lcs (1.
|
49
|
+
diff-lcs (1.4.4)
|
49
50
|
docile (1.3.2)
|
50
51
|
domain_name (0.5.20190701)
|
51
52
|
unf (>= 0.0.5, < 1.0.0)
|
52
|
-
dotenv (2.7.
|
53
|
-
dotenv-rails (2.7.
|
54
|
-
dotenv (= 2.7.
|
55
|
-
railties (>= 3.2
|
53
|
+
dotenv (2.7.6)
|
54
|
+
dotenv-rails (2.7.6)
|
55
|
+
dotenv (= 2.7.6)
|
56
|
+
railties (>= 3.2)
|
56
57
|
erubi (1.9.0)
|
57
58
|
faker (1.9.6)
|
58
59
|
i18n (>= 0.7)
|
59
|
-
ffi (1.
|
60
|
+
ffi (1.13.1)
|
60
61
|
formatador (0.2.5)
|
61
62
|
fuubar (2.5.0)
|
62
63
|
rspec-core (~> 3.0)
|
@@ -79,42 +80,42 @@ GEM
|
|
79
80
|
hashdiff (1.0.1)
|
80
81
|
http-cookie (1.0.3)
|
81
82
|
domain_name (~> 0.5)
|
82
|
-
i18n (1.8.
|
83
|
+
i18n (1.8.5)
|
83
84
|
concurrent-ruby (~> 1.0)
|
84
|
-
|
85
|
-
|
85
|
+
json (2.3.1)
|
86
|
+
jwt (2.2.2)
|
86
87
|
listen (3.2.1)
|
87
88
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
88
89
|
rb-inotify (~> 0.9, >= 0.9.10)
|
89
|
-
loofah (2.
|
90
|
+
loofah (2.7.0)
|
90
91
|
crass (~> 1.0.2)
|
91
92
|
nokogiri (>= 1.5.9)
|
92
|
-
lumberjack (1.2.
|
93
|
+
lumberjack (1.2.8)
|
93
94
|
method_source (0.8.2)
|
94
95
|
mime-types (3.3.1)
|
95
96
|
mime-types-data (~> 3.2015)
|
96
|
-
mime-types-data (3.
|
97
|
+
mime-types-data (3.2020.0512)
|
97
98
|
mini_portile2 (2.4.0)
|
98
|
-
minitest (5.14.
|
99
|
-
multi_json (1.
|
99
|
+
minitest (5.14.2)
|
100
|
+
multi_json (1.15.0)
|
100
101
|
nenv (0.3.0)
|
101
102
|
netrc (0.11.0)
|
102
|
-
nokogiri (1.10.
|
103
|
+
nokogiri (1.10.10)
|
103
104
|
mini_portile2 (~> 2.4.0)
|
104
105
|
notiffany (0.1.3)
|
105
106
|
nenv (~> 0.1)
|
106
107
|
shellany (~> 0.0)
|
107
|
-
parallel (1.19.
|
108
|
-
parser (2.7.1.
|
109
|
-
ast (~> 2.4.
|
108
|
+
parallel (1.19.2)
|
109
|
+
parser (2.7.1.4)
|
110
|
+
ast (~> 2.4.1)
|
110
111
|
pry (0.10.4)
|
111
112
|
coderay (~> 1.1.0)
|
112
113
|
method_source (~> 0.8.1)
|
113
114
|
slop (~> 3.4)
|
114
115
|
pry-nav (0.2.4)
|
115
116
|
pry (>= 0.9.10, < 0.11.0)
|
116
|
-
public_suffix (4.0.
|
117
|
-
rack (2.1.
|
117
|
+
public_suffix (4.0.6)
|
118
|
+
rack (2.1.4)
|
118
119
|
rack-test (0.8.3)
|
119
120
|
rack (>= 1.0, < 3)
|
120
121
|
rails-dom-testing (2.0.3)
|
@@ -122,17 +123,18 @@ GEM
|
|
122
123
|
nokogiri (>= 1.6)
|
123
124
|
rails-html-sanitizer (1.3.0)
|
124
125
|
loofah (~> 2.3)
|
125
|
-
railties (6.0.
|
126
|
-
actionpack (= 6.0.
|
127
|
-
activesupport (= 6.0.
|
126
|
+
railties (6.0.3.2)
|
127
|
+
actionpack (= 6.0.3.2)
|
128
|
+
activesupport (= 6.0.3.2)
|
128
129
|
method_source
|
129
130
|
rake (>= 0.8.7)
|
130
131
|
thor (>= 0.20.3, < 2.0)
|
131
132
|
rainbow (3.0.0)
|
132
133
|
rake (13.0.1)
|
133
|
-
rb-fsevent (0.10.
|
134
|
+
rb-fsevent (0.10.4)
|
134
135
|
rb-inotify (0.10.1)
|
135
136
|
ffi (~> 1.0)
|
137
|
+
regexp_parser (1.7.1)
|
136
138
|
rest-client (2.0.2)
|
137
139
|
http-cookie (>= 1.0.2, < 2.0)
|
138
140
|
mime-types (>= 1.16, < 4.0)
|
@@ -142,31 +144,34 @@ GEM
|
|
142
144
|
rspec-core (~> 3.9.0)
|
143
145
|
rspec-expectations (~> 3.9.0)
|
144
146
|
rspec-mocks (~> 3.9.0)
|
145
|
-
rspec-core (3.9.
|
146
|
-
rspec-support (~> 3.9.
|
147
|
-
rspec-expectations (3.9.
|
147
|
+
rspec-core (3.9.2)
|
148
|
+
rspec-support (~> 3.9.3)
|
149
|
+
rspec-expectations (3.9.2)
|
148
150
|
diff-lcs (>= 1.2.0, < 2.0)
|
149
151
|
rspec-support (~> 3.9.0)
|
150
152
|
rspec-mocks (3.9.1)
|
151
153
|
diff-lcs (>= 1.2.0, < 2.0)
|
152
154
|
rspec-support (~> 3.9.0)
|
153
|
-
rspec-support (3.9.
|
154
|
-
rubocop (0.
|
155
|
-
jaro_winkler (~> 1.5.1)
|
155
|
+
rspec-support (3.9.3)
|
156
|
+
rubocop (0.90.0)
|
156
157
|
parallel (~> 1.10)
|
157
|
-
parser (>= 2.7.
|
158
|
+
parser (>= 2.7.1.1)
|
158
159
|
rainbow (>= 2.2.2, < 4.0)
|
160
|
+
regexp_parser (>= 1.7)
|
159
161
|
rexml
|
162
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
160
163
|
ruby-progressbar (~> 1.7)
|
161
164
|
unicode-display_width (>= 1.4.0, < 2.0)
|
162
|
-
rubocop-
|
163
|
-
|
165
|
+
rubocop-ast (0.3.0)
|
166
|
+
parser (>= 2.7.1.4)
|
167
|
+
rubocop-rails (2.7.1)
|
168
|
+
activesupport (>= 4.2.0)
|
164
169
|
rack (>= 1.1)
|
165
|
-
rubocop (>= 0.
|
170
|
+
rubocop (>= 0.87.0)
|
166
171
|
ruby-progressbar (1.10.1)
|
167
172
|
safe_yaml (1.0.5)
|
168
173
|
shellany (0.0.1)
|
169
|
-
simplecov (0.
|
174
|
+
simplecov (0.19.0)
|
170
175
|
docile (~> 1.1)
|
171
176
|
simplecov-html (~> 0.11)
|
172
177
|
simplecov-html (0.12.2)
|
@@ -177,7 +182,7 @@ GEM
|
|
177
182
|
terminal-notifier-guard (1.7.0)
|
178
183
|
thor (1.0.1)
|
179
184
|
thread_safe (0.3.6)
|
180
|
-
tins (1.
|
185
|
+
tins (1.25.0)
|
181
186
|
sync
|
182
187
|
tzinfo (1.2.7)
|
183
188
|
thread_safe (~> 0.1)
|
@@ -185,14 +190,14 @@ GEM
|
|
185
190
|
unf_ext
|
186
191
|
unf_ext (0.0.7.7)
|
187
192
|
unicode-display_width (1.7.0)
|
188
|
-
|
189
|
-
vcr (5.1.0)
|
193
|
+
vcr (6.0.0)
|
190
194
|
webmock (3.8.3)
|
191
195
|
addressable (>= 2.3.6)
|
192
196
|
crack (>= 0.3.2)
|
193
197
|
hashdiff (>= 0.4.0, < 2.0.0)
|
194
|
-
yard (0.9.
|
195
|
-
|
198
|
+
yard (0.9.25)
|
199
|
+
zache (0.12.0)
|
200
|
+
zeitwerk (2.4.0)
|
196
201
|
|
197
202
|
PLATFORMS
|
198
203
|
ruby
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Ruby API client for the [Auth0](https://auth0.com) platform.
|
|
12
12
|
|
13
13
|
This gem can be installed directly:
|
14
14
|
|
15
|
-
```
|
15
|
+
```bash
|
16
16
|
$ gem install auth0
|
17
17
|
```
|
18
18
|
|
@@ -26,7 +26,7 @@ bundle add auth0
|
|
26
26
|
|
27
27
|
You can build the API documentation with the following:
|
28
28
|
|
29
|
-
```
|
29
|
+
```bash
|
30
30
|
bundle exec rake documentation
|
31
31
|
```
|
32
32
|
|
@@ -65,22 +65,22 @@ class AllUsersController < ApplicationController
|
|
65
65
|
}
|
66
66
|
@users = auth0_client.users @params
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
private
|
70
|
-
|
70
|
+
|
71
71
|
# Setup the Auth0 API connection.
|
72
72
|
def auth0_client
|
73
73
|
@auth0_client ||= Auth0Client.new(
|
74
74
|
client_id: ENV['AUTH0_RUBY_CLIENT_ID'],
|
75
75
|
client_secret: ENV['AUTH0_RUBY_CLIENT_SECRET'],
|
76
|
-
# If you pass in a client_secret value, the SDK will automatically try to get a
|
77
|
-
# Management API token for this application. Make sure your Application can make a
|
76
|
+
# If you pass in a client_secret value, the SDK will automatically try to get a
|
77
|
+
# Management API token for this application. Make sure your Application can make a
|
78
78
|
# Client Credentials grant (Application settings in Auth0 > Advanced > Grant Types
|
79
79
|
# tab) and that the Application is authorized for the Management API:
|
80
80
|
# https://auth0.com/docs/api-auth/config/using-the-auth0-dashboard
|
81
81
|
#
|
82
82
|
# Otherwise, you can pass in a Management API token directly for testing or temporary
|
83
|
-
# access using the key below.
|
83
|
+
# access using the key below.
|
84
84
|
# token: ENV['AUTH0_RUBY_API_TOKEN'],
|
85
85
|
domain: ENV['AUTH0_RUBY_DOMAIN'],
|
86
86
|
api_version: 2,
|
@@ -107,36 +107,116 @@ This should show the parameters passed to the `users` method and a list of users
|
|
107
107
|
|
108
108
|
In addition to the Management API, this SDK also provides access to [Authentication API](https://auth0.com/docs/api/authentication) endpoints with the `Auth0::API::AuthenticationEndpoints` module. For basic login capability, we suggest using our OmniAuth stategy [detailed here](https://auth0.com/docs/quickstart/webapp/rails/01-login). Other authentication tasks currently supported are:
|
109
109
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
110
|
+
- Register a new user with a database connection using the `signup` method.
|
111
|
+
- Redirect a user to the universal login page for authentication using the `authorization_url` method.
|
112
|
+
- Log a user into a highly trusted app with the [Resource Owner Password grant](https://auth0.com/docs/api-auth/tutorials/password-grant) using the `login` method.
|
113
|
+
- Exchange an authorization code for an access token on callback using the `obtain_user_tokens` method (see the note on state validation below).
|
114
|
+
- Send a change password email to a database connection user using the `change_password` method.
|
115
|
+
- Log a user out of Auth0 with the `logout_url` method.
|
116
116
|
|
117
|
-
**Important note on state validation**: If you choose to implement a login flow callback yourself, it is important to generate and store a `state` value, pass that value to Auth0 in the `authorization_url` method, and validate it in your callback URL before calling `obtain_user_tokens`. For more information on state validation, [please see our documentation](https://auth0.com/docs/protocols/oauth2/oauth-state).
|
117
|
+
**Important note on state validation**: If you choose to implement a login flow callback yourself, it is important to generate and store a `state` value, pass that value to Auth0 in the `authorization_url` method, and validate it in your callback URL before calling `obtain_user_tokens`. For more information on state validation, [please see our documentation](https://auth0.com/docs/protocols/oauth2/oauth-state).
|
118
118
|
|
119
119
|
Please note that this module implements endpoints that might be deprecated for newer tenants. If you have any questions about how and when the endpoints should be used, consult the [documentation](https://auth0.com/docs/api/authentication) or ask in our [Community forums](https://community.auth0.com/tags/wordpress).
|
120
120
|
|
121
|
+
## ID Token Validation
|
122
|
+
|
123
|
+
An ID token may be present in the credentials received after authentication. This token contains information associated with the user that has just logged in, provided the scope used contained `openid`. You can [read more about ID tokens here](https://auth0.com/docs/tokens/concepts/id-tokens).
|
124
|
+
|
125
|
+
Before accessing its contents, you must first validate the ID token to ensure it has not been tampered with and that it is meant for your application to consume. Use the `validate_id_token` method to do so:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
begin
|
129
|
+
@auth0_client.validate_id_token 'YOUR_ID_TOKEN'
|
130
|
+
rescue Auth0::InvalidIdToken => e
|
131
|
+
# In this case the ID Token contents should not be trusted
|
132
|
+
end
|
133
|
+
```
|
134
|
+
|
135
|
+
The method takes the following optional keyword parameters:
|
136
|
+
|
137
|
+
| Parameter | Type | Description | Default value |
|
138
|
+
| ------------- | -------------- | ------------- | ------------------------- |
|
139
|
+
| `algorithm` | `JWTAlgorithm` | The [signing algorithm](https://auth0.com/docs/tokens/concepts/signing-algorithms) used by your Auth0 application. | `Auth0::Algorithm::RS256` (using the [JWKS URL](https://auth0.com/docs/tokens/concepts/jwks) of your **Auth0 Domain**) |
|
140
|
+
| `leeway` | Integer | Number of seconds to account for clock skew when validating the `exp`, `iat` and `azp` claims. | `60` |
|
141
|
+
| `nonce` | String | The `nonce` value you sent in the call to `/authorize`, if any. | `nil` |
|
142
|
+
| `max_age` | Integer | The `max_age` value you sent in the call to `/authorize`, if any. | `nil` |
|
143
|
+
| `issuer` | String | By default the `iss` claim will be checked against the URL of your **Auth0 Domain**. Use this parameter to override that. | `nil` |
|
144
|
+
| `audience` | String | By default the `aud` claim will be compared to your **Auth0 Client ID**. Use this parameter to override that. | `nil` |
|
145
|
+
|
146
|
+
You can check the signing algorithm value under **Advanced Settings > OAuth > JsonWebToken Signature Algorithm** in your Auth0 application settings panel. [We recommend](https://auth0.com/docs/tokens/concepts/signing-algorithms#our-recommendation) that you make use of asymmetric signing algorithms like `RS256` instead of symmetric ones like `HS256`.
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
# HS256
|
150
|
+
|
151
|
+
begin
|
152
|
+
@auth0_client.validate_id_token 'YOUR_ID_TOKEN', algorithm: Auth0::Algorithm::HS256.secret('YOUR_SECRET')
|
153
|
+
rescue Auth0::InvalidIdToken => e
|
154
|
+
# Handle error
|
155
|
+
end
|
156
|
+
|
157
|
+
# RS256 with a custom JWKS URL
|
158
|
+
|
159
|
+
begin
|
160
|
+
@auth0_client.validate_id_token 'YOUR_ID_TOKEN', algorithm: Auth0::Algorithm::RS256.jwks_url('YOUR_URL')
|
161
|
+
rescue Auth0::InvalidIdToken => e
|
162
|
+
# Handle error
|
163
|
+
end
|
164
|
+
```
|
165
|
+
|
166
|
+
## Development
|
167
|
+
|
168
|
+
In order to set up the local environment you'd have to have Ruby installed and a few global gems used to run and record the unit tests. A working Ruby version can be taken from the [CI script](/.circleci/config.yml). At the moment of this writting we're using Ruby `2.5.7`.
|
169
|
+
|
170
|
+
> It is expected that every Pull Request introducing a fix, change or feature contains enough test coverage to assert the new behavior.
|
171
|
+
|
172
|
+
### Running the tests
|
173
|
+
|
174
|
+
Install the gems required for this project.
|
175
|
+
|
176
|
+
```bash
|
177
|
+
bundle install
|
178
|
+
```
|
179
|
+
|
180
|
+
Finally, run the tests.
|
181
|
+
|
182
|
+
```bash
|
183
|
+
bundle exec rake test
|
184
|
+
```
|
185
|
+
|
186
|
+
#### Running only unit tests
|
187
|
+
|
188
|
+
You can run only the unit tests and ignore the integration tests by running the following:
|
189
|
+
|
190
|
+
```bash
|
191
|
+
bundle exec rake spec
|
192
|
+
```
|
193
|
+
|
194
|
+
#### Running only integration tests
|
195
|
+
|
196
|
+
You can run only the unit tests and ignore the integration tests by running the following:
|
197
|
+
|
198
|
+
```bash
|
199
|
+
bundle exec rake integration
|
200
|
+
```
|
121
201
|
|
122
202
|
## More Information
|
123
203
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
204
|
+
- [Login using OmniAuth](https://auth0.com/docs/quickstart/webapp/rails/01-login)
|
205
|
+
- [API authentication in Ruby](https://auth0.com/docs/quickstart/backend/ruby)
|
206
|
+
- [API authentication in Rails](https://auth0.com/docs/quickstart/backend/rails)
|
207
|
+
- [Managing authentication with Auth0 (blog)](https://auth0.com/blog/rails-5-with-auth0/)
|
208
|
+
- [Ruby on Rails workflow with Docker (blog)](https://auth0.com/blog/ruby-on-rails-killer-workflow-with-docker-part-1/)
|
129
209
|
|
130
210
|
## What is Auth0?
|
131
211
|
|
132
212
|
Auth0 helps you to:
|
133
213
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
214
|
+
- Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce** among others, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**.
|
215
|
+
- Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**.
|
216
|
+
- Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user.
|
217
|
+
- Support for generating signed [JSON Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely.
|
218
|
+
- Analytics of how, when, and where users are logging in.
|
219
|
+
- Pull data from other sources and add it to the user profile with [JavaScript rules](https://docs.auth0.com/rules).
|
140
220
|
|
141
221
|
## Create a free Auth0 Account
|
142
222
|
|