auth0 4.5.0 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +3 -2
  3. data/.github/ISSUE_TEMPLATE.md +39 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +35 -0
  5. data/CHANGELOG.md +38 -2
  6. data/CODE_OF_CONDUCT.md +3 -0
  7. data/DEPLOYMENT.md +33 -9
  8. data/Gemfile +6 -0
  9. data/README.md +6 -3
  10. data/Rakefile +4 -1
  11. data/build_travis.sh +1 -1
  12. data/lib/auth0/api/authentication_endpoints.rb +225 -86
  13. data/lib/auth0/api/v2/client_grants.rb +2 -2
  14. data/lib/auth0/api/v2/device_credentials.rb +5 -4
  15. data/lib/auth0/api/v2/logs.rb +11 -11
  16. data/lib/auth0/api/v2/resource_servers.rb +7 -8
  17. data/lib/auth0/api/v2/tickets.rb +6 -2
  18. data/lib/auth0/api/v2/users.rb +18 -17
  19. data/lib/auth0/api/v2/users_by_email.rb +3 -2
  20. data/lib/auth0/client.rb +1 -1
  21. data/lib/auth0/mixins.rb +4 -0
  22. data/lib/auth0/mixins/access_token_struct.rb +20 -0
  23. data/lib/auth0/mixins/api_token_struct.rb +10 -0
  24. data/lib/auth0/mixins/headers.rb +35 -0
  25. data/lib/auth0/mixins/httpproxy.rb +11 -3
  26. data/lib/auth0/mixins/initializer.rb +9 -21
  27. data/lib/auth0/version.rb +1 -1
  28. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_change_password/should_trigger_a_password_reset.yml +63 -0
  29. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_email.yml +54 -0
  30. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_password.yml +54 -0
  31. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_invalid_audience.yml +55 -0
  32. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_custom_audience.yml +117 -0
  33. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_default_scope.yml +119 -0
  34. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_saml_metadata/should_retrieve_SAML_metadata.yml +57 -0
  35. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_fail_as_not_authorized.yml +55 -0
  36. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_return_the_userinfo.yml +118 -0
  37. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_wsfed_metadata/should_retrieve_WSFED_metadata.yml +55 -0
  38. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/create_test_user.yml +58 -0
  39. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/delete_test_user.yml +54 -0
  40. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_add_token_to_blacklist/should_add_a_token_to_the_blacklist.yml +56 -0
  41. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_blacklisted_tokens/should_get_the_added_token_from_the_blacklist.yml +59 -0
  42. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_at_least_1_result.yml +62 -0
  43. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_first_page_of_one_result.yml +66 -0
  44. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_test_client_grant.yml +62 -0
  45. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_delete_client_grant/should_delete_the_test_client_grant.yml +54 -0
  46. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_patch_client_grant/should_update_the_test_client_grant.yml +64 -0
  47. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client.yml +118 -0
  48. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client_grant.yml +64 -0
  49. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client.yml +54 -0
  50. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client_grant.yml +54 -0
  51. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_exclude_and_include_fields_properly.yml +91 -0
  52. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_include_the_specified_fields.yml +63 -0
  53. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/should_get_the_test_client.yml +92 -0
  54. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_fields_not_specified.yml +60 -0
  55. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_the_specified_fields.yml +132 -0
  56. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_include_the_specified_fields.yml +63 -0
  57. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_paginate_results.yml +65 -0
  58. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/should_get_at_least_one_client.yml +132 -0
  59. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_delete_client/should_delete_the_test_client_without_an_error.yml +54 -0
  60. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_patch_client/should_update_the_client_with_the_correct_attributes.yml +94 -0
  61. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/create_test_client.yml +118 -0
  62. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +63 -0
  63. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +61 -0
  64. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +63 -0
  65. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +59 -0
  66. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +59 -0
  67. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +59 -0
  68. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +59 -0
  69. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +59 -0
  70. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +54 -0
  71. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +110 -0
  72. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +66 -0
  73. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +65 -0
  74. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_user.yml +68 -0
  75. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_delete_device_credential/should_delete_the_test_credential_without_an_error.yml +54 -0
  76. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/_filter_by_type/should_exclude_the_test_credential.yml +59 -0
  77. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_have_at_least_1_entry.yml +62 -0
  78. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_include_the_test_credential.yml +62 -0
  79. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_credential.yml +62 -0
  80. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_user.yml +68 -0
  81. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_credential.yml +54 -0
  82. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_user.yml +54 -0
  83. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_configure_provider/should_configure_a_new_email_provider.yml +63 -0
  84. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_delete_the_existing_email_provider_without_an_error.yml +54 -0
  85. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_throw_an_error_trying_to_get_the_email_provider.yml +51 -0
  86. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_with_specific_fields.yml +60 -0
  87. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_without_specific_fields.yml +61 -0
  88. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/should_get_the_existing_email_provider.yml +61 -0
  89. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_update_provider/should_update_the_existing_email_provider.yml +63 -0
  90. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/delete_existing_provider.yml +54 -0
  91. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_match_the_created_log_entry.yml +265 -0
  92. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_not_be_empty.yml +265 -0
  93. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_fields_not_specified.yml +61 -0
  94. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_the_specified_fields.yml +75 -0
  95. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_have_one_log_entry.yml +76 -0
  96. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_include_the_specified_fields.yml +62 -0
  97. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_from/should_take_one_log_entry.yml +258 -0
  98. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/create_test_user.yml +68 -0
  99. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_disabled_rule.yml +54 -0
  100. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_enabled_rule.yml +54 -0
  101. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_user.yml +54 -0
  102. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_delete_resource_server/should_delete_the_test_server_without_an_error.yml +54 -0
  103. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_server/should_get_the_test_server.yml +64 -0
  104. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/create_test_server.yml +66 -0
  105. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/delete_test_server.yml +54 -0
  106. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_disabled_rule_without_an_error.yml +54 -0
  107. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_enabled_rule_without_an_error.yml +54 -0
  108. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_fields_not_specified.yml +62 -0
  109. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_specified_fields.yml +62 -0
  110. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_include_the_specified_fields.yml +61 -0
  111. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/should_get_a_specific_rule.yml +62 -0
  112. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_exclude_fields_not_specified.yml +60 -0
  113. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_include_the_specified_fields.yml +61 -0
  114. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_disabled_rule.yml +63 -0
  115. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_enabled_rule.yml +62 -0
  116. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_paginated_results.yml +128 -0
  117. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/should_return_at_least_1_rule.yml +64 -0
  118. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_update_rule/should_update_the_disabled_rule_to_be_enabled.yml +64 -0
  119. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_disabled_rule.yml +65 -0
  120. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_enabled_rule.yml +65 -0
  121. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_active_users/should_have_at_least_one_active_user.yml +59 -0
  122. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_daily_stats/should_have_at_least_one_stats_entry_for_the_timeframe.yml +63 -0
  123. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings/should_get_the_tenant_settings.yml +95 -0
  124. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_exclude_a_field_not_requested.yml +61 -0
  125. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_include_the_field_requested.yml +61 -0
  126. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_revert_the_tenant_name.yml +96 -0
  127. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_update_the_tenant_settings_with_a_new_tenant_name.yml +96 -0
  128. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_email_verification/should_create_an_email_verification_ticket.yml +63 -0
  129. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_password_change/should_create_a_password_change_ticket.yml +63 -0
  130. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/create_test_user.yml +68 -0
  131. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/delete_test_user.yml +54 -0
  132. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_user_successfully.yml +54 -0
  133. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_email_verified_and_return_the_updated_data.yml +68 -0
  134. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_user_metadata_and_return_the_updated_user.yml +69 -0
  135. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_fields_not_indicated.yml +60 -0
  136. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_the_fields_indicated.yml +63 -0
  137. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_include_the_fields_indicated.yml +63 -0
  138. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/should_retrieve_the_created_user.yml +66 -0
  139. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v2_search_engine_query.yml +59 -0
  140. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v3_search_engine_query.yml +59 -0
  141. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_exclude_the_indicated_fields_when_paginated.yml +59 -0
  142. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_include_the_indicated_fields_when_paginated.yml +59 -0
  143. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_not_include_other_fields_when_paginated.yml +59 -0
  144. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_return_the_correct_number_of_results_when_paginated.yml +59 -0
  145. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/should_have_at_least_one_user.yml +59 -0
  146. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_user.yml +68 -0
  147. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +101 -42
  148. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +18 -5
  149. data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +38 -28
  150. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +98 -60
  151. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +117 -103
  152. data/spec/integration/lib/auth0/api/v2/api_device_credentials_spec.rb +101 -58
  153. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +72 -77
  154. data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +46 -38
  155. data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +72 -40
  156. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +113 -52
  157. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +11 -14
  158. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +40 -34
  159. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +36 -28
  160. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +111 -108
  161. data/spec/integration/lib/auth0/auth0_client_spec.rb +29 -22
  162. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +238 -13
  163. data/spec/lib/auth0/api/v2/tickets_spec.rb +13 -1
  164. data/spec/lib/auth0/client_spec.rb +126 -18
  165. data/spec/lib/auth0/mixins/initializer_spec.rb +1 -0
  166. data/spec/spec_helper.rb +45 -11
  167. data/spec/support/credentials.rb +22 -6
  168. data/spec/support/dummy_class.rb +6 -2
  169. data/spec/support/dummy_class_for_proxy.rb +1 -0
  170. metadata +246 -6
  171. data/spec/spec_helper_full.rb +0 -44
  172. data/spec/spec_helper_unit.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e2d0aa18336dc8b5427ef196eebe49f8232e2776c90307d1c38e2129d8704e8
4
- data.tar.gz: acfe0224309b9b2de3faa249f65e40654586f446494b53044d27cea4ad60b5da
3
+ metadata.gz: 44aa1a52cec04f4b9e2f8ac6f6d032cf599223f962f8f31f5ea75ac66f85a310
4
+ data.tar.gz: 522d4c589930e8c4036570b8c87fbccb3362cc386dbbc13ec828cc8134bce43a
5
5
  SHA512:
6
- metadata.gz: 194975ab5dce4b26bae48fdf25b143a7ae7ff47898e500dc0a49913bcecb54276919e79a70a8a5b2d1d064d176f15cd394bd58d26241f2388c35535ebf5614a5
7
- data.tar.gz: 29bde6a3792287ecae9d8559e0b52ed8fc57407a183665944e1883cb3ee64dede9169a8525b191042c86b6c05a2833b34b592d60ff58ec97161d427fa4b84f49
6
+ metadata.gz: d1aec8459dc67d87089273a12d5ab1c02b40509d92442d84d29123d2472c4499a8e252b325c6bc333ac7fc22bc2910bf9ed95cf6429444ec0d7c27b5ee8fe780
7
+ data.tar.gz: b44f46446c0ea25470b4ff7bfecba848983602cec4404b6221029aac21839e2127a9462ab2560e64b3869ef7f5d4fa212bf32e9b3a06c3858af8d1bc3de5fdaf
@@ -1,3 +1,4 @@
1
1
  ---
2
- BUNDLE_JOBS: '4'
3
- BUNDLE_BIN: bin
2
+ BUNDLE_JOBS: "3"
3
+ BUNDLE_BIN: "bin"
4
+ BUNDLE_RETRY: "3"
@@ -0,0 +1,39 @@
1
+ In order to efficiently and accurately address your issue or feature request, 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. Please delete any sections or questions below that do not pertain to this request.
2
+
3
+ For general support or usage questions, please use the [Auth0 Community](https://community.auth0.com/) or [Auth0 Support](https://support.auth0.com.).
4
+
5
+ ### Description
6
+
7
+ Description of the bug or feature request and why it's a problem. Consider including:
8
+
9
+ - The use case or overall problem you're trying to solve
10
+ - Information about when the problem started
11
+
12
+ ### Prerequisites
13
+
14
+ * [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
15
+ * [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
16
+ * [ ] Did you check the documentation ([repo README](https://github.com/auth0/ruby-auth0/blob/master/README.md) or [Quickstart](https://auth0.com/docs/quickstart/backend/rails))?
17
+ * [ ] Did you check the [Auth0 Community](https://community.auth0.com/)?
18
+ * [ ] Are you reporting this to the correct repository? See also the [OmniAuth-Auth0 strategy](https://github.com/auth0/omniauth-auth0) for logging in with Rails.
19
+ * [ ] Are there any related or duplicate [Issues](https://github.com/auth0/ruby-auth0/issues) or [PRs](https://github.com/auth0/ruby-auth0/pulls) for this issue?
20
+
21
+ ### Environment
22
+
23
+ Please provide the following:
24
+
25
+ * Ruby Auth0 version:
26
+ * Ruby version:
27
+ * Rails version (if applicable):
28
+ * Browser version (if applicable):
29
+ * Additional gems that might be affecting your instance
30
+
31
+ ### Reproduction
32
+
33
+ Detail the steps taken to reproduce this error and note if this issue can be reproduced consistently or if it is intermittent.
34
+
35
+ Please include:
36
+
37
+ - Log files (redact/remove sensitive information)
38
+ - Application settings (redact/remove sensitive information)
39
+ - Screenshots, if helpful
@@ -0,0 +1,35 @@
1
+ ### Changes
2
+
3
+ Please describe both what is changing and why this is important. Include:
4
+
5
+ - Endpoints added, deleted, deprecated, or changed
6
+ - Classes and methods added, deleted, deprecated, or changed
7
+ - Screenshots of new or changed UI, if applicable
8
+ - A summary of usage if this is a new feature or change to a public API (this should also be added to relevant documentation once released)
9
+
10
+ ### References
11
+
12
+ Please include relevant links supporting this change such as a:
13
+
14
+ - support ticket
15
+ - community post
16
+ - StackOverflow post
17
+ - support forum thread
18
+
19
+ Please note any links that are not publicly accessible.
20
+
21
+ ### Testing
22
+
23
+ Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
24
+
25
+ * [ ] This change adds unit test coverage
26
+ * [ ] This change adds integration test coverage
27
+ * [ ] This change has been tested on the latest version of Ruby
28
+
29
+ ### Checklist
30
+
31
+ * [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
32
+ * [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)
33
+ * [ ] All existing and new tests complete without errors
34
+ * [ ] Rubocop passes on all added/modified files
35
+ * [ ] All active GitHub checks have passed
@@ -1,6 +1,42 @@
1
1
  # Change Log
2
2
 
3
- ## [v4.5.0](https://github.com/auth0/ruby-auth0/tree/v4.5.0) (2018-07-26)
3
+ ## [v4.6.0](https://github.com/auth0/ruby-auth0/tree/v4.6.0) (2018-12-17)
4
+ [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.5.0...v4.6.0)
5
+
6
+ **Closed issues**
7
+ - New Release with Client Token work [\#148](https://github.com/auth0/ruby-auth0/issues/148)
8
+ - Unable to initialize Auth0Api [\#147](https://github.com/auth0/ruby-auth0/issues/147)
9
+ - Issues building the documentation [\#135](https://github.com/auth0/ruby-auth0/issues/135)
10
+ - signin with referral token [\#127](https://github.com/auth0/ruby-auth0/issues/127)
11
+ - Some challenges when upgrading to Ruby 2.5.1 [\#122](https://github.com/auth0/ruby-auth0/issues/122)
12
+ - Cannot refresh access token with refresh token. [\#111](https://github.com/auth0/ruby-auth0/issues/111)
13
+ - Incorrect request_params for username-password login [\#109](https://github.com/auth0/ruby-auth0/issues/109)
14
+ - Obtain APIv2 Token [\#86](https://github.com/auth0/ruby-auth0/issues/86)
15
+
16
+ **Added**
17
+ - Add refresh token method and unit tests [\#150](https://github.com/auth0/ruby-auth0/pull/150) ([joshcanhelp](https://github.com/joshcanhelp))
18
+ - Improve telemetry; more modular Auth API [\#149](https://github.com/auth0/ruby-auth0/pull/149) ([joshcanhelp](https://github.com/joshcanhelp))
19
+ - Add ttl_sec argument to post_email_verification request. [\#145](https://github.com/auth0/ruby-auth0/pull/145) ([digitaldawn](https://github.com/digitaldawn))
20
+ - Add issue and PR templates, CoC [\#141](https://github.com/auth0/ruby-auth0/pull/141) ([joshcanhelp](https://github.com/joshcanhelp))
21
+ - Add new login_ro method to replace login [\#133](https://github.com/auth0/ruby-auth0/pull/133) ([joshcanhelp](https://github.com/joshcanhelp))
22
+ - Add VCR to and improve all integration tests [\#132](https://github.com/auth0/ruby-auth0/pull/132) ([joshcanhelp](https://github.com/joshcanhelp))
23
+ - Add new method to perform an auth code exchange [\#131](https://github.com/auth0/ruby-auth0/pull/131) ([joshcanhelp](https://github.com/joshcanhelp))
24
+ - Add new userinfo method for auth endpoints [\#130](https://github.com/auth0/ruby-auth0/pull/130) ([joshcanhelp](https://github.com/joshcanhelp))
25
+ - Add Client Credentials grant [\#129](https://github.com/auth0/ruby-auth0/pull/129) ([joshcanhelp](https://github.com/joshcanhelp))
26
+
27
+ **Changed**
28
+ - Improve the test suite [\#143](https://github.com/auth0/ruby-auth0/pull/143) ([joshcanhelp](https://github.com/joshcanhelp))
29
+
30
+ **Deprecated**
31
+ - Formal deprecation of 4 auth endpoint methods; rubocop [\#151](https://github.com/auth0/ruby-auth0/pull/151) ([joshcanhelp](https://github.com/joshcanhelp))
32
+
33
+ **Fixed**
34
+ - Documentation improvements [\#139](https://github.com/auth0/ruby-auth0/pull/139) ([szemek](https://github.com/szemek))
35
+ - Fix typos in README.md [\#137](https://github.com/auth0/ruby-auth0/pull/137) ([swetax](https://github.com/swetax))
36
+ - Explicitly require JSON dependency [\#126](https://github.com/auth0/ruby-auth0/pull/126) ([jgaskins](https://github.com/jgaskins))
37
+
38
+
39
+ ## [v4.5.0](https://github.com/auth0/ruby-auth0/tree/v4.5.0) (2018-07-27)
4
40
  [Full Changelog](https://github.com/auth0/ruby-auth0/compare/v4.4.0...v4.5.0)
5
41
 
6
42
  **Closed issues:**
@@ -186,4 +222,4 @@
186
222
 
187
223
 
188
224
 
189
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
225
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
@@ -0,0 +1,3 @@
1
+ # Code of Conduct
2
+
3
+ Please see [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) for information on contributing to this repo.
@@ -1,14 +1,38 @@
1
- ```
1
+ ```bash
2
+ # Install gems for exec commands
2
3
  bundle install
3
- bundle exec rake spec
4
+
5
+ # Run all tests
6
+ MODE=full bundle exec rake all
7
+
8
+ # Create a release branch
9
+ git checkout master
10
+ git pull
11
+ git checkout -b release-X.X.X
12
+
13
+ # Update the version number
4
14
  bundle exec gem bump --version x.y.z
15
+
16
+ # Generate the changelog
17
+ github_changelog_generator -t $GITHUB_READ_TOKEN
18
+ # Review the changelog
19
+ # Remove "unreleased" section
20
+ # Make sure the tags are ordered
21
+
22
+ # Commit, push, and create a PR for this release
23
+ git commit -am "Release vX.X.X"
24
+ git push --set-upstream origin release-X.X.X
25
+ # Add related milestone
26
+ # Create PR on GitHub and assign for review
27
+ # Merge/rebase and delete branch once approved
28
+
29
+ # Create and add a tag
30
+ git checkout master
31
+ git pull
5
32
  bundle exec gem tag
6
- github_changelog_generator -t <YOUR TOKEN>
33
+ # Create a new release from this tag on GitHub using markdown from the changelog
34
+
35
+ # Make sure you are an author for this gem here https://rubygems.org/gems/auth0/
36
+ # Rubygems token can be updated in ~/.gem/credentials
7
37
  bundle exec gem release
8
38
  ```
9
-
10
- > Note for the changelog:
11
- * Review the changelog.
12
- * Remove "unreleased" section.
13
- * Make sure the tags are ordered.
14
- * Commit / push the changelog to master.
data/Gemfile CHANGED
@@ -9,3 +9,9 @@ group :development do
9
9
  gem 'rubocop', require: false
10
10
  gem 'yard', require: false
11
11
  end
12
+
13
+ group :test do
14
+ gem 'webmock', require: false
15
+ gem 'vcr', require: false
16
+ gem 'codecov', require: false
17
+ end
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
+ # Auth0 - Ruby
2
+
1
3
  [![Build Status](https://travis-ci.org/auth0/ruby-auth0.svg?branch=master)](https://travis-ci.org/auth0/ruby-auth0)
2
4
  [![Gem Version](https://badge.fury.io/rb/auth0.svg)](http://badge.fury.io/rb/auth0)
3
5
  [![Coverage Status](https://coveralls.io/repos/auth0/ruby-auth0/badge.svg?branch=master)](https://coveralls.io/r/auth0/ruby-auth0?branch=master)
4
6
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/github/auth0/ruby-auth0/master/frames)
7
+ [![MIT licensed](https://img.shields.io/dub/l/vibe-d.svg?style=flat)](https://github.com/auth0/ruby-auth0/blob/master/LICENSE)
5
8
 
6
9
  Ruby API client for the [Auth0](https://auth0.com) platform.
7
10
 
@@ -27,7 +30,7 @@ You can build the API documentation with the following:
27
30
  bundle exec rake documentation
28
31
  ```
29
32
 
30
- To view the generated documentation, open `doc/Auth0/Api.html`
33
+ To view the generated documentation, open `doc/Auth0/Api.html` .
31
34
 
32
35
  ## Management API v2
33
36
 
@@ -97,12 +100,12 @@ In addition to the Management API, this SDK also provides access to [Authenticat
97
100
 
98
101
  * Register a new user with a database connection using the `signup` method.
99
102
  * Redirect a user to the universal login page for authentication using the `authorization_url` method.
100
- * Log a user in to a highly trusted app with the [Resource Owner Password grant](https://auth0.com/docs/api-auth/tutorials/password-grant) using the `login` method.
103
+ * 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.
101
104
  * Exchange an authorization code for an access token on callback using the `obtain_user_tokens` method (see the note on state validation below).
102
105
  * Send a change password email to a database connection user using the `change_password` method.
103
106
  * Log a user out of Auth0 with the `logout_url` method.
104
107
 
105
- **Important note on state validation**: If you choose to implement a login flow callback youself, 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).
108
+ **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).
106
109
 
107
110
  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).
108
111
 
data/Rakefile CHANGED
@@ -44,7 +44,10 @@ begin
44
44
  desc 'Run All Suites'
45
45
  RSpec::Core::RakeTask.new(:all)
46
46
 
47
- task default: [:rubocop, :spec]
47
+ desc 'Run unit and integration tests'
48
+ task test: [:spec, :integration]
49
+
50
+ task default: [:rubocop, :test]
48
51
  rescue LoadError
49
52
  puts 'Load Error - No RSpec'
50
53
  end
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
 
3
3
  if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ]; then
4
- MODE=full bundle exec rake all
4
+ bundle exec rake all
5
5
  else
6
6
  bundle exec rake spec
7
7
  fi
@@ -7,68 +7,116 @@ module Auth0
7
7
  UP_AUTH = 'Username-Password-Authentication'.freeze
8
8
  JWT_BEARER = 'urn:ietf:params:oauth:grant-type:jwt-bearer'.freeze
9
9
 
10
- # Retrieve an access token.
11
- # @see https://auth0.com/docs/api/authentication#client-credentials
12
- # @param access_token [string] Social provider's access_token
13
- # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
14
- # @return [json] Returns the access token
15
- def obtain_access_token(access_token = nil, connection = 'facebook', scope = 'openid')
16
- if access_token
17
- request_params = { client_id: @client_id, access_token: access_token, connection: connection, scope: scope }
18
- post('/oauth/access_token', request_params)['access_token']
19
- else
20
- request_params = { client_id: @client_id, client_secret: @client_secret, grant_type: 'client_credentials' }
21
- post('/oauth/token', request_params)['access_token']
22
- end
10
+ # Request an API access token using a Client Credentials grant
11
+ # @see https://auth0.com/docs/api-auth/tutorials/client-credentials
12
+ # @param audience [string] API audience to use
13
+ # @return [json] Returns the API token
14
+ def api_token(
15
+ client_id: @client_id,
16
+ client_secret: @client_secret,
17
+ audience: "https://#{@domain}/api/v2/"
18
+ )
19
+ request_params = {
20
+ grant_type: 'client_credentials',
21
+ client_id: client_id,
22
+ client_secret: client_secret,
23
+ audience: audience
24
+ }
25
+ response = post('/oauth/token', request_params)
26
+ ApiToken.new(response['access_token'], response['scope'], response['expires_in'])
23
27
  end
24
28
 
25
29
  # Get access and ID tokens using an Authorization Code.
26
30
  # @see https://auth0.com/docs/api/authentication#authorization-code
27
- # @param code [string] The access code obtained through passive authentication
28
- # @param redirect_uri [string] Url to redirect after authorization
29
- # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
30
- # @param scope [string] Defaults to openid. Can be 'openid name email', 'openid offline_access'
31
- # @return [json] Returns the access_token and id_token
32
- def obtain_user_tokens(code, redirect_uri, connection = 'facebook', scope = 'openid')
33
- raise Auth0::InvalidParameter, 'Must supply a valid code' if code.to_s.empty?
34
- raise Auth0::InvalidParameter, 'Must supply a valid redirect_uri' if redirect_uri.to_s.empty?
31
+ # @param code [string] The authentication code obtained from /authorize
32
+ # @param redirect_uri [string] URL to redirect to after authorization.
33
+ # Required only if it was set at the GET /authorize endpoint
34
+ # @param client_id [string] Client ID for the Application
35
+ # @param client_secret [string] Client Secret for the Application.
36
+ # @return [AccessToken] Returns the access_token and id_token
37
+ def exchange_auth_code_for_tokens(
38
+ code,
39
+ redirect_uri: nil,
40
+ client_id: @client_id,
41
+ client_secret: @client_secret
42
+ )
43
+ raise Auth0::InvalidParameter, 'Must provide an authorization code' if code.to_s.empty?
44
+
35
45
  request_params = {
36
- client_id: @client_id,
37
- client_secret: @client_secret,
38
- connection: connection,
39
- grant_type: 'authorization_code',
40
- code: code,
41
- scope: scope,
42
- redirect_uri: redirect_uri
46
+ grant_type: 'authorization_code',
47
+ client_id: client_id,
48
+ client_secret: client_secret,
49
+ code: code,
50
+ redirect_uri: redirect_uri
43
51
  }
44
- post('/oauth/token', request_params)
52
+ AccessToken.from_response post('/oauth/token', request_params)
53
+ end
54
+
55
+ # Get access and ID tokens using a refresh token.
56
+ # @see https://auth0.com/docs/api/authentication#refresh-token
57
+ # @param refresh_token [string] Refresh token to use. Request this with
58
+ # the offline_access scope when logging in.
59
+ # @param client_id [string] Client ID for the Application
60
+ # @param client_secret [string] Client Secret for the Application.
61
+ # Required when the Application's Token Endpoint Authentication Method
62
+ # is Post or Basic.
63
+ # @return [AccessToken] Returns tokens allowed in the refresh_token
64
+ def exchange_refresh_token(
65
+ refresh_token,
66
+ client_id: @client_id,
67
+ client_secret: @client_secret
68
+ )
69
+ raise Auth0::InvalidParameter, 'Must provide a refresh token' if refresh_token.to_s.empty?
70
+
71
+ request_params = {
72
+ grant_type: 'refresh_token',
73
+ client_id: client_id,
74
+ client_secret: client_secret,
75
+ refresh_token: refresh_token
76
+ }
77
+ AccessToken.from_response post('/oauth/token', request_params)
45
78
  end
46
79
 
80
+ # rubocop:disable Metrics/ParameterLists
47
81
  # Get access and ID tokens using Resource Owner Password.
82
+ # Requires that your tenant has a Default Audience or Default Directory.
48
83
  # @see https://auth0.com/docs/api/authentication#resource-owner-password
49
- # @param username [string] Username or email
84
+ # @param login_name [string] Email or username for the connection
50
85
  # @param password [string] Password
51
- # @param id_token [string] Token's id
52
- # @param connection_name [string] Connection name; use a database or
53
- # passwordless connection, Active Directory/LDAP, Windows Azure or ADF
54
- # @param options [hash] Additional options - :scope, :grant_type, :device
86
+ # @param client_id [string] Client ID from Application settings
87
+ # @param client_secret [string] Client Secret from Application settings
88
+ # @param realm [string] Specific realm to authenticate against
89
+ # @param audience [string] API audience
90
+ # @param scope [string] Scope(s) requested
91
+ # - Include an audience (above) for API access scopes
92
+ # - Use the default "openid" for userinfo calls
55
93
  # @return [json] Returns the access_token and id_token
56
- def login(username, password, id_token = nil, connection_name = UP_AUTH, options = {})
57
- raise Auth0::InvalidParameter, 'Must supply a valid username' if username.to_s.empty?
58
- raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
94
+ def login_with_resource_owner(
95
+ login_name,
96
+ password,
97
+ client_id: @client_id,
98
+ client_secret: @client_secret,
99
+ realm: nil,
100
+ audience: nil,
101
+ scope: 'openid'
102
+ )
103
+
104
+ raise Auth0::InvalidParameter, 'Must supply a valid login_name' if login_name.empty?
105
+ raise Auth0::InvalidParameter, 'Must supply a valid password' if password.empty?
106
+
59
107
  request_params = {
60
- client_id: @client_id,
61
- client_secret: @client_secret,
62
- username: username,
63
- password: password,
64
- scope: options.fetch(:scope, 'openid'),
65
- connection: connection_name,
66
- grant_type: options.fetch(:grant_type, 'password'),
67
- id_token: id_token,
68
- device: options.fetch(:device, nil)
108
+ username: login_name,
109
+ password: password,
110
+ client_id: client_id,
111
+ client_secret: client_secret,
112
+ realm: realm,
113
+ scope: scope,
114
+ audience: audience,
115
+ grant_type: realm ? 'http://auth0.com/oauth/grant-type/password-realm' : 'password'
69
116
  }
70
- post('/oauth/token', request_params)
117
+ AccessToken.from_response post('/oauth/token', request_params)
71
118
  end
119
+ # rubocop:enable Metrics/ParameterLists
72
120
 
73
121
  # Sign up with a database connection using a username and password.
74
122
  # @see https://auth0.com/docs/api/authentication#signup
@@ -79,11 +127,12 @@ module Auth0
79
127
  def signup(email, password, connection_name = UP_AUTH)
80
128
  raise Auth0::InvalidParameter, 'Must supply a valid email' if email.to_s.empty?
81
129
  raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
130
+
82
131
  request_params = {
83
- email: email,
84
- password: password,
132
+ email: email,
133
+ password: password,
85
134
  connection: connection_name,
86
- client_id: @client_id
135
+ client_id: @client_id
87
136
  }
88
137
  post('/dbconnections/signup', request_params)
89
138
  end
@@ -97,11 +146,12 @@ module Auth0
97
146
  # @param connection_name [string] Database connection name
98
147
  def change_password(email, password, connection_name = UP_AUTH)
99
148
  raise Auth0::InvalidParameter, 'Must supply a valid email' if email.to_s.empty?
149
+
100
150
  request_params = {
101
- email: email,
102
- password: password,
151
+ email: email,
152
+ password: password,
103
153
  connection: connection_name,
104
- client_id: @client_id
154
+ client_id: @client_id
105
155
  }
106
156
  post('/dbconnections/change_password', request_params)
107
157
  end
@@ -114,12 +164,13 @@ module Auth0
114
164
  # @param auth_params [hash] Append or override the magic link parameters
115
165
  def start_passwordless_email_flow(email, send = 'link', auth_params = {})
116
166
  raise Auth0::InvalidParameter, 'Must supply a valid email' if email.to_s.empty?
167
+
117
168
  request_params = {
118
- email: email,
119
- send: send,
120
- authParams: auth_params,
121
- connection: 'email',
122
- client_id: @client_id
169
+ email: email,
170
+ send: send,
171
+ authParams: auth_params,
172
+ connection: 'email',
173
+ client_id: @client_id
123
174
  }
124
175
  post('/passwordless/start', request_params)
125
176
  end
@@ -130,10 +181,11 @@ module Auth0
130
181
  # @param phone_number [string] User's phone number.
131
182
  def start_passwordless_sms_flow(phone_number)
132
183
  raise Auth0::InvalidParameter, 'Must supply a valid phone number' if phone_number.to_s.empty?
184
+
133
185
  request_params = {
134
186
  phone_number: phone_number,
135
- connection: 'sms',
136
- client_id: @client_id
187
+ connection: 'sms',
188
+ client_id: @client_id
137
189
  }
138
190
  post('/passwordless/start', request_params)
139
191
  end
@@ -155,8 +207,8 @@ module Auth0
155
207
  # Return the user information based on the Auth0 access token.
156
208
  # @see https://auth0.com/docs/api/authentication#get-user-info
157
209
  # @return [json] User information based on the Auth0 access token
158
- def user_info
159
- get('/userinfo')
210
+ def userinfo(access_token)
211
+ get('/userinfo', {}, 'Authorization' => "Bearer #{access_token}")
160
212
  end
161
213
 
162
214
  # Return an authorization URL.
@@ -166,6 +218,7 @@ module Auth0
166
218
  # @return [url] Authorization URL.
167
219
  def authorization_url(redirect_uri, options = {})
168
220
  raise Auth0::InvalidParameter, 'Must supply a valid redirect_uri' if redirect_uri.to_s.empty?
221
+
169
222
  request_params = {
170
223
  client_id: @client_id,
171
224
  response_type: options.fetch(:response_type, 'code'),
@@ -225,7 +278,7 @@ module Auth0
225
278
  wreply: options[:wreply]
226
279
  }
227
280
 
228
- url_client_id = @client_id if !request_params[:wtrealm]
281
+ url_client_id = @client_id unless request_params[:wtrealm]
229
282
  URI::HTTPS.build(
230
283
  host: @domain,
231
284
  path: "/wsfed/#{url_client_id}",
@@ -233,6 +286,86 @@ module Auth0
233
286
  )
234
287
  end
235
288
 
289
+ #
290
+ # DEPRECATED
291
+ #
292
+
293
+ # Retrieve an access token.
294
+ # @deprecated 4.6.0 - Use the api_token method instead.
295
+ # @see https://auth0.com/docs/api/authentication#client-credentials
296
+ # @param access_token [string] Social provider's access_token
297
+ # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
298
+ # @return [json] Returns the access token
299
+ def obtain_access_token(access_token = nil, connection = 'facebook', scope = 'openid')
300
+ if access_token
301
+ request_params = { client_id: @client_id, access_token: access_token, connection: connection, scope: scope }
302
+ post('/oauth/access_token', request_params)['access_token']
303
+ else
304
+ request_params = { client_id: @client_id, client_secret: @client_secret, grant_type: 'client_credentials' }
305
+ post('/oauth/token', request_params)['access_token']
306
+ end
307
+ end
308
+
309
+ # Get access and ID tokens using an Authorization Code.
310
+ # @deprecated 4.6.0 - Use the exchange_auth_code_for_tokens method instead.
311
+ # @see https://auth0.com/docs/api/authentication#authorization-code
312
+ # @param code [string] The access code obtained through passive authentication
313
+ # @param redirect_uri [string] Url to redirect after authorization
314
+ # @param connection [string] Currently, this endpoint only works for Facebook, Google, Twitter and Weibo
315
+ # @param scope [string] Defaults to openid. Can be 'openid name email', 'openid offline_access'
316
+ # @return [json] Returns the access_token and id_token
317
+ def obtain_user_tokens(code, redirect_uri, connection = 'facebook', scope = 'openid')
318
+ raise Auth0::InvalidParameter, 'Must supply a valid code' if code.to_s.empty?
319
+ raise Auth0::InvalidParameter, 'Must supply a valid redirect_uri' if redirect_uri.to_s.empty?
320
+
321
+ request_params = {
322
+ client_id: @client_id,
323
+ client_secret: @client_secret,
324
+ connection: connection,
325
+ grant_type: 'authorization_code',
326
+ code: code,
327
+ scope: scope,
328
+ redirect_uri: redirect_uri
329
+ }
330
+ post('/oauth/token', request_params)
331
+ end
332
+
333
+ # Get access and ID tokens using Resource Owner Password.
334
+ # @deprecated 4.6.0 - Use the login_with_resource_owner method instead.
335
+ # @see https://auth0.com/docs/api/authentication#resource-owner-password
336
+ # @param username [string] Username or email
337
+ # @param password [string] Password
338
+ # @param id_token [string] Token's id
339
+ # @param connection_name [string] Connection name; use a database or
340
+ # passwordless connection, Active Directory/LDAP, Windows Azure or ADF
341
+ # @param options [hash] Additional options - :scope, :grant_type, :device
342
+ # @return [json] Returns the access_token and id_token
343
+ def login(username, password, id_token = nil, connection_name = UP_AUTH, options = {})
344
+ raise Auth0::InvalidParameter, 'Must supply a valid username' if username.to_s.empty?
345
+ raise Auth0::InvalidParameter, 'Must supply a valid password' if password.to_s.empty?
346
+
347
+ request_params = {
348
+ client_id: @client_id,
349
+ client_secret: @client_secret,
350
+ username: username,
351
+ password: password,
352
+ scope: options.fetch(:scope, 'openid'),
353
+ connection: connection_name,
354
+ grant_type: options.fetch(:grant_type, 'password'),
355
+ id_token: id_token,
356
+ device: options.fetch(:device, nil)
357
+ }
358
+ post('/oauth/token', request_params)
359
+ end
360
+
361
+ # Return the user information based on the Auth0 access token.
362
+ # @deprecated 4.6.0 - Use the userinfo method instead.
363
+ # @see https://auth0.com/docs/api/authentication#get-user-info
364
+ # @return [json] User information based on the Auth0 access token
365
+ def user_info
366
+ get('/userinfo')
367
+ end
368
+
236
369
  # Login using phone number + verification code.
237
370
  # @deprecated 4.5.0 - Legacy authentication pipeline; use a Password Grant
238
371
  # instead - https://auth0.com/docs/api-auth/tutorials/password-grant
@@ -243,11 +376,12 @@ module Auth0
243
376
  def phone_login(phone_number, code, scope = 'openid')
244
377
  raise Auth0::InvalidParameter, 'Must supply a valid phone number' if phone_number.to_s.empty?
245
378
  raise Auth0::InvalidParameter, 'Must supply a valid code' if code.to_s.empty?
379
+
246
380
  request_params = {
247
- client_id: @client_id,
248
- username: phone_number,
249
- password: code,
250
- scope: scope,
381
+ client_id: @client_id,
382
+ username: phone_number,
383
+ password: code,
384
+ scope: scope,
251
385
  connection: 'sms',
252
386
  grant_type: 'password'
253
387
  }
@@ -261,6 +395,7 @@ module Auth0
261
395
  # @return User information associated with the user id (sub property) of the token.
262
396
  def token_info(id_token)
263
397
  raise Auth0::InvalidParameter, 'Must supply a valid id_token' if id_token.to_s.empty?
398
+
264
399
  request_params = { id_token: id_token }
265
400
  post('/tokeninfo', request_params)
266
401
  end
@@ -278,13 +413,14 @@ module Auth0
278
413
  # @return [json] Returns the refreshed delegation token
279
414
  def refresh_delegation(refresh_token, target, scope = 'openid', api_type = 'app', extra_parameters = {})
280
415
  raise Auth0::InvalidParameter, 'Must supply a valid token to refresh' if refresh_token.to_s.empty?
416
+
281
417
  request_params = {
282
- client_id: @client_id,
283
- grant_type: JWT_BEARER,
284
- refresh_token: refresh_token,
285
- target: target,
286
- api_type: api_type,
287
- scope: scope
418
+ client_id: @client_id,
419
+ grant_type: JWT_BEARER,
420
+ refresh_token: refresh_token,
421
+ target: target,
422
+ api_type: api_type,
423
+ scope: scope
288
424
  }.merge(extra_parameters)
289
425
  post('/delegation', request_params)
290
426
  end
@@ -302,13 +438,14 @@ module Auth0
302
438
  # @return [json] Returns the refreshed delegation token
303
439
  def delegation(id_token, target, scope = 'openid', api_type = 'app', extra_parameters = {})
304
440
  raise Auth0::InvalidParameter, 'Must supply a valid id_token' if id_token.to_s.empty?
441
+
305
442
  request_params = {
306
- client_id: @client_id,
443
+ client_id: @client_id,
307
444
  grant_type: JWT_BEARER,
308
- id_token: id_token,
309
- target: target,
310
- api_type: api_type,
311
- scope: scope
445
+ id_token: id_token,
446
+ target: target,
447
+ api_type: api_type,
448
+ scope: scope
312
449
  }.merge(extra_parameters)
313
450
  post('/delegation', request_params)
314
451
  end
@@ -327,16 +464,17 @@ module Auth0
327
464
  raise Auth0::InvalidParameter, 'Must supply a valid app_client_id' if app_client_id.to_s.empty?
328
465
  raise Auth0::InvalidParameter, 'Must supply a valid impersonator_id' if impersonator_id.to_s.empty?
329
466
  raise Auth0::MissingParameter, 'Must supply client_secret' if @client_secret.nil?
467
+
330
468
  authorization_header obtain_access_token
331
469
  request_params = {
332
- protocol: options.fetch(:protocol, 'oauth2'),
333
- impersonator_id: impersonator_id,
334
- client_id: app_client_id,
470
+ protocol: options.fetch(:protocol, 'oauth2'),
471
+ impersonator_id: impersonator_id,
472
+ client_id: app_client_id,
335
473
  additionalParameters: {
336
- response_type: options.fetch(:response_type, 'code'),
337
- state: options.fetch(:state, ''),
338
- scope: options.fetch(:scope, 'openid'),
339
- callback_url: options.fetch(:callback_url, '')
474
+ response_type: options.fetch(:response_type, 'code'),
475
+ state: options.fetch(:state, ''),
476
+ scope: options.fetch(:scope, 'openid'),
477
+ callback_url: options.fetch(:callback_url, '')
340
478
  }
341
479
  }
342
480
  result = post("/users/#{user_id}/impersonate", request_params)
@@ -354,8 +492,9 @@ module Auth0
354
492
  def unlink_user(access_token, user_id)
355
493
  raise Auth0::InvalidParameter, 'Must supply a valid access_token' if access_token.to_s.empty?
356
494
  raise Auth0::InvalidParameter, 'Must supply a valid user_id' if user_id.to_s.empty?
495
+
357
496
  request_params = {
358
- access_token: access_token,
497
+ access_token: access_token,
359
498
  user_id: user_id
360
499
  }
361
500
  post('/unlink', request_params)