auth0 5.0.0 → 5.1.2

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +29 -8
  3. data/.github/CODEOWNERS +1 -1
  4. data/.github/ISSUE_TEMPLATE/config.yml +8 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
  6. data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
  7. data/.gitignore +1 -0
  8. data/CHANGELOG.md +46 -0
  9. data/README.md +80 -1
  10. data/auth0.gemspec +4 -3
  11. data/lib/auth0/api/authentication_endpoints.rb +16 -6
  12. data/lib/auth0/api/v2.rb +8 -4
  13. data/lib/auth0/api/v2/branding.rb +66 -0
  14. data/lib/auth0/api/v2/connections.rb +3 -0
  15. data/lib/auth0/api/v2/jobs.rb +3 -1
  16. data/lib/auth0/api/v2/organizations.rb +335 -0
  17. data/lib/auth0/api/v2/tickets.rb +14 -2
  18. data/lib/auth0/api/v2/users.rb +13 -1
  19. data/lib/auth0/exception.rb +3 -1
  20. data/lib/auth0/mixins/httpproxy.rb +4 -1
  21. data/lib/auth0/mixins/initializer.rb +3 -1
  22. data/lib/auth0/mixins/validation.rb +14 -0
  23. data/lib/auth0/version.rb +1 -1
  24. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +1 -1
  25. data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
  26. data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
  27. data/spec/lib/auth0/api/v2/connections_spec.rb +4 -0
  28. data/spec/lib/auth0/api/v2/jobs_spec.rb +11 -0
  29. data/spec/lib/auth0/api/v2/organizations_spec.rb +593 -0
  30. data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
  31. data/spec/lib/auth0/api/v2/users_spec.rb +20 -1
  32. data/spec/lib/auth0/client_spec.rb +79 -9
  33. data/spec/lib/auth0/mixins/httpproxy_spec.rb +8 -8
  34. data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
  35. data/spec/spec_helper.rb +6 -1
  36. metadata +34 -19
  37. data/.github/ISSUE_TEMPLATE.md +0 -39
  38. data/Gemfile.lock +0 -226
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82dfc2ea2a26c6a1aa75bcbfeb013ba0ae6f88f160c855863e858b56dadc40a4
4
- data.tar.gz: 9c882d7199b9084703b573ab3621b202858fc1d4f6ffd20c588de54e4b7ac2e5
3
+ metadata.gz: 65e850e90fba56319b9629b53159529ba450c62633e0f3f32330d917922358fc
4
+ data.tar.gz: a7b19d7a9128b409e457e670b9b3ae8882b3fe2cc62978d18c3361b4bcaa85d4
5
5
  SHA512:
6
- metadata.gz: 8005cde8f1c028b5d87c8058c3b711cd0f8d85e4dd34db1d2b79e45581935a26401dfc5da5d0e08745ccb3b061ebd1ab767d9255043e827e55468f7603ea290c
7
- data.tar.gz: cb6ac580e79b850b7785f1e13594e06b4055fb124906910590519b9cd6e6f6df984c218b21cf07cf2c0738212a0d444c2e07dcbf3e7c58bb5298a38fbea3c347
6
+ metadata.gz: 98fa29ea9c5cbfb1c7918566b1569630af21ff0f078ebcd990131ed1a70352d1b53f70cb033038fb28d6a5a9d89a445bc29a2e6b31c2e7f14193bcd8b4ccf9f3
7
+ data.tar.gz: 5059fbdf9fbe8b84118b224945b4abac252744c6af58ef1aa2efba99301c410016d9196502d277714d76786907a2cae352d3f9ab81987879410fa03aa5f40712
data/.circleci/config.yml CHANGED
@@ -1,17 +1,37 @@
1
1
  version: 2.1
2
+
3
+ matrix_ruby_versions: &matrix_ruby_versions
4
+ matrix:
5
+ parameters:
6
+ ruby_version: ["2.5", "2.6", "2.7", "3.0"]
7
+ # Default version of ruby to use for lint and publishing
8
+ default_ruby_version: &default_ruby_version "2.7"
9
+
10
+ executors:
11
+ ruby-image:
12
+ parameters:
13
+ ruby_version:
14
+ type: string
15
+ default: *default_ruby_version
16
+ docker:
17
+ - image: circleci/ruby:<< parameters.ruby_version >>
18
+
2
19
  jobs:
3
20
  run-tests:
4
- docker:
5
- - image: circleci/ruby:2.5.7-buster
21
+ parameters:
22
+ ruby_version:
23
+ type: string
24
+ default: *default_ruby_version
25
+ executor:
26
+ name: ruby-image
27
+ ruby_version: << parameters.ruby_version >>
6
28
  steps:
7
29
  - checkout
8
30
  - restore_cache:
9
- keys:
10
- - gems-v2-{{ checksum "Gemfile.lock" }}
11
- - gems-v2-
12
- - run: bundle check || bundle install
31
+ key: gems-v2-{{ checksum "Gemfile.lock" }}
32
+ - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
13
33
  - save_cache:
14
- key: gems-v2--{{ checksum "Gemfile.lock" }}
34
+ key: gems-v2-{{ checksum "Gemfile.lock" }}
15
35
  paths:
16
36
  - vendor/bundle
17
37
  # Must define DOMAIN, CLIENT_ID, CLIENT_SECRET and MASTER_JWT env
@@ -20,4 +40,5 @@ jobs:
20
40
  workflows:
21
41
  tests:
22
42
  jobs:
23
- - run-tests
43
+ - run-tests:
44
+ <<: *matrix_ruby_versions
data/.github/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @auth0/dx-sdks-approver
1
+ * @auth0/dx-sdks-engineer
@@ -0,0 +1,8 @@
1
+ blank_issues_enabled: false
2
+ contact_links:
3
+ - name: Auth0 Community
4
+ url: https://community.auth0.com/c/sdks/5
5
+ about: Discuss this SDK in the Auth0 Community forums
6
+ - name: SDK API Documentation
7
+ url: https://www.rubydoc.info/gems/auth0
8
+ about: Read the API documentation for this SDK
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea or a feature for this project
4
+ title: ''
5
+ labels: feature request
6
+ assignees: ''
7
+ ---
8
+
9
+ <!--
10
+ **Please do not report security vulnerabilities here**. The Responsible Disclosure Program (https://auth0.com/whitehat) details the procedure for disclosing security issues.
11
+
12
+ Thank you in advance for helping us to improve this library! Your attention to detail here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community (https://community.auth0.com/) or Auth0 Support (https://support.auth0.com/). Finally, to avoid duplicates, please search existing Issues before submitting one here.
13
+
14
+ By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct (https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
15
+ -->
16
+
17
+ ### Describe the problem you'd like to have solved
18
+
19
+ <!--
20
+ > A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
21
+ -->
22
+
23
+ ### Describe the ideal solution
24
+
25
+ <!--
26
+ > A clear and concise description of what you want to happen.
27
+ -->
28
+
29
+ ## Alternatives and current work-arounds
30
+
31
+ <!--
32
+ > A clear and concise description of any alternatives you've considered or any work-arounds that are currently in place.
33
+ -->
34
+
35
+ ### Additional information, if any
36
+
37
+ <!--
38
+ > Add any other context or screenshots about the feature request here.
39
+ -->
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: Report a bug
3
+ about: Have you found a bug or issue? Create a bug report for this SDK
4
+ title: ''
5
+ labels: bug report
6
+ assignees: ''
7
+ ---
8
+
9
+ <!--
10
+ **Please do not report security vulnerabilities here**. The Responsible Disclosure Program (https://auth0.com/whitehat) details the procedure for disclosing security issues.
11
+
12
+ Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community (https://community.auth0.com/) or Auth0 Support (https://support.auth0.com/). Finally, to avoid duplicates, please search existing Issues before submitting one here.
13
+
14
+ By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct (https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md).
15
+ -->
16
+
17
+ ### Describe the problem
18
+
19
+ <!--
20
+ > Provide a clear and concise description of the issue
21
+ -->
22
+
23
+ ### What was the expected behavior?
24
+
25
+ <!--
26
+ > Tell us about the behavior you expected to see
27
+ -->
28
+
29
+ ### Reproduction
30
+ <!--
31
+ > Detail the steps taken to reproduce this error, and whether this issue can be reproduced consistently or if it is intermittent.
32
+ > **Note**: If clear, reproducable steps or the smallest sample app demonstrating misbehavior cannot be provided, we may not be able to follow up on this bug report.
33
+
34
+ > Where possible, please include:
35
+ >
36
+ > - The smallest possible sample app that reproduces the undesirable behavior
37
+ > - Log files (redact/remove sensitive information)
38
+ > - Application settings (redact/remove sensitive information)
39
+ > - Screenshots
40
+ -->
41
+
42
+ - Step 1..
43
+ - Step 2..
44
+ - ...
45
+
46
+ ### Environment
47
+
48
+ <!--
49
+ > Please provide the following:
50
+ -->
51
+
52
+ - **Version of this library used:**
53
+ - **Which framework are you using, if applicable:**
54
+ - **Other modules/plugins/libraries that might be involved:**
55
+ - **Any other relevant information you think would be useful:**
data/.gitignore CHANGED
@@ -11,3 +11,4 @@ coverage
11
11
  *.swo
12
12
  spec/auth0.yml
13
13
  .env
14
+ /Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,5 +1,51 @@
1
1
  # Change Log
2
2
 
3
+ ## [v5.1.2](https://github.com/auth0/ruby-auth0/tree/v5.1.2) (2021-07-15)
4
+
5
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.1.1..v5.1.2)
6
+
7
+ **Security**
8
+
9
+ - Bump addressable version per CVE-2021-32740 [\#276](https://github.com/auth0/ruby-auth0/pull/276) ([lostapathy](https://github.com/lostapathy))
10
+
11
+ ## [v5.1.1](https://github.com/auth0/ruby-auth0/tree/v5.1.1) (2021-04-14)
12
+
13
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.1.0..v5.1.1)
14
+
15
+ **Fixed**
16
+
17
+ - Fixes create_organizations_enabled_connection [\#269](https://github.com/auth0/ruby-auth0/pull/269) ([davidpatrick](https://github.com/apps/davidpatrick))
18
+
19
+
20
+ ## [v5.1.0](https://github.com/auth0/ruby-auth0/tree/v5.1.0) (2021-04-09)
21
+
22
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.0.1..v5.1.0)
23
+
24
+ **Added**
25
+
26
+ - Org idtoken validation guidance [\#267](https://github.com/auth0/ruby-auth0/pull/267) ([davidpatrick](https://github.com/davidpatrick))
27
+ - Adds Branding endpoints [\#266](https://github.com/auth0/ruby-auth0/pull/266) ([davidpatrick](https://github.com/davidpatrick))
28
+ - Organizations feature [\#264](https://github.com/auth0/ruby-auth0/pull/264) ([davidpatrick](https://github.com/davidpatrick))
29
+ - Add Organizations support to Authentication API Client [\#263](https://github.com/auth0/ruby-auth0/pull/263) ([davidpatrick](https://github.com/davidpatrick))
30
+ - Add api_identifier as an accepted configurable [\#261](https://github.com/auth0/ruby-auth0/pull/261) ([QWYNBG](https://github.com/QWYNBG))
31
+ - add name param to connections api [\#260](https://github.com/auth0/ruby-auth0/pull/260) ([QWYNBG](https://github.com/QWYNBG))
32
+
33
+ ## [v5.0.1](https://github.com/auth0/ruby-auth0/tree/v5.0.1) (2021-02-02)
34
+
35
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v5.0.0..v5.0.1)
36
+
37
+ **Added**
38
+
39
+ - Add test support for Ruby 2.6 and 2.7 and 3.0 [\#256](https://github.com/auth0/ruby-auth0/pull/256) ([fursich](https://github.com/fursich))
40
+
41
+ **Fixed**
42
+
43
+ - Fixes recovery-code-regeneration URL [\#257](https://github.com/auth0/ruby-auth0/pull/257) ([epintos](https://github.com/apps/epintos))
44
+
45
+ **Security**
46
+
47
+ - Bumps nokogiri from 1.10.10 to 1.11.1 [\#258](https://github.com/auth0/ruby-auth0/pull/258) ([dependabot](https://github.com/apps/dependabot))
48
+
3
49
  ## [v5.0.0](https://github.com/auth0/ruby-auth0/tree/v5.0.0) (2020-10-22)
4
50
 
5
51
  This release addresses some long standing issues with the library that could only be addressed in a major. We have also removed Api/v1 endpoints and other deprecated methods.
data/README.md CHANGED
@@ -113,6 +113,61 @@ In addition to the Management API, this SDK also provides access to [Authenticat
113
113
 
114
114
  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).
115
115
 
116
+ ### Organizations
117
+
118
+ [Organizations](https://auth0.com/docs/organizations) is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications.
119
+
120
+ Using Organizations, you can:
121
+
122
+ - Represent teams, business customers, partner companies, or any logical grouping of users that should have different ways of accessing your applications, as organizations.
123
+ - Manage their membership in a variety of ways, including user invitation.
124
+ - Configure branded, federated login flows for each organization.
125
+ - Implement role-based access control, such that users can have different roles when authenticating in the context of different organizations.
126
+ - Build administration capabilities into your products, using Organizations APIs, so that those businesses can manage their own organizations.
127
+
128
+ Note that Organizations is currently only available to customers on our Enterprise and Startup subscription plans.
129
+
130
+ #### Logging in with an Organization
131
+
132
+ Configure the Authentication API client and pass your Organization ID to the authorize url:
133
+
134
+ ```ruby
135
+ require 'auth0'
136
+
137
+ @auth0_client ||= Auth0Client.new(
138
+ client_id: '{YOUR_APPLICATION_CLIENT_ID}',
139
+ client_secret: '{YOUR_APPLICATION_CLIENT_SECRET}',
140
+ domain: '{YOUR_TENANT}.auth0.com',
141
+ organization: "{YOUR_ORGANIZATION_ID}"
142
+ )
143
+
144
+ universal_login_url = @auth0_client.authorization_url("https://{YOUR_APPLICATION_CALLBACK_URL}")
145
+
146
+ # redirect_to universal_login_url
147
+ ```
148
+
149
+ #### Accepting user invitations
150
+
151
+ Auth0 Organizations allow users to be invited using emailed links, which will direct a user back to your application. The URL the user will arrive at is based on your configured `Application Login URI`, which you can change from your Application's settings inside the Auth0 dashboard. When they arrive at this URL, a `invitation` and `organization` query parameters will be provided
152
+
153
+ ```ruby
154
+ require 'auth0'
155
+
156
+ @auth0_client ||= Auth0Client.new(
157
+ client_id: '{YOUR_APPLICATION_CLIENT_ID}',
158
+ client_secret: '{YOUR_APPLICATION_CLIENT_ID}',
159
+ domain: '{YOUR_TENANT}.auth0.com',
160
+ organization: "{YOUR_ORGANIZATION_ID}"
161
+ )
162
+
163
+ universal_login_url = @auth0_client.authorization_url("https://{YOUR_APPLICATION_CALLBACK_URL}", {
164
+ organization: "{ORGANIZATION_QUERY_PARAM}", # You can override organization if needed
165
+ invitation: "{INVITATION_QUERY_PARAM}"
166
+ })
167
+
168
+ # redirect_to universal_login_url
169
+ ```
170
+
116
171
  ## ID Token Validation
117
172
 
118
173
  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).
@@ -137,6 +192,7 @@ The method takes the following optional keyword parameters:
137
192
  | `max_age` | Integer | The `max_age` value you sent in the call to `/authorize`, if any. | `nil` |
138
193
  | `issuer` | String | By default the `iss` claim will be checked against the URL of your **Auth0 Domain**. Use this parameter to override that. | `nil` |
139
194
  | `audience` | String | By default the `aud` claim will be compared to your **Auth0 Client ID**. Use this parameter to override that. | `nil` |
195
+ | `organization`| String | By default the `org_id` claim will be compared to your **Organization ID**. Use this parameter to override that. | `nil` |
140
196
 
141
197
  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`.
142
198
 
@@ -158,6 +214,29 @@ rescue Auth0::InvalidIdToken => e
158
214
  end
159
215
  ```
160
216
 
217
+ ### Organization ID Token Validation
218
+
219
+ If an org_id claim is present in the Access Token, then the claim should be validated by the API to ensure that the value received is expected or known.
220
+
221
+ In particular:
222
+
223
+ * The issuer (iss) claim should be checked to ensure the token was issued by Auth0
224
+
225
+ * the org_id claim should be checked to ensure it is a value that is already known to the application. This could be validated against a known list of organization IDs, or perhaps checked in conjunction with the current request URL. e.g. the sub-domain may hint at what organization should be used to validate the Access Token.
226
+
227
+ Normally, validating the issuer would be enough to ensure that the token was issued by Auth0. In the case of organizations, additional checks should be made so that the organization within an Auth0 tenant is expected.
228
+
229
+ If the claim cannot be validated, then the application should deem the token invalid.
230
+
231
+ ```ruby
232
+ begin
233
+ @auth0_client.validate_id_token 'YOUR_ID_TOKEN', organization: '{Expected org_id}'
234
+ rescue Auth0::InvalidIdToken => e
235
+ # In this case the ID Token contents should not be trusted
236
+ end
237
+
238
+ For more information, please read [Work with Tokens and Organizations](https://auth0.com/docs/organizations/using-tokens) on Auth0 Docs.
239
+
161
240
  ## Development
162
241
 
163
242
  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`.
@@ -231,4 +310,4 @@ If you find a bug or have a feature request, please report them in this reposito
231
310
  This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
232
311
 
233
312
 
234
- [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0?ref=badge_large)
313
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0?ref=badge_large)
data/auth0.gemspec CHANGED
@@ -19,19 +19,20 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'rest-client', '~> 2.0.0'
20
20
  s.add_runtime_dependency 'jwt', '~> 2.2.0'
21
21
  s.add_runtime_dependency 'zache', '~> 0.12.0'
22
- s.add_runtime_dependency 'addressable', '~> 2.7.0'
22
+ s.add_runtime_dependency 'addressable', '~> 2.8.0'
23
23
 
24
+ s.add_development_dependency 'bundler'
24
25
  s.add_development_dependency 'rake', '~> 13.0'
25
26
  s.add_development_dependency 'fuubar', '~> 2.0'
26
27
  s.add_development_dependency 'guard-rspec', '~> 4.5' unless ENV['CIRCLECI']
27
28
  s.add_development_dependency 'dotenv-rails', '~> 2.0'
28
29
  s.add_development_dependency 'pry', '~> 0.10'
29
30
  s.add_development_dependency 'pry-nav', '~> 0.2.4'
30
- s.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
31
+ s.add_development_dependency 'rspec', '~> 3.5'
31
32
  s.add_development_dependency 'rack-test', '~> 0.6'
32
33
  s.add_development_dependency 'rack', '~> 2.1.2'
33
34
  s.add_development_dependency 'simplecov', '~> 0.9'
34
- s.add_development_dependency 'faker', '~> 1.4'
35
+ s.add_development_dependency 'faker', '~> 2.0'
35
36
  s.add_development_dependency 'gem-release', '~> 0.7'
36
37
  s.license = 'MIT'
37
38
  end
@@ -14,18 +14,23 @@ module Auth0
14
14
  # Request an API access token using a Client Credentials grant
15
15
  # @see https://auth0.com/docs/api-auth/tutorials/client-credentials
16
16
  # @param audience [string] API audience to use
17
+ # @param organization [string] Organization ID
17
18
  # @return [json] Returns the API token
18
19
  def api_token(
19
20
  client_id: @client_id,
20
21
  client_secret: @client_secret,
21
- audience: "https://#{@domain}/api/v2/"
22
+ organization: @organization,
23
+ audience: nil
22
24
  )
25
+
23
26
  request_params = {
24
27
  grant_type: 'client_credentials',
25
28
  client_id: client_id,
26
29
  client_secret: client_secret,
27
- audience: audience
30
+ audience: audience,
31
+ organization: organization
28
32
  }
33
+
29
34
  response = post('/oauth/token', request_params)
30
35
  ::Auth0::ApiToken.new(response['access_token'], response['scope'], response['expires_in'])
31
36
  end
@@ -220,7 +225,7 @@ module Auth0
220
225
  # Return an authorization URL.
221
226
  # @see https://auth0.com/docs/api/authentication#authorization-code-grant
222
227
  # @param redirect_uri [string] URL to redirect after authorization
223
- # @param options [hash] Can contain response_type, connection, state and additional_parameters.
228
+ # @param options [hash] Can contain response_type, connection, state, organization, invitation, and additional_parameters.
224
229
  # @return [url] Authorization URL.
225
230
  def authorization_url(redirect_uri, options = {})
226
231
  raise Auth0::InvalidParameter, 'Must supply a valid redirect_uri' if redirect_uri.to_s.empty?
@@ -231,7 +236,9 @@ module Auth0
231
236
  connection: options.fetch(:connection, nil),
232
237
  redirect_uri: redirect_uri,
233
238
  state: options.fetch(:state, nil),
234
- scope: options.fetch(:scope, nil)
239
+ scope: options.fetch(:scope, nil),
240
+ organization: options.fetch(:organization, @organization),
241
+ invitation: options.fetch(:invitation, nil)
235
242
  }.merge(options.fetch(:additional_parameters, {}))
236
243
 
237
244
  URI::HTTPS.build(host: @domain, path: '/authorize', query: to_query(request_params))
@@ -296,7 +303,7 @@ module Auth0
296
303
  # @see https://auth0.com/docs/tokens/guides/validate-id-tokens
297
304
  # @param id_token [string] The JWT to validate.
298
305
  # @param algorithm [JWKAlgorithm] The expected signing algorithm.
299
- # Defaults to +Auth0::Algorithm::RS256.jwks_url("https://YOUR_AUTH0_DOMAIN/.well-known/jwks.json", lifetime: 10 * 60)+.
306
+
300
307
  # @param leeway [integer] The clock skew to accept when verifying date related claims in seconds.
301
308
  # Must be a non-negative value. Defaults to *60 seconds*.
302
309
  # @param nonce [string] The nonce value sent during authentication.
@@ -306,8 +313,10 @@ module Auth0
306
313
  # Defaults to +https://YOUR_AUTH0_DOMAIN/+.
307
314
  # @param audience [string] The expected audience claim value.
308
315
  # Defaults to your *Auth0 Client ID*.
316
+ # @param organization [string] Organization ID
317
+ # Defaults to your *Auth0 Organization ID*.
309
318
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/ParameterLists
310
- def validate_id_token(id_token, algorithm: nil, leeway: 60, nonce: nil, max_age: nil, issuer: nil, audience: nil)
319
+ def validate_id_token(id_token, algorithm: nil, leeway: 60, nonce: nil, max_age: nil, issuer: nil, audience: nil, organization: @organization)
311
320
  context = {
312
321
  issuer: issuer || "https://#{@domain}/",
313
322
  audience: audience || @client_id,
@@ -317,6 +326,7 @@ module Auth0
317
326
 
318
327
  context[:nonce] = nonce unless nonce.nil?
319
328
  context[:max_age] = max_age unless max_age.nil?
329
+ context[:organization] = organization unless !organization
320
330
 
321
331
  Auth0::Mixins::Validation::IdTokenValidator.new(context).validate(id_token)
322
332
  end
data/lib/auth0/api/v2.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'auth0/api/v2/anomaly'
2
2
  require 'auth0/api/v2/blacklists'
3
+ require 'auth0/api/v2/branding'
3
4
  require 'auth0/api/v2/clients'
4
5
  require 'auth0/api/v2/client_grants'
5
6
  require 'auth0/api/v2/connections'
@@ -7,6 +8,7 @@ require 'auth0/api/v2/device_credentials'
7
8
  require 'auth0/api/v2/emails'
8
9
  require 'auth0/api/v2/jobs'
9
10
  require 'auth0/api/v2/prompts'
11
+ require 'auth0/api/v2/organizations'
10
12
  require 'auth0/api/v2/rules'
11
13
  require 'auth0/api/v2/roles'
12
14
  require 'auth0/api/v2/stats'
@@ -26,25 +28,27 @@ module Auth0
26
28
  module V2
27
29
  include Auth0::Api::V2::Anomaly
28
30
  include Auth0::Api::V2::Blacklists
31
+ include Auth0::Api::V2::Branding
29
32
  include Auth0::Api::V2::Clients
30
33
  include Auth0::Api::V2::ClientGrants
31
34
  include Auth0::Api::V2::Connections
32
35
  include Auth0::Api::V2::DeviceCredentials
33
36
  include Auth0::Api::V2::Emails
37
+ include Auth0::Api::V2::Guardian
34
38
  include Auth0::Api::V2::Jobs
39
+ include Auth0::Api::V2::Logs
40
+ include Auth0::Api::V2::LogStreams
35
41
  include Auth0::Api::V2::Prompts
42
+ include Auth0::Api::V2::Organizations
36
43
  include Auth0::Api::V2::Rules
37
44
  include Auth0::Api::V2::Roles
38
45
  include Auth0::Api::V2::Stats
39
46
  include Auth0::Api::V2::Users
40
47
  include Auth0::Api::V2::UsersByEmail
41
48
  include Auth0::Api::V2::UserBlocks
49
+ include Auth0::Api::V2::ResourceServers
42
50
  include Auth0::Api::V2::Tenants
43
51
  include Auth0::Api::V2::Tickets
44
- include Auth0::Api::V2::Logs
45
- include Auth0::Api::V2::LogStreams
46
- include Auth0::Api::V2::ResourceServers
47
- include Auth0::Api::V2::Guardian
48
52
  end
49
53
  end
50
54
  end