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
@@ -0,0 +1,335 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the organizations endpoints
5
+ module Organizations
6
+ include Auth0::Mixins::Validation
7
+
8
+ attr_reader :organizations_path
9
+
10
+ # Get all organizations.
11
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
12
+ # @param options [hash] The Hash options used to define the paging of rersults
13
+ # * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
14
+ # * :page [integer] The page number. Zero based.
15
+ # * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
16
+ # @return [json] All Organizations
17
+ def organizations(options = {})
18
+ request_params = {
19
+ per_page: options.fetch(:per_page, nil),
20
+ page: options.fetch(:page, nil),
21
+ include_totals: options.fetch(:include_totals, nil)
22
+ }
23
+ get(organizations_path, request_params)
24
+ end
25
+ alias get_organizations organizations
26
+
27
+ # Create a new organization.
28
+ # @see ttps://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations
29
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations for available options
30
+ # @return [json] Returns the created organization.
31
+ def create_organization(options = {})
32
+ post(organizations_path, options)
33
+ end
34
+
35
+ # Get an organization by id. A token with read:organizations scope is required
36
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations_by_id
37
+ # @param organization_id [string] The organization_id of the user to retrieve.
38
+ #
39
+ # @return [json] Returns the organization with the given organization_id if it exists.
40
+ def organization(organization_id)
41
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
42
+ path = "#{organizations_path}/#{organization_id}"
43
+ get(path)
44
+ end
45
+
46
+ # Get an organization by name. A token with read:organizations scope is required.
47
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_name_by_name
48
+ # @param organization_name [string] The Organization name
49
+ #
50
+ # @return [json] Returns the organization with the given organization_name if it exists.
51
+ def organization_by_name(organization_name)
52
+ raise Auth0::InvalidParameter, 'Must supply a valid organization_name' if organization_name.to_s.empty?
53
+ path = "#{organizations_path}/name/#{organization_name}"
54
+ get(path)
55
+ end
56
+
57
+
58
+ # Deletes a single organization given its id
59
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organizations_by_id
60
+ # @param organization_id [string] The Organization ID
61
+ def delete_organization(organization_id)
62
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
63
+ path = "#{organizations_path}/#{organization_id}"
64
+ delete(path)
65
+ end
66
+
67
+ # Update an existing organization.
68
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id
69
+ # @param organization_id [string] The Organization ID
70
+ # @param body [hash] The optional parameters to update.
71
+ #
72
+ # @return [json] Returns the updated user.
73
+ def patch_organization(organization_id, body)
74
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
75
+ raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
76
+ path = "#{organizations_path}/#{organization_id}"
77
+ patch(path, body)
78
+ end
79
+ alias update_organization patch_organization
80
+
81
+ ### Organization Enabled Connections
82
+
83
+ # Get enabled connections in an Organization
84
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
85
+ # @param organization_id [string] The Organization ID
86
+ #
87
+ # @return [json] Returns the enabled connections for the given organization
88
+ def get_organizations_enabled_connections(organization_id)
89
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
90
+ path = "#{organizations_enabled_connections_path(organization_id)}"
91
+ get(path)
92
+ end
93
+
94
+ # Get enabled connection by id in an Organization
95
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections_by_connectionId
96
+ # @param organization_id [string] The Organization ID
97
+ # @param connection_id [string] The Connection id
98
+ #
99
+ # @return [json] Returns the connection for the given organization
100
+ def get_organizations_enabled_connection(organization_id, connection_id)
101
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
102
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
103
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
104
+ get(path)
105
+ end
106
+
107
+ # Update an eanbled connection in an Organization
108
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_enabled_connections_by_connectionId
109
+ # @param organization_id [string] The Organization ID
110
+ # @param connection_id [string] The Connection id
111
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
112
+ #
113
+ # @return [json] Returns the connection for the given organization
114
+ def patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil)
115
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
116
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
117
+ raise Auth0::InvalidParameter, 'Must supply a valid assign_membership_on_login value' if assign_membership_on_login.nil?
118
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
119
+
120
+ body = {}
121
+ body[:assign_membership_on_login] = assign_membership_on_login
122
+
123
+ patch(path, body)
124
+ end
125
+ alias update_organizations_enabled_connection patch_organizations_enabled_connection
126
+
127
+ # Add an enabled connection for an Organization
128
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_enabled_connections
129
+ # @param organization_id [string] The Organization ID
130
+ # @param connection_id [string] The Organization ID
131
+ # @param assign_membership_on_login [boolean] flag to allow assign membership on login
132
+ #
133
+ # @return [json] Returns the connection for the given organization
134
+ def create_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: false)
135
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
136
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
137
+ path = "#{organizations_enabled_connections_path(organization_id)}"
138
+
139
+ body = {}
140
+ body[:assign_membership_on_login] = assign_membership_on_login
141
+ body[:connection_id] = connection_id
142
+
143
+ post(path, body)
144
+ end
145
+ alias add_organizations_enabled_connection create_organizations_enabled_connection
146
+
147
+ # Remove an enabled connection from an Organization
148
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_enabled_connections_by_connectionId
149
+ # @param organization_id [string] The Organization ID
150
+ # @param connection_id [string] The Connection id
151
+ def delete_organizations_enabled_connection(organization_id, connection_id)
152
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
153
+ raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
154
+ path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
155
+ delete(path)
156
+ end
157
+ alias remove_organizations_enabled_connection delete_organizations_enabled_connection
158
+
159
+ ### Organization Invites
160
+
161
+ # Get invites in an Organization
162
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations
163
+ # @param organization_id [string] The Organization ID
164
+ #
165
+ # @return [json] Returns the invites for the given organization
166
+ def get_organizations_invites(organization_id)
167
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
168
+ path = "#{organizations_invitations_path(organization_id)}"
169
+ get(path)
170
+ end
171
+
172
+ # Get invite by id in an Organization
173
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations_by_invitation_id
174
+ # @param organization_id [string] The Organization ID
175
+ # @param invitation_id [string] The invitation id
176
+ #
177
+ # @return [json] Returns the invitation for the given organization
178
+ def get_organizations_invite(organization_id, invitation_id)
179
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
180
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
181
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
182
+ get(path)
183
+ end
184
+
185
+ # Create an invitation in an organization
186
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
187
+ # @param organization_id [string] The Organization ID
188
+ # @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
189
+ # @return [json] Returns the invitation for the given organization
190
+ def create_organizations_invite(organization_id, options = {})
191
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
192
+ path = "#{organizations_invitations_path(organization_id)}"
193
+
194
+ post(path, options)
195
+ end
196
+ alias add_organizations_invite create_organizations_invite
197
+
198
+ # Delete an invitation to organization
199
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_invitations_by_invitation_id
200
+ # @param organization_id [string] The Organization ID
201
+ # @param invitation_id [string] The Invitation id
202
+ def delete_organizations_invite(organization_id, invitation_id)
203
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
204
+ raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
205
+ path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
206
+ delete(path)
207
+ end
208
+ alias remove_organizations_invite delete_organizations_invite
209
+
210
+ ### Organization Member
211
+
212
+ # Get Members in a Organization
213
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
214
+ # @param organization_id [string] The Organization ID
215
+ # @param user_id [string] The User ID
216
+ #
217
+ # @return [json] Returns the members for the given organization
218
+ def get_organizations_members(organization_id)
219
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
220
+ path = "#{organizations_members_path(organization_id)}"
221
+ get(path)
222
+ end
223
+
224
+ # Add members in an organization
225
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_members
226
+ # @param organization_id [string] The Organization ID
227
+ # @param members [array] Array of user IDs.
228
+ #
229
+ # @return [json] Returns the invitation for the given organization
230
+ def create_organizations_members(organization_id, members = [])
231
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
232
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
233
+ path = "#{organizations_members_path(organization_id)}"
234
+
235
+ body = {}
236
+ body[:members] = members
237
+
238
+ post(path, body)
239
+ end
240
+ alias add_organizations_members create_organizations_members
241
+
242
+ # Remove members from an organization
243
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_members
244
+ # @param organization_id [string] The Organization ID
245
+ # @param members [array] Array of user IDs.
246
+ def delete_organizations_members(organization_id, members = [])
247
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
248
+ raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
249
+ path = "#{organizations_members_path(organization_id)}"
250
+
251
+ body = {}
252
+ body[:members] = members
253
+
254
+ delete(path, body)
255
+ end
256
+ alias remove_organizations_members delete_organizations_members
257
+
258
+ ### Organization Member Roles
259
+
260
+ # Get Roles assigned to a Member in an Organization
261
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organization_member_roles
262
+ # @param organization_id [string] The Organization ID
263
+ # @param user_id [string] The User ID
264
+ #
265
+ # @return [json] Returns the member_roles for the given organization
266
+ def get_organizations_member_roles(organization_id, user_id)
267
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
268
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
269
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
270
+ get(path)
271
+ end
272
+
273
+ # Assign roles to a member in an organization
274
+ # @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_organization_member_roles
275
+ # @param organization_id [string] The Organization ID
276
+ # @param user_id [string] The User ID
277
+ # @param roles [array] Array of role IDs.
278
+ #
279
+ # @return [json] Returns the invitation for the given organization
280
+ def create_organizations_member_roles(organization_id, user_id, roles = [])
281
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
282
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
283
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
284
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
285
+
286
+ body = {}
287
+ body[:roles] = roles
288
+
289
+ post(path, body)
290
+ end
291
+ alias add_organizations_member_roles create_organizations_member_roles
292
+
293
+ # Remove roles from a Member of an organization
294
+ # @https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles
295
+ # @param organization_id [string] The Organization ID
296
+ # @param user_id [string] The User ID
297
+ # @param roles [array] Array of role IDs.
298
+ def delete_organizations_member_roles(organization_id, user_id, roles = [])
299
+ raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
300
+ raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
301
+ raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
302
+ path = "#{organizations_member_roles_path(organization_id, user_id)}"
303
+
304
+ body = {}
305
+ body[:roles] = roles
306
+
307
+ delete(path, body)
308
+ end
309
+ alias remove_organizations_member_roles delete_organizations_member_roles
310
+
311
+ private
312
+ # Organizations API path
313
+ def organizations_path
314
+ @organizations_path ||= '/api/v2/organizations'
315
+ end
316
+
317
+ def organizations_enabled_connections_path(org_id)
318
+ "#{organizations_path}/#{org_id}/enabled_connections"
319
+ end
320
+
321
+ def organizations_members_path(org_id)
322
+ "#{organizations_path}/#{org_id}/members"
323
+ end
324
+
325
+ def organizations_member_roles_path(org_id, user_id)
326
+ "#{organizations_path}/#{org_id}/members/#{user_id}/roles"
327
+ end
328
+
329
+ def organizations_invitations_path(org_id)
330
+ "#{organizations_path}/#{org_id}/invitations"
331
+ end
332
+ end
333
+ end
334
+ end
335
+ end
@@ -0,0 +1,70 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ module Prompts
5
+ attr_reader :prompts_path
6
+
7
+ # Get prompts settings.
8
+ # @see https://auth0.com/docs/api/management/v2#!/Prompts/get_prompts
9
+ # @return [json] Returns the prompts setting.
10
+ def prompts
11
+ get(prompts_path)
12
+ end
13
+ alias get_prompts prompts
14
+
15
+ # Update prompts settings.
16
+ # @see https://auth0.com/docs/api/management/v2#!/Prompts/patch_prompts
17
+ # @param options [hash]
18
+ # * :universal_login_experience [string] Should be any of: new, classic.
19
+ #
20
+ # @return [json] Returns the prompts settings.
21
+ def patch_prompts(options = {})
22
+ request_params = {
23
+ universal_login_experience: options.fetch(:universal_login_experience, nil)
24
+ }
25
+ patch(prompts_path, request_params)
26
+ end
27
+ alias update_prompts patch_prompts
28
+
29
+ # Get custom text for a prompt
30
+ # Retrieve custom text for a specific prompt and language.
31
+ # @see https://auth0.com/docs/api/management/v2#!/Prompts/get_custom_text_by_language
32
+ # @param prompt [string] Prompt of custom texts to update.
33
+ # @param language [string] Language of custom texts to update.
34
+ #
35
+ # @return [json] Returns the custom texts.
36
+ def custom_text(prompt, language)
37
+ raise Auth0::InvalidParameter, 'Must supply a valid prompt' if prompt.to_s.empty?
38
+ raise Auth0::InvalidParameter, 'Must supply a valid language' if language.to_s.empty?
39
+
40
+ path = "#{prompts_path}/#{prompt}/custom-text/#{language}"
41
+ get(path)
42
+ end
43
+ alias get_custom_text custom_text
44
+
45
+ # Set custom text for a specific prompt
46
+ # Existing texts will be overwritten.
47
+ # @see https://auth0.com/docs/api/management/v2#!/Prompts/put_custom_text_by_language
48
+ # @param prompt [string] Prompt of custom texts to update.
49
+ # @param language [string] Language of custom texts to update.
50
+ # @param body [hash] Custom texts.
51
+ #
52
+ # @return [json] Returns the custom texts.
53
+ def put_custom_text(prompt, language, body)
54
+ raise Auth0::InvalidParameter, 'Must supply a valid prompt' if prompt.to_s.empty?
55
+ raise Auth0::InvalidParameter, 'Must supply a valid language' if language.to_s.empty?
56
+
57
+ path = "#{prompts_path}/#{prompt}/custom-text/#{language}"
58
+ put(path, body)
59
+ end
60
+ alias update_custom_text put_custom_text
61
+
62
+ private
63
+
64
+ def prompts_path
65
+ @prompts_path ||= '/api/v2/prompts'
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -5,6 +5,20 @@ module Auth0
5
5
  module ResourceServers
6
6
  attr_reader :resource_servers_path
7
7
 
8
+ # Retrieves a list of all resource servers.
9
+ # @see https://auth0.com/docs/api/management/v2#!/Resource_servers/get_resource_servers
10
+ # @param page [int] Page number to get, 0-based.
11
+ # @param per_page [int] Results per page if also passing a page number.
12
+ # @return [json] Returns the resource servers.
13
+ def resource_servers(page: nil, per_page: nil)
14
+ request_params = {
15
+ page: !page.nil? ? page.to_i : nil,
16
+ per_page: !page.nil? && !per_page.nil? ? per_page.to_i : nil
17
+ }
18
+ get(resource_servers_path, request_params)
19
+ end
20
+ alias get_resource_servers resource_servers
21
+
8
22
  # Retrieves a resource server by its ID.
9
23
  # @see https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers_by_id
10
24
  # @param resource_server_id [string] The id of the resource server to retrieve.
@@ -21,18 +35,17 @@ module Auth0
21
35
  # Creates a new resource server according to the JSON object received in body.
22
36
  # @see https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers
23
37
  # @param identifier [string] The identifier of the resource server.
24
- # @param name [string] The name of the resource server. Must contain at least one character.
25
- # Does not allow '<' or '>'.
26
- # @param signing_alg [string] The algorithm used to sign tokens.
27
- # @param signing_secret [string] The secret used to sign tokens when using symmetric algorithms.
28
- # @param token_lifetime [integer] The amount of time (in seconds) that the token will be valid
29
- # after being issued.
30
- # @param scopes [array] The scope of the resource server.
38
+ # @param options [hash]
39
+ # * :name [string] The name of the resource server. Must contain at least one character. Does not allow '<' or '>'.
40
+ # * :signing_alg [string] The algorithm used to sign tokens.
41
+ # * :signing_secret [string] The secret used to sign tokens when using symmetric algorithms.
42
+ # * :token_lifetime [integer] The amount of time (in seconds) that the token will be valid after being issued.
43
+ # * :scopes [array] The scope of the resource server.
31
44
  #
32
45
  # @return [json] Returns the resource server.
33
46
  def create_resource_server(identifier, options = {})
34
47
  raise Auth0::InvalidParameter, 'Must supply a valid resource server id' if identifier.to_s.empty?
35
- if ['<', '>'].include?(options.fetch(:name, ''))
48
+ if options.fetch(:name, '').index(/[<>]/)
36
49
  raise Auth0::InvalidParameter, 'Name must contain at least one character. Does not allow "<" or ">"'
37
50
  end
38
51
  request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
@@ -49,6 +62,17 @@ module Auth0
49
62
  delete(path)
50
63
  end
51
64
 
65
+ # Updates a resource server.
66
+ # @see https://auth0.com/docs/api/management/v2#!/Resource_Servers/patch_resource_servers_by_id
67
+ # @param id [string] The id or audience of the resource server to update.
68
+ # @param body [hash] The Hash options used to define the resource servers's properties.
69
+ def patch_resource_server(id, body)
70
+ raise Auth0::InvalidParameter, 'Must specify a resource server id or audience' if id.to_s.empty?
71
+ raise Auth0::InvalidParameter, 'Must specify a valid body' if body.to_s.empty?
72
+ path = "#{resource_servers_path}/#{id}"
73
+ patch(path, body)
74
+ end
75
+
52
76
  private
53
77
 
54
78
  # Resource Servers API path
@@ -0,0 +1,172 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the Roles endpoints
5
+ module Roles
6
+ include Auth0::Mixins::Validation
7
+
8
+ # Get all Roles
9
+ # Required scope: "read:roles"
10
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/get_roles
11
+ #
12
+ # @param options [hash] A hash of options for getting Roles
13
+ # - per_page: Number of Roles to return.
14
+ # - page: Page number to return, zero-based.
15
+ # - include_totals: True to include query summary in the result, false or nil otherwise.
16
+ # - name_filter: Optional filter on name (case-insensitive).
17
+ #
18
+ # @return [json] All Roles matching the query.
19
+ def get_roles(options = {})
20
+ request_params = {
21
+ per_page: options.fetch(:per_page, nil),
22
+ page: options.fetch(:page, nil),
23
+ include_totals: options.fetch(:include_totals, nil),
24
+ name_filter: options.fetch(:name_filter, nil)
25
+ }
26
+ get roles_path, request_params
27
+ end
28
+ alias roles get_roles
29
+
30
+ # Get a single Role by ID.
31
+ # Required scope: "read:roles"
32
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/get_roles_by_id
33
+ #
34
+ # @param role_id [string] Role ID to get.
35
+ #
36
+ # @return [json] Role data.
37
+ def get_role(role_id)
38
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
39
+
40
+ get "#{roles_path}/#{role_id}"
41
+ end
42
+ alias role get_role
43
+
44
+ # Create a new Role.
45
+ # Required scope: "create:roles"
46
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/post_roles
47
+ #
48
+ # @param role_name [string] Role name for the new Role.
49
+ # @param data [hash] Additional Role data.
50
+ def create_role(role_name, data = {})
51
+ raise Auth0::MissingParameter, 'Must supply a valid role_name' if role_name.to_s.empty?
52
+
53
+ data[:name] = role_name
54
+ post roles_path.to_s, data
55
+ end
56
+
57
+ # Update a Role by ID.
58
+ # Required scope: "update:roles"
59
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/patch_roles_by_id
60
+ #
61
+ # @param role_id [string] Role ID to update.
62
+ # @param data [string] Role data to update.
63
+ def update_role(role_id, data = {})
64
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
65
+
66
+ patch "#{roles_path}/#{role_id}", data
67
+ end
68
+
69
+ # Delete a single Role by ID.
70
+ # Required scope: "delete:roles"
71
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/delete_roles_by_id
72
+ #
73
+ # @param role_id [string] Role ID to delete.
74
+ def delete_role(role_id)
75
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
76
+
77
+ delete "#{roles_path}/#{role_id}"
78
+ end
79
+
80
+ # Get Users assigned to a specific Role.
81
+ # Required scopes:
82
+ # - "read:roles"
83
+ # - "read:users"
84
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/get_role_user
85
+ #
86
+ # @param role_id [string] Role ID to which the Users belong to.
87
+ # @param options [hash] A hash of options for getting Roles
88
+ # - per_page: Number of Roles to return.
89
+ # - page: Page number to return, zero-based.
90
+ # - include_totals: True to include query summary in the result, false or nil otherwise.
91
+ def get_role_users(role_id, options = {})
92
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
93
+
94
+ request_params = {
95
+ per_page: options.fetch(:per_page, nil),
96
+ page: options.fetch(:page, nil),
97
+ include_totals: options.fetch(:include_totals, nil)
98
+ }
99
+ get "#{roles_path}/#{role_id}/users", request_params
100
+ end
101
+
102
+ # Add one or more Users to a Role.
103
+ # Required scopes: "update:roles"
104
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/post_role_users
105
+ #
106
+ # @param role_id [string] Role ID to add Users.
107
+ # @param users [array] Array of string User IDs to add to the Role.
108
+ def add_role_users(role_id, users = [])
109
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
110
+
111
+ validate_strings_array(users)
112
+ post "#{roles_path}/#{role_id}/users", users: users
113
+ end
114
+
115
+ # Get the permissions associated to a Role.
116
+ # Required scope: "read:roles"
117
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/get_role_permission
118
+ #
119
+ # @param role_id [string] Role ID to add permissions.
120
+ # @param options [hash] A hash of options for getting permissions
121
+ # - per_page: Number or permissions to return.
122
+ # - page: Page number to return, zero-based
123
+ # - include_totals: True to include query summary in the result, false or nil otherwise.
124
+ #
125
+ # @return [json] All permissions matching the query.
126
+ def get_role_permissions(role_id, options = {})
127
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
128
+
129
+ request_params = {
130
+ per_page: options.fetch(:per_page, nil),
131
+ page: options.fetch(:page, nil),
132
+ include_totals: options.fetch(:include_totals, nil)
133
+ }
134
+ get "#{roles_path}/#{role_id}/permissions", request_params
135
+ end
136
+
137
+ # Associate permissions with a Role.
138
+ # Required scope: "update:roles"
139
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/post_role_permission_assignment
140
+ #
141
+ # @param role_id [string] Role ID to add permissions.
142
+ # @param permissions [array] Array of Permission structs to add.
143
+ def add_role_permissions(role_id, permissions)
144
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
145
+
146
+ permissions = validate_permissions_array(permissions)
147
+ post "#{roles_path}/#{role_id}/permissions", permissions: permissions
148
+ end
149
+
150
+ # Remove permissions from a Role.
151
+ # Required scope: "update:roles"
152
+ # @see https://auth0.com/docs/api/management/v2#!/Roles/delete_role_permission_assignment
153
+ #
154
+ # @param role_id [string] Role ID to remove permissions.
155
+ # @param permissions [array] Array of Permission structs to remove.
156
+ def remove_role_permissions(role_id, permissions)
157
+ raise Auth0::MissingParameter, 'Must supply a valid role_id' if role_id.to_s.empty?
158
+
159
+ permissions = validate_permissions_array(permissions)
160
+ delete_with_body("#{roles_path}/#{role_id}/permissions", permissions: permissions)
161
+ end
162
+
163
+ private
164
+
165
+ # Roles base API path
166
+ def roles_path
167
+ @roles_path ||= '/api/v2/roles'
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
@@ -14,14 +14,18 @@ module Auth0
14
14
  # @param fields [string] A comma separated list of fields to include or exclude from the result.
15
15
  # @param include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
16
16
  # @param stage [string] Retrieves rules that match the execution stage (defaults to login_success).
17
+ # @param page [int] Page number to get, 0-based.
18
+ # @param per_page [int] Results per page if also passing a page number.
17
19
  #
18
20
  # @return [json] Returns the existing rules.
19
- def rules(enabled: nil, fields: nil, include_fields: nil, stage: nil)
21
+ def rules(enabled: nil, fields: nil, include_fields: nil, stage: nil, page: nil, per_page: nil)
20
22
  request_params = {
21
23
  enabled: enabled,
22
24
  fields: fields,
23
25
  include_fields: include_fields,
24
- stage: stage
26
+ stage: stage,
27
+ page: page,
28
+ per_page: per_page
25
29
  }
26
30
  get(rules_path, request_params)
27
31
  end