auth0 4.4.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 (289) hide show
  1. checksums.yaml +4 -4
  2. data/.bundle/config +3 -2
  3. data/.circleci/config.yml +44 -0
  4. data/.env.example +2 -0
  5. data/.github/CODEOWNERS +1 -0
  6. data/.github/ISSUE_TEMPLATE/config.yml +8 -0
  7. data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
  8. data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
  9. data/.github/PULL_REQUEST_TEMPLATE.md +35 -0
  10. data/.github/stale.yml +20 -0
  11. data/.gitignore +1 -2
  12. data/.rubocop.yml +2 -0
  13. data/.yardoc/checksums +22 -0
  14. data/.yardoc/complete +0 -0
  15. data/.yardoc/object_types +0 -0
  16. data/.yardoc/objects/root.dat +0 -0
  17. data/.yardoc/proxy_types +0 -0
  18. data/CHANGELOG.md +334 -19
  19. data/CODE_OF_CONDUCT.md +3 -0
  20. data/DEPLOYMENT.md +56 -9
  21. data/Gemfile +10 -3
  22. data/README.md +260 -37
  23. data/Rakefile +4 -23
  24. data/auth0.gemspec +10 -9
  25. data/codecov.yml +22 -0
  26. data/examples/ruby-api/.gitignore +0 -6
  27. data/lib/auth0/algorithm.rb +5 -0
  28. data/lib/auth0/api/authentication_endpoints.rb +244 -237
  29. data/lib/auth0/api/v2/anomaly.rb +36 -0
  30. data/lib/auth0/api/v2/branding.rb +66 -0
  31. data/lib/auth0/api/v2/client_grants.rb +14 -5
  32. data/lib/auth0/api/v2/clients.rb +9 -6
  33. data/lib/auth0/api/v2/connections.rb +19 -7
  34. data/lib/auth0/api/v2/device_credentials.rb +5 -4
  35. data/lib/auth0/api/v2/guardian.rb +142 -0
  36. data/lib/auth0/api/v2/jobs.rb +77 -13
  37. data/lib/auth0/api/v2/log_streams.rb +78 -0
  38. data/lib/auth0/api/v2/logs.rb +11 -11
  39. data/lib/auth0/api/v2/organizations.rb +335 -0
  40. data/lib/auth0/api/v2/prompts.rb +70 -0
  41. data/lib/auth0/api/v2/resource_servers.rb +32 -8
  42. data/lib/auth0/api/v2/roles.rb +172 -0
  43. data/lib/auth0/api/v2/rules.rb +6 -2
  44. data/lib/auth0/api/v2/tickets.rb +55 -8
  45. data/lib/auth0/api/v2/users.rb +168 -28
  46. data/lib/auth0/api/v2/users_by_email.rb +3 -2
  47. data/lib/auth0/api/v2.rb +16 -2
  48. data/lib/auth0/client.rb +1 -1
  49. data/lib/auth0/exception.rb +34 -9
  50. data/lib/auth0/mixins/access_token_struct.rb +20 -0
  51. data/lib/auth0/mixins/api_token_struct.rb +10 -0
  52. data/lib/auth0/mixins/headers.rb +35 -0
  53. data/lib/auth0/mixins/httpproxy.rb +37 -14
  54. data/lib/auth0/mixins/initializer.rb +10 -26
  55. data/lib/auth0/mixins/permission_struct.rb +3 -0
  56. data/lib/auth0/mixins/validation.rb +346 -0
  57. data/lib/auth0/mixins.rb +9 -1
  58. data/lib/auth0/version.rb +1 -1
  59. data/lib/auth0.rb +1 -0
  60. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_change_password/should_trigger_a_password_reset.yml +63 -0
  61. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_email.yml +54 -0
  62. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_password.yml +54 -0
  63. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_invalid_audience.yml +55 -0
  64. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_custom_audience.yml +117 -0
  65. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_default_scope.yml +119 -0
  66. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_saml_metadata/should_retrieve_SAML_metadata.yml +57 -0
  67. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_fail_as_not_authorized.yml +55 -0
  68. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_return_the_userinfo.yml +118 -0
  69. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_wsfed_metadata/should_retrieve_WSFED_metadata.yml +55 -0
  70. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/create_test_user.yml +58 -0
  71. data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/delete_test_user.yml +54 -0
  72. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_check_if_ip_is_blocked/should_return_200_response_code.yml +65 -0
  73. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_remove_ip_block/should_remove_an_IP_successfully.yml +60 -0
  74. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_add_token_to_blacklist/should_add_a_token_to_the_blacklist.yml +56 -0
  75. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_blacklisted_tokens/should_get_the_added_token_from_the_blacklist.yml +59 -0
  76. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_at_least_1_result.yml +62 -0
  77. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_first_page_of_one_result.yml +66 -0
  78. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_test_client_grant.yml +62 -0
  79. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_delete_client_grant/should_delete_the_test_client_grant.yml +54 -0
  80. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_patch_client_grant/should_update_the_test_client_grant.yml +64 -0
  81. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client.yml +118 -0
  82. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client_grant.yml +64 -0
  83. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client.yml +54 -0
  84. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client_grant.yml +54 -0
  85. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_exclude_and_include_fields_properly.yml +91 -0
  86. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_include_the_specified_fields.yml +63 -0
  87. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/should_get_the_test_client.yml +92 -0
  88. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_fields_not_specified.yml +60 -0
  89. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_the_specified_fields.yml +132 -0
  90. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_include_the_specified_fields.yml +63 -0
  91. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_paginate_results.yml +65 -0
  92. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/should_get_at_least_one_client.yml +132 -0
  93. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_delete_client/should_delete_the_test_client_without_an_error.yml +54 -0
  94. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_patch_client/should_update_the_client_with_the_correct_attributes.yml +94 -0
  95. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/create_test_client.yml +118 -0
  96. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +63 -0
  97. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +61 -0
  98. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +63 -0
  99. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +59 -0
  100. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +59 -0
  101. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +59 -0
  102. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +59 -0
  103. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +59 -0
  104. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +54 -0
  105. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +110 -0
  106. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +66 -0
  107. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +65 -0
  108. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_user.yml +68 -0
  109. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_delete_device_credential/should_delete_the_test_credential_without_an_error.yml +54 -0
  110. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/_filter_by_type/should_exclude_the_test_credential.yml +59 -0
  111. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_have_at_least_1_entry.yml +62 -0
  112. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_include_the_test_credential.yml +62 -0
  113. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_credential.yml +62 -0
  114. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_user.yml +68 -0
  115. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_credential.yml +54 -0
  116. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_user.yml +54 -0
  117. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_configure_provider/should_configure_a_new_email_provider.yml +63 -0
  118. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_delete_the_existing_email_provider_without_an_error.yml +54 -0
  119. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_throw_an_error_trying_to_get_the_email_provider.yml +51 -0
  120. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_with_specific_fields.yml +60 -0
  121. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_without_specific_fields.yml +61 -0
  122. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/should_get_the_existing_email_provider.yml +61 -0
  123. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_update_provider/should_update_the_existing_email_provider.yml +63 -0
  124. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/delete_existing_provider.yml +54 -0
  125. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_create_an_export_users_job_successfully.yml +61 -0
  126. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_get_the_export_users_job.yml +117 -0
  127. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_create_an_import_users_job_successfully.yml +60 -0
  128. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_get_the_import_users_job.yml +116 -0
  129. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_create_a_new_verification_email_job.yml +119 -0
  130. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_get_the_completed_verification_email.yml +175 -0
  131. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_reject_an_invalid_client_id.yml +109 -0
  132. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/delete_imported_user.yml +110 -0
  133. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/search_for_connection_id.yml +59 -0
  134. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_match_the_created_log_entry.yml +265 -0
  135. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_not_be_empty.yml +265 -0
  136. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_fields_not_specified.yml +61 -0
  137. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_the_specified_fields.yml +75 -0
  138. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_have_one_log_entry.yml +76 -0
  139. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_include_the_specified_fields.yml +62 -0
  140. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_from/should_take_one_log_entry.yml +258 -0
  141. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/create_test_user.yml +68 -0
  142. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_disabled_rule.yml +54 -0
  143. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_enabled_rule.yml +54 -0
  144. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_user.yml +54 -0
  145. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_delete_resource_server/should_delete_the_test_server_without_an_error.yml +54 -0
  146. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_patch_resource_server/should_update_the_resource_server_with_the_correct_attributes.yml +61 -0
  147. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_server/should_get_the_test_server.yml +59 -0
  148. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_get_the_test_server.yml +59 -0
  149. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_at_least_1_result.yml +59 -0
  150. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_the_first_page_of_one_result.yml +64 -0
  151. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/create_test_server.yml +61 -0
  152. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/delete_test_server.yml +54 -0
  153. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_permissions/should_add_a_Permission_to_the_Role_successfully.yml +69 -0
  154. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_users/should_add_a_User_to_the_Role_successfully.yml +69 -0
  155. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_delete_role/should_delete_the_Role_successfully.yml +62 -0
  156. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role/should_get_the_Role_successfully.yml +67 -0
  157. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_exactly_1_Permission.yml +67 -0
  158. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_the_added_Permission_from_the_Role_successfully.yml +67 -0
  159. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_exactly_1_User.yml +67 -0
  160. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_the_added_User_from_the_Role_successfully.yml +67 -0
  161. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_roles/should_get_the_Role_successfully.yml +67 -0
  162. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_remove_role_permissions/should_remove_a_Permission_from_the_Role_successfully.yml +64 -0
  163. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_update_role/should_update_the_Role_successfully.yml +69 -0
  164. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_api.yml +69 -0
  165. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_role.yml +69 -0
  166. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_user.yml +69 -0
  167. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_api.yml +62 -0
  168. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_user.yml +62 -0
  169. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_disabled_rule_without_an_error.yml +54 -0
  170. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_enabled_rule_without_an_error.yml +54 -0
  171. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_fields_not_specified.yml +62 -0
  172. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_specified_fields.yml +62 -0
  173. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_include_the_specified_fields.yml +61 -0
  174. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/should_get_a_specific_rule.yml +62 -0
  175. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_exclude_fields_not_specified.yml +60 -0
  176. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_include_the_specified_fields.yml +61 -0
  177. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_disabled_rule.yml +63 -0
  178. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_enabled_rule.yml +62 -0
  179. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_paginated_results.yml +128 -0
  180. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/should_return_at_least_1_rule.yml +64 -0
  181. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_update_rule/should_update_the_disabled_rule_to_be_enabled.yml +64 -0
  182. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_disabled_rule.yml +65 -0
  183. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_enabled_rule.yml +65 -0
  184. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_active_users/should_have_at_least_one_active_user.yml +59 -0
  185. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_daily_stats/should_have_at_least_one_stats_entry_for_the_timeframe.yml +63 -0
  186. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings/should_get_the_tenant_settings.yml +95 -0
  187. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_exclude_a_field_not_requested.yml +61 -0
  188. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_include_the_field_requested.yml +61 -0
  189. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_revert_the_tenant_name.yml +96 -0
  190. 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
  191. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_email_verification/should_create_an_email_verification_ticket.yml +63 -0
  192. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_password_change/should_create_a_password_change_ticket.yml +63 -0
  193. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/create_test_user.yml +68 -0
  194. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/delete_test_user.yml +54 -0
  195. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_permissions/should_add_a_Permissions_for_a_User_successfully.yml +67 -0
  196. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_roles/should_add_a_Role_to_a_User_successfully.yml +62 -0
  197. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_User_successfully.yml +60 -0
  198. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_secondary_User_successfully.yml +60 -0
  199. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user_provider/should_attempt_to_delete_the_MFA_provider_for_the_User.yml +60 -0
  200. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_enrollments/should_get_Enrollments_for_a_User_successfully.yml +65 -0
  201. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_exactly_1_Permission_for_a_User_successfully.yml +65 -0
  202. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_the_correct_Permission_for_a_User_successfully.yml +65 -0
  203. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_roles/should_get_Roles_for_a_User_successfully.yml +65 -0
  204. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_invalidate_browsers/should_invalidate_MFA_browsers_for_the_User_successfully.yml +62 -0
  205. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_link_user_account/should_link_two_Users_successfully.yml +67 -0
  206. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_the_User_successfully.yml +68 -0
  207. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_permissions/should_remove_a_Permission_from_a_User_successfully.yml +62 -0
  208. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_roles/should_remove_a_Role_from_a_User_successfully.yml +62 -0
  209. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_unlink_user_account/should_unlink_two_Users_successfully.yml +65 -0
  210. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_fields_not_indicated.yml +65 -0
  211. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_the_fields_indicated.yml +65 -0
  212. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_include_the_fields_indicated.yml +65 -0
  213. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/should_retrieve_the_created_user.yml +65 -0
  214. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user_logs/should_get_Logs_for_a_User_successfully.yml +69 -0
  215. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v2_search_engine_query.yml +65 -0
  216. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/is_expected_to_find_a_user_with_a_v3_search_engine_query.yml +65 -0
  217. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_exclude_the_indicated_fields_when_paginated.yml +65 -0
  218. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_include_the_indicated_fields_when_paginated.yml +65 -0
  219. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_not_include_other_fields_when_paginated.yml +65 -0
  220. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_return_the_correct_number_of_results_when_paginated.yml +65 -0
  221. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/should_have_at_least_one_user.yml +65 -0
  222. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_secondary_test_user.yml +67 -0
  223. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_api.yml +67 -0
  224. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_role.yml +67 -0
  225. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_user.yml +67 -0
  226. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_api.yml +60 -0
  227. data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_role.yml +60 -0
  228. data/spec/integration/lib/auth0/api/api_authentication_spec.rb +96 -54
  229. data/spec/integration/lib/auth0/api/v2/api_anomaly_spec.rb +17 -0
  230. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +18 -5
  231. data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +46 -33
  232. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +115 -61
  233. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +117 -103
  234. data/spec/integration/lib/auth0/api/v2/api_device_credentials_spec.rb +101 -58
  235. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +72 -77
  236. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +113 -60
  237. data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +46 -38
  238. data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +110 -40
  239. data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +145 -0
  240. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +119 -62
  241. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +11 -14
  242. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +40 -34
  243. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +42 -28
  244. data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
  245. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +252 -120
  246. data/spec/integration/lib/auth0/auth0_client_spec.rb +32 -26
  247. data/spec/lib/auth0/api/v2/anomaly_spec.rb +26 -0
  248. data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
  249. data/spec/lib/auth0/api/v2/client_grants_spec.rb +34 -2
  250. data/spec/lib/auth0/api/v2/clients_spec.rb +50 -5
  251. data/spec/lib/auth0/api/v2/connections_spec.rb +49 -1
  252. data/spec/lib/auth0/api/v2/guardian_spec.rb +154 -0
  253. data/spec/lib/auth0/api/v2/jobs_spec.rb +109 -6
  254. data/spec/lib/auth0/api/v2/log_streams_spec.rb +84 -0
  255. data/spec/lib/auth0/api/v2/organizations_spec.rb +593 -0
  256. data/spec/lib/auth0/api/v2/prompts_spec.rb +88 -0
  257. data/spec/lib/auth0/api/v2/resource_servers_spec.rb +23 -0
  258. data/spec/lib/auth0/api/v2/roles_spec.rb +362 -0
  259. data/spec/lib/auth0/api/v2/rules_spec.rb +23 -1
  260. data/spec/lib/auth0/api/v2/tickets_spec.rb +95 -5
  261. data/spec/lib/auth0/api/v2/users_spec.rb +465 -61
  262. data/spec/lib/auth0/client_spec.rb +196 -18
  263. data/spec/lib/auth0/mixins/httpproxy_spec.rb +83 -4
  264. data/spec/lib/auth0/mixins/initializer_spec.rb +1 -0
  265. data/spec/lib/auth0/mixins/validation_spec.rb +498 -0
  266. data/spec/spec_helper.rb +54 -11
  267. data/spec/support/credentials.rb +6 -18
  268. data/spec/support/dummy_class.rb +7 -3
  269. data/spec/support/dummy_class_for_proxy.rb +1 -0
  270. data/spec/support/stub_response.rb +1 -1
  271. metadata +497 -53
  272. data/.travis.yml +0 -18
  273. data/build_travis.sh +0 -7
  274. data/deploy_documentation.sh +0 -29
  275. data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
  276. data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
  277. data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
  278. data/doc_config/templates/default/layout/html/footer.erb +0 -115
  279. data/doc_config/templates/default/layout/html/headers.erb +0 -17
  280. data/doc_config/templates/default/layout/html/layout.erb +0 -27
  281. data/lib/auth0/api/v1/clients.rb +0 -48
  282. data/lib/auth0/api/v1/connections.rb +0 -53
  283. data/lib/auth0/api/v1/logs.rb +0 -34
  284. data/lib/auth0/api/v1/rules.rb +0 -45
  285. data/lib/auth0/api/v1/users.rb +0 -164
  286. data/lib/auth0/api/v1.rb +0 -19
  287. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -348
  288. data/spec/spec_helper_full.rb +0 -45
  289. data/spec/spec_helper_unit.rb +0 -3
data/README.md CHANGED
@@ -1,76 +1,296 @@
1
- Ruby api client for [Auth0](https://auth0.com) platform
1
+ # Auth0 - Ruby
2
2
 
3
- [![Build Status](https://travis-ci.org/auth0/ruby-auth0.svg?branch=master)](https://travis-ci.org/auth0/ruby-auth0)
3
+ [![CircleCI](https://img.shields.io/circleci/project/github/auth0/ruby-auth0/master.svg)](https://circleci.com/gh/auth0/ruby-auth0)
4
4
  [![Gem Version](https://badge.fury.io/rb/auth0.svg)](http://badge.fury.io/rb/auth0)
5
- [![Coverage Status](https://coveralls.io/repos/auth0/ruby-auth0/badge.svg?branch=master)](https://coveralls.io/r/auth0/ruby-auth0?branch=master)
6
- [![Dependency Status](https://gemnasium.com/auth0/ruby-auth0.svg)](https://gemnasium.com/auth0/ruby-auth0)
5
+ [![codecov](https://codecov.io/gh/auth0/ruby-auth0/branch/master/graph/badge.svg)](https://codecov.io/gh/auth0/ruby-auth0)
7
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)
8
+ [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fauth0%2Fruby-auth0?ref=badge_shield)
9
+
10
+ Ruby API client for the [Auth0](https://auth0.com) platform.
8
11
 
9
12
  ## Installation
10
13
 
11
- ``` bash
14
+ This gem can be installed directly:
15
+
16
+ ```bash
12
17
  $ gem install auth0
13
18
  ```
14
19
 
15
- or with [Bundler](http://bundler.io)
20
+ ... or with [Bundler](https://bundler.io/man/bundle-add.1.html):
21
+
22
+ ```bash
23
+ bundle add auth0
24
+ ```
25
+
26
+ ## API Documentation
27
+
28
+ https://www.rubydoc.info/gems/auth0
29
+
30
+ ## Management API v2
31
+
32
+ This SDK provides access to the [Management API v2](https://auth0.com/docs/api/management/v2) via modules that help create clear and accurate calls. Most of the interaction is done through the `Auth0Client` class, instantiated with the required credentials.
33
+
34
+ As a simple example of how to get started, we'll create an admin route to point to a list of all users from Auth0:
35
+
36
+ ```ruby
37
+ # config/routes.rb
38
+ Rails.application.routes.draw do
39
+ # ...
40
+ get 'admin/users', to: 'all_users#index'
41
+ # ...
42
+ end
43
+ ```
44
+
45
+ ... and a Controller to handle that route:
46
+
47
+ ```ruby
48
+ # app/controllers/all_users_controllers.rb
49
+ require 'auth0'
50
+
51
+ class AllUsersController < ApplicationController
52
+ # Get all users from Auth0 with "auth0" in their email.
53
+ def index
54
+ @params = {
55
+ q: "email:*auth0*",
56
+ fields: 'email,user_id,name',
57
+ include_fields: true,
58
+ page: 0,
59
+ per_page: 50
60
+ }
61
+ @users = auth0_client.users @params
62
+ end
63
+
64
+ private
65
+
66
+ # Setup the Auth0 API connection.
67
+ def auth0_client
68
+ @auth0_client ||= Auth0Client.new(
69
+ client_id: ENV['AUTH0_RUBY_CLIENT_ID'],
70
+ client_secret: ENV['AUTH0_RUBY_CLIENT_SECRET'],
71
+ # If you pass in a client_secret value, the SDK will automatically try to get a
72
+ # Management API token for this application. Make sure your Application can make a
73
+ # Client Credentials grant (Application settings in Auth0 > Advanced > Grant Types
74
+ # tab) and that the Application is authorized for the Management API:
75
+ # https://auth0.com/docs/api-auth/config/using-the-auth0-dashboard
76
+ #
77
+ # Otherwise, you can pass in a Management API token directly for testing or temporary
78
+ # access using the key below.
79
+ # token: ENV['AUTH0_RUBY_API_TOKEN'],
80
+ domain: ENV['AUTH0_RUBY_DOMAIN'],
81
+ api_version: 2,
82
+ timeout: 15 # optional, defaults to 10
83
+ )
84
+ end
85
+ end
86
+ ```
87
+
88
+ In this example, we're using environment variables to store the values needed to connect to Auth0 and authorize. The `token` used above is an API token for the Management API with the scopes required to perform a specific action (in this case `read:users`). These tokens can be [generated manually](https://auth0.com/docs/api/management/v2/tokens#get-a-token-manually) using a test Application or with the [Application](https://manage.auth0.com/#/applications) being used for your project.
89
+
90
+ Finally, we'll add a view to display the results:
16
91
 
17
92
  ```ruby
18
- gem 'auth0'
93
+ # app/views/all_users/index.html.erb
94
+ <h1>Users</h1>
95
+ <%= debug @params %>
96
+ <%= debug @users %>
19
97
  ```
20
98
 
21
- ## Basic usage
99
+ This should show the parameters passed to the `users` method and a list of users that matched the query (or an empty array if none).
100
+
101
+ ## Authentication
102
+
103
+ 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:
104
+
105
+ - Register a new user with a database connection using the `signup` method.
106
+ - Redirect a user to the universal login page for authentication using the `authorization_url` method.
107
+ - 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.
108
+ - Exchange an authorization code for an access token on callback using the `obtain_user_tokens` method (see the note on state validation below).
109
+ - Send a change password email to a database connection user using the `change_password` method.
110
+ - Log a user out of Auth0 with the `logout_url` method.
111
+
112
+ **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).
113
+
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
+
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:
22
121
 
23
- Using [APIv2](https://auth0.com/docs/api/v2)
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:
24
133
 
25
134
  ```ruby
26
- require "auth0"
135
+ require 'auth0'
27
136
 
28
- auth0 = Auth0Client.new(
29
- :client_id => "YOUR CLIENT ID",
30
- :token => "YOUR JWT HERE",
31
- :domain => "<YOUR ACCOUNT>.auth0.com",
32
- :api_version => 2
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}"
33
142
  )
34
143
 
35
- puts auth0.get_users
144
+ universal_login_url = @auth0_client.authorization_url("https://{YOUR_APPLICATION_CALLBACK_URL}")
145
+
146
+ # redirect_to universal_login_url
36
147
  ```
37
148
 
38
- ### Timeout
39
- You can setup a custom timeout in the Auth0Client. By default it is set to 10 seconds.
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
40
152
 
41
153
  ```ruby
42
- require "auth0"
154
+ require 'auth0'
43
155
 
44
- auth0 = Auth0Client.new(
45
- :client_id => "YOUR CLIENT ID",
46
- :token => "YOUR JWT HERE",
47
- :domain => "<YOUR ACCOUNT>.auth0.com",
48
- :timeout => 15
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}"
49
161
  )
50
162
 
51
- puts auth0.get_users
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
52
169
  ```
53
170
 
54
- ## API Documentation
171
+ ## ID Token Validation
172
+
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).
55
174
 
56
- Build API docs locally
175
+ 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:
57
176
 
58
- ``` bash
59
- bundle exec rake documentation
177
+ ```ruby
178
+ begin
179
+ @auth0_client.validate_id_token 'YOUR_ID_TOKEN'
180
+ rescue Auth0::InvalidIdToken => e
181
+ # In this case the ID Token contents should not be trusted
182
+ end
60
183
  ```
61
184
 
62
- To view API docs, go to `doc` folder and open `index.html`
185
+ The method takes the following optional keyword parameters:
186
+
187
+ | Parameter | Type | Description | Default value |
188
+ | ------------- | -------------- | ------------- | ------------------------- |
189
+ | `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**) |
190
+ | `leeway` | Integer | Number of seconds to account for clock skew when validating the `exp`, `iat` and `azp` claims. | `60` |
191
+ | `nonce` | String | The `nonce` value you sent in the call to `/authorize`, if any. | `nil` |
192
+ | `max_age` | Integer | The `max_age` value you sent in the call to `/authorize`, if any. | `nil` |
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` |
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` |
196
+
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`.
198
+
199
+ ```ruby
200
+ # HS256
201
+
202
+ begin
203
+ @auth0_client.validate_id_token 'YOUR_ID_TOKEN', algorithm: Auth0::Algorithm::HS256.secret('YOUR_SECRET')
204
+ rescue Auth0::InvalidIdToken => e
205
+ # Handle error
206
+ end
207
+
208
+ # RS256 with a custom JWKS URL
209
+
210
+ begin
211
+ @auth0_client.validate_id_token 'YOUR_ID_TOKEN', algorithm: Auth0::Algorithm::RS256.jwks_url('YOUR_URL')
212
+ rescue Auth0::InvalidIdToken => e
213
+ # Handle error
214
+ end
215
+ ```
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
+
240
+ ## Development
241
+
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`.
243
+
244
+ > It is expected that every Pull Request introducing a fix, change or feature contains enough test coverage to assert the new behavior.
245
+
246
+ ### Running the tests
247
+
248
+ Install the gems required for this project.
249
+
250
+ ```bash
251
+ bundle install
252
+ ```
253
+
254
+ Finally, run the tests.
255
+
256
+ ```bash
257
+ bundle exec rake test
258
+ ```
259
+
260
+ #### Running only unit tests
261
+
262
+ You can run only the unit tests and ignore the integration tests by running the following:
263
+
264
+ ```bash
265
+ bundle exec rake spec
266
+ ```
267
+
268
+ #### Running only integration tests
269
+
270
+ You can run only the unit tests and ignore the integration tests by running the following:
271
+
272
+ ```bash
273
+ bundle exec rake integration
274
+ ```
275
+
276
+ ## More Information
277
+
278
+ - [Login using OmniAuth](https://auth0.com/docs/quickstart/webapp/rails/01-login)
279
+ - [API authentication in Ruby](https://auth0.com/docs/quickstart/backend/ruby)
280
+ - [API authentication in Rails](https://auth0.com/docs/quickstart/backend/rails)
281
+ - [Managing authentication with Auth0 (blog)](https://auth0.com/blog/rails-5-with-auth0/)
282
+ - [Ruby on Rails workflow with Docker (blog)](https://auth0.com/blog/ruby-on-rails-killer-workflow-with-docker-part-1/)
63
283
 
64
284
  ## What is Auth0?
65
285
 
66
286
  Auth0 helps you to:
67
287
 
68
- * Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, amont others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**.
69
- * Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**.
70
- * Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user.
71
- * Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely.
72
- * Analytics of how, when and where users are logging in.
73
- * Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules).
288
+ - 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**.
289
+ - Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**.
290
+ - Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user.
291
+ - Support for generating signed [JSON Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely.
292
+ - Analytics of how, when, and where users are logging in.
293
+ - Pull data from other sources and add it to the user profile with [JavaScript rules](https://docs.auth0.com/rules).
74
294
 
75
295
  ## Create a free Auth0 Account
76
296
 
@@ -79,7 +299,7 @@ Auth0 helps you to:
79
299
 
80
300
  ## Issue Reporting
81
301
 
82
- If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
302
+ If you find a bug or have a feature request, please report them in this repository's [Issues tab](https://github.com/auth0/ruby-auth0/issues). Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
83
303
 
84
304
  ## Author
85
305
 
@@ -88,3 +308,6 @@ If you have found a bug or if you have a feature request, please report them at
88
308
  ## License
89
309
 
90
310
  This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
311
+
312
+
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/Rakefile CHANGED
@@ -9,28 +9,6 @@ begin
9
9
  desc 'Run Rubocop'
10
10
  RuboCop::RakeTask.new(:rubocop)
11
11
 
12
- require 'yard'
13
- DOC_FILES = ['lib/auth0/api/v2/*.rb', 'lib/auth0/api/authentication_endpoints.rb'].freeze
14
-
15
- desc 'Build Documentation'
16
- YARD::Rake::YardocTask.new(:documentation) do |t|
17
- t.files = DOC_FILES
18
- t.options = ['-p', 'doc_config/templates']
19
- end
20
-
21
- desc 'Publish SDK documentation'
22
- task :publish do
23
- sh 'rake documentation'
24
- sh 'cp -R doc /tmp/ruby-auth0-doc'
25
- sh 'git checkout gh-pages'
26
- sh 'cp -R /tmp/ruby-auth0-doc/* .'
27
- sh 'rm -rf /tmp/ruby-auth0-doc'
28
- sh 'git add .'
29
- sh 'git commit -am "Rebuild documentation"'
30
- sh 'git push origin gh-pages'
31
- sh 'git checkout master'
32
- end
33
-
34
12
  desc 'Run Integration Tests'
35
13
  RSpec::Core::RakeTask.new(:integration) do |t|
36
14
  t.pattern = FileList["spec/integration/**/*#{ENV['PATTERN']}*_spec.rb"]
@@ -44,7 +22,10 @@ begin
44
22
  desc 'Run All Suites'
45
23
  RSpec::Core::RakeTask.new(:all)
46
24
 
47
- task default: [:rubocop, :spec]
25
+ desc 'Run unit and integration tests'
26
+ task test: [:spec, :integration]
27
+
28
+ task default: [:rubocop, :test]
48
29
  rescue LoadError
49
30
  puts 'Load Error - No RSpec'
50
31
  end
data/auth0.gemspec CHANGED
@@ -11,27 +11,28 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'Auth0 API Client'
12
12
  s.description = 'Ruby toolkit for Auth0 API https://auth0.com.'
13
13
 
14
- s.rubyforge_project = 'auth0'
15
-
16
14
  s.files = `git ls-files`.split("\n")
17
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
16
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
17
  s.require_paths = ['lib']
20
18
 
21
- s.add_runtime_dependency 'rest-client', '~> 2.0'
19
+ s.add_runtime_dependency 'rest-client', '~> 2.0.0'
20
+ s.add_runtime_dependency 'jwt', '~> 2.2.0'
21
+ s.add_runtime_dependency 'zache', '~> 0.12.0'
22
+ s.add_runtime_dependency 'addressable', '~> 2.8.0'
22
23
 
23
- s.add_development_dependency 'rake', '~> 10.4'
24
+ s.add_development_dependency 'bundler'
25
+ s.add_development_dependency 'rake', '~> 13.0'
24
26
  s.add_development_dependency 'fuubar', '~> 2.0'
25
- s.add_development_dependency 'guard-rspec', '~> 4.5' unless ENV['TRAVIS']
27
+ s.add_development_dependency 'guard-rspec', '~> 4.5' unless ENV['CIRCLECI']
26
28
  s.add_development_dependency 'dotenv-rails', '~> 2.0'
27
29
  s.add_development_dependency 'pry', '~> 0.10'
28
30
  s.add_development_dependency 'pry-nav', '~> 0.2.4'
29
- s.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
31
+ s.add_development_dependency 'rspec', '~> 3.5'
30
32
  s.add_development_dependency 'rack-test', '~> 0.6'
31
- s.add_development_dependency 'rack', '~> 1.6.4'
33
+ s.add_development_dependency 'rack', '~> 2.1.2'
32
34
  s.add_development_dependency 'simplecov', '~> 0.9'
33
- s.add_development_dependency 'faker', '~> 1.4'
34
- s.add_development_dependency 'yard', '~> 0.9.12'
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
data/codecov.yml ADDED
@@ -0,0 +1,22 @@
1
+ coverage:
2
+ precision: 2
3
+ round: down
4
+ range: "60...100"
5
+ status:
6
+ project:
7
+ default:
8
+ enabled: true
9
+ target: auto
10
+ threshold: 5%
11
+ if_no_uploads: error
12
+ patch:
13
+ default:
14
+ enabled: true
15
+ target: 80%
16
+ threshold: 30%
17
+ if_no_uploads: error
18
+ changes:
19
+ default:
20
+ enabled: true
21
+ if_no_uploads: error
22
+ comment: false
@@ -16,12 +16,6 @@
16
16
  .repl_history
17
17
  build/
18
18
 
19
- ## Documentation cache and generated files:
20
- /.yardoc/
21
- /_yardoc/
22
- /doc/
23
- /rdoc/
24
-
25
19
  ## Environment normalisation:
26
20
  /.bundle/
27
21
  /vendor/bundle
@@ -0,0 +1,5 @@
1
+ module Auth0
2
+ module Algorithm
3
+ include Auth0::Mixins::Validation::Algorithm
4
+ end
5
+ end