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.
- checksums.yaml +4 -4
- data/.bundle/config +3 -2
- data/.circleci/config.yml +44 -0
- data/.env.example +2 -0
- data/.github/CODEOWNERS +1 -0
- data/.github/ISSUE_TEMPLATE/config.yml +8 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
- data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +35 -0
- data/.github/stale.yml +20 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +2 -0
- data/.yardoc/checksums +22 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/CHANGELOG.md +334 -19
- data/CODE_OF_CONDUCT.md +3 -0
- data/DEPLOYMENT.md +56 -9
- data/Gemfile +10 -3
- data/README.md +260 -37
- data/Rakefile +4 -23
- data/auth0.gemspec +10 -9
- data/codecov.yml +22 -0
- data/examples/ruby-api/.gitignore +0 -6
- data/lib/auth0/algorithm.rb +5 -0
- data/lib/auth0/api/authentication_endpoints.rb +244 -237
- data/lib/auth0/api/v2/anomaly.rb +36 -0
- data/lib/auth0/api/v2/branding.rb +66 -0
- data/lib/auth0/api/v2/client_grants.rb +14 -5
- data/lib/auth0/api/v2/clients.rb +9 -6
- data/lib/auth0/api/v2/connections.rb +19 -7
- data/lib/auth0/api/v2/device_credentials.rb +5 -4
- data/lib/auth0/api/v2/guardian.rb +142 -0
- data/lib/auth0/api/v2/jobs.rb +77 -13
- data/lib/auth0/api/v2/log_streams.rb +78 -0
- data/lib/auth0/api/v2/logs.rb +11 -11
- data/lib/auth0/api/v2/organizations.rb +335 -0
- data/lib/auth0/api/v2/prompts.rb +70 -0
- data/lib/auth0/api/v2/resource_servers.rb +32 -8
- data/lib/auth0/api/v2/roles.rb +172 -0
- data/lib/auth0/api/v2/rules.rb +6 -2
- data/lib/auth0/api/v2/tickets.rb +55 -8
- data/lib/auth0/api/v2/users.rb +168 -28
- data/lib/auth0/api/v2/users_by_email.rb +3 -2
- data/lib/auth0/api/v2.rb +16 -2
- data/lib/auth0/client.rb +1 -1
- data/lib/auth0/exception.rb +34 -9
- data/lib/auth0/mixins/access_token_struct.rb +20 -0
- data/lib/auth0/mixins/api_token_struct.rb +10 -0
- data/lib/auth0/mixins/headers.rb +35 -0
- data/lib/auth0/mixins/httpproxy.rb +37 -14
- data/lib/auth0/mixins/initializer.rb +10 -26
- data/lib/auth0/mixins/permission_struct.rb +3 -0
- data/lib/auth0/mixins/validation.rb +346 -0
- data/lib/auth0/mixins.rb +9 -1
- data/lib/auth0/version.rb +1 -1
- data/lib/auth0.rb +1 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_change_password/should_trigger_a_password_reset.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_email.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_incorrect_password.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_fail_with_an_invalid_audience.yml +55 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_custom_audience.yml +117 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_login_with_resource_owner/should_login_successfully_with_a_default_scope.yml +119 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_saml_metadata/should_retrieve_SAML_metadata.yml +57 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_fail_as_not_authorized.yml +55 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_userinfo/should_return_the_userinfo.yml +118 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/_wsfed_metadata/should_retrieve_WSFED_metadata.yml +55 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/create_test_user.yml +58 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_AuthenticationEndpoints/delete_test_user.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_check_if_ip_is_blocked/should_return_200_response_code.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Anomaly/_remove_ip_block/should_remove_an_IP_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_add_token_to_blacklist/should_add_a_token_to_the_blacklist.yml +56 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Blacklists/_blacklisted_tokens/should_get_the_added_token_from_the_blacklist.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_at_least_1_result.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_first_page_of_one_result.yml +66 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_client_grants/should_return_the_test_client_grant.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_delete_client_grant/should_delete_the_test_client_grant.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/_patch_client_grant/should_update_the_test_client_grant.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client.yml +118 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/create_test_client_grant.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ClientGrants/delete_test_client_grant.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_exclude_and_include_fields_properly.yml +91 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/_filters/should_include_the_specified_fields.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_client/should_get_the_test_client.yml +92 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_fields_not_specified.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_exclude_the_specified_fields.yml +132 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_include_the_specified_fields.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/_filters/should_paginate_results.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_clients/should_get_at_least_one_client.yml +132 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_delete_client/should_delete_the_test_client_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/_patch_client/should_update_the_client_with_the_correct_attributes.yml +94 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Clients/create_test_client.yml +118 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_exclude_the_fields_indicated.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/_filters/should_include_the_fields_indicated.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connection/should_find_the_correct_connection.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_include_previously-created_connection_when_filtered.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_exclude_the_fields_indicated_from_filtered_results.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/_filters/should_should_include_the_fields_indicated_from_filtered_results.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_include_the_previously_created_connection.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_connections/should_not_be_empty.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection/should_delete_the_connection.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_delete_connection_user/should_delete_the_user_created.yml +110 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/_update_connection/should_update_the_connection.yml +66 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_connection.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Connections/create_test_user.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_delete_device_credential/should_delete_the_test_credential_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/_filter_by_type/should_exclude_the_test_credential.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_have_at_least_1_entry.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/_device_credentials/should_include_the_test_credential.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_credential.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/create_test_user.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_credential.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_DeviceCredentials/delete_test_user.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_configure_provider/should_configure_a_new_email_provider.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_delete_the_existing_email_provider_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_delete_provider/should_throw_an_error_trying_to_get_the_email_provider.yml +51 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_with_specific_fields.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/_filters/should_get_the_existing_email_provider_without_specific_fields.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_get_provider/should_get_the_existing_email_provider.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/_update_provider/should_update_the_existing_email_provider.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Emails/delete_existing_provider.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_create_an_export_users_job_successfully.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_export_users_and_get_job/should_get_the_export_users_job.yml +117 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_create_an_import_users_job_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_import_users_and_get_job/should_get_the_import_users_job.yml +116 -0
- 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
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_get_the_completed_verification_email.yml +175 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/_send_verification_email_and_get_job/should_reject_an_invalid_client_id.yml +109 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/delete_imported_user.yml +110 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Jobs/search_for_connection_id.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_match_the_created_log_entry.yml +265 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_log/should_not_be_empty.yml +265 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_fields_not_specified.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_exclude_the_specified_fields.yml +75 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_have_one_log_entry.yml +76 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_filters/should_include_the_specified_fields.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/_logs/_from/should_take_one_log_entry.yml +258 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/create_test_user.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_disabled_rule.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_enabled_rule.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Logs/delete_test_user.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_delete_resource_server/should_delete_the_test_server_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_patch_resource_server/should_update_the_resource_server_with_the_correct_attributes.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_server/should_get_the_test_server.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_get_the_test_server.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_at_least_1_result.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/_resource_servers/should_return_the_first_page_of_one_result.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/create_test_server.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_ResourceServers/delete_test_server.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_permissions/should_add_a_Permission_to_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_add_role_users/should_add_a_User_to_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_delete_role/should_delete_the_Role_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role/should_get_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_exactly_1_Permission.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_permissions/should_get_the_added_Permission_from_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_exactly_1_User.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_role_users/should_get_the_added_User_from_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_get_roles/should_get_the_Role_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_remove_role_permissions/should_remove_a_Permission_from_the_Role_successfully.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/_update_role/should_update_the_Role_successfully.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_api.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_role.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/create_test_user.yml +69 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_api.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Roles/delete_test_user.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_disabled_rule_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_delete_rule/should_delete_the_test_enabled_rule_without_an_error.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_fields_not_specified.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_exclude_the_specified_fields.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/_filters/should_include_the_specified_fields.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rule/should_get_a_specific_rule.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_exclude_fields_not_specified.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_include_the_specified_fields.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_disabled_rule.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_at_least_1_enabled_rule.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/_filters/should_return_paginated_results.yml +128 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_rules/should_return_at_least_1_rule.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/_update_rule/should_update_the_disabled_rule_to_be_enabled.yml +64 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_disabled_rule.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Rules/create_test_enabled_rule.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_active_users/should_have_at_least_one_active_user.yml +59 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Stats/_daily_stats/should_have_at_least_one_stats_entry_for_the_timeframe.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings/should_get_the_tenant_settings.yml +95 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_exclude_a_field_not_requested.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_get_tenant_settings_with_specific_fields/should_include_the_field_requested.yml +61 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tenants/_update_tenant_settings/should_revert_the_tenant_name.yml +96 -0
- 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
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_email_verification/should_create_an_email_verification_ticket.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/_post_password_change/should_create_a_password_change_ticket.yml +63 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/create_test_user.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Tickets/delete_test_user.yml +54 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_permissions/should_add_a_Permissions_for_a_User_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_add_user_roles/should_add_a_Role_to_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_User_successfully.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_delete_user/should_delete_the_secondary_User_successfully.yml +60 -0
- 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
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_enrollments/should_get_Enrollments_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_exactly_1_Permission_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_permissions/should_get_the_correct_Permission_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_get_user_roles/should_get_Roles_for_a_User_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_invalidate_browsers/should_invalidate_MFA_browsers_for_the_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_link_user_account/should_link_two_Users_successfully.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_patch_user/should_patch_the_User_successfully.yml +68 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_permissions/should_remove_a_Permission_from_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_remove_user_roles/should_remove_a_Role_from_a_User_successfully.yml +62 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_unlink_user_account/should_unlink_two_Users_successfully.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_fields_not_indicated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_exclude_the_fields_indicated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/_filters/should_include_the_fields_indicated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user/should_retrieve_the_created_user.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_user_logs/should_get_Logs_for_a_User_successfully.yml +69 -0
- 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
- 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
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_exclude_the_indicated_fields_when_paginated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_include_the_indicated_fields_when_paginated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_not_include_other_fields_when_paginated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/_filters/should_return_the_correct_number_of_results_when_paginated.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/_users/should_have_at_least_one_user.yml +65 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_secondary_test_user.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_api.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_role.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/create_test_user.yml +67 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_api.yml +60 -0
- data/spec/fixtures/vcr_cassettes/Auth0_Api_V2_Users/delete_test_role.yml +60 -0
- data/spec/integration/lib/auth0/api/api_authentication_spec.rb +96 -54
- data/spec/integration/lib/auth0/api/v2/api_anomaly_spec.rb +17 -0
- data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +18 -5
- data/spec/integration/lib/auth0/api/v2/api_client_grants_spec.rb +46 -33
- data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +115 -61
- data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +117 -103
- data/spec/integration/lib/auth0/api/v2/api_device_credentials_spec.rb +101 -58
- data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +72 -77
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +113 -60
- data/spec/integration/lib/auth0/api/v2/api_logs_spec.rb +46 -38
- data/spec/integration/lib/auth0/api/v2/api_resource_servers_spec.rb +110 -40
- data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +145 -0
- data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +119 -62
- data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +11 -14
- data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +40 -34
- data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +42 -28
- data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +252 -120
- data/spec/integration/lib/auth0/auth0_client_spec.rb +32 -26
- data/spec/lib/auth0/api/v2/anomaly_spec.rb +26 -0
- data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
- data/spec/lib/auth0/api/v2/client_grants_spec.rb +34 -2
- data/spec/lib/auth0/api/v2/clients_spec.rb +50 -5
- data/spec/lib/auth0/api/v2/connections_spec.rb +49 -1
- data/spec/lib/auth0/api/v2/guardian_spec.rb +154 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +109 -6
- data/spec/lib/auth0/api/v2/log_streams_spec.rb +84 -0
- data/spec/lib/auth0/api/v2/organizations_spec.rb +593 -0
- data/spec/lib/auth0/api/v2/prompts_spec.rb +88 -0
- data/spec/lib/auth0/api/v2/resource_servers_spec.rb +23 -0
- data/spec/lib/auth0/api/v2/roles_spec.rb +362 -0
- data/spec/lib/auth0/api/v2/rules_spec.rb +23 -1
- data/spec/lib/auth0/api/v2/tickets_spec.rb +95 -5
- data/spec/lib/auth0/api/v2/users_spec.rb +465 -61
- data/spec/lib/auth0/client_spec.rb +196 -18
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +83 -4
- data/spec/lib/auth0/mixins/initializer_spec.rb +1 -0
- data/spec/lib/auth0/mixins/validation_spec.rb +498 -0
- data/spec/spec_helper.rb +54 -11
- data/spec/support/credentials.rb +6 -18
- data/spec/support/dummy_class.rb +7 -3
- data/spec/support/dummy_class_for_proxy.rb +1 -0
- data/spec/support/stub_response.rb +1 -1
- metadata +497 -53
- data/.travis.yml +0 -18
- data/build_travis.sh +0 -7
- data/deploy_documentation.sh +0 -29
- data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
- data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
- data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
- data/doc_config/templates/default/layout/html/footer.erb +0 -115
- data/doc_config/templates/default/layout/html/headers.erb +0 -17
- data/doc_config/templates/default/layout/html/layout.erb +0 -27
- data/lib/auth0/api/v1/clients.rb +0 -48
- data/lib/auth0/api/v1/connections.rb +0 -53
- data/lib/auth0/api/v1/logs.rb +0 -34
- data/lib/auth0/api/v1/rules.rb +0 -45
- data/lib/auth0/api/v1/users.rb +0 -164
- data/lib/auth0/api/v1.rb +0 -19
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -348
- data/spec/spec_helper_full.rb +0 -45
- data/spec/spec_helper_unit.rb +0 -3
data/lib/auth0/api/v2/tickets.rb
CHANGED
@@ -9,39 +9,86 @@ module Auth0
|
|
9
9
|
# @see https://auth0.com/docs/api/v2#!/Tickets/post_email_verification
|
10
10
|
# @param user_id [string] The user_id of for which the ticket is to be created.
|
11
11
|
# @param result_url [string] The user will be redirected to this endpoint once the ticket is used.
|
12
|
+
# @param ttl_sec [integer] The ticket's lifetime in seconds starting from the moment of creation.
|
13
|
+
# After expiration, the ticket cannot be used to verify the user's email. If not specified or if
|
14
|
+
# you send 0, the Auth0 default lifetime of five days will be applied
|
15
|
+
# @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
|
16
|
+
# * :user_id [string] user_id of the identity.
|
17
|
+
# * :provider [string] provider of the identity.
|
18
|
+
# @param client_id [string] client id
|
19
|
+
# @param organization_id [string] organization id
|
12
20
|
#
|
13
21
|
# @return [json] Returns the created ticket url.
|
14
|
-
def post_email_verification(user_id, result_url: nil)
|
22
|
+
def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
|
15
23
|
if user_id.to_s.empty?
|
16
24
|
raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
|
17
25
|
end
|
18
26
|
path = "#{tickets_path}/email-verification"
|
19
27
|
request_params = {
|
20
28
|
user_id: user_id,
|
21
|
-
result_url: result_url
|
29
|
+
result_url: result_url,
|
30
|
+
ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
|
22
31
|
}
|
32
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
33
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
34
|
+
|
35
|
+
if identity
|
36
|
+
unless identity.is_a? Hash
|
37
|
+
raise Auth0::InvalidParameter, 'Identity must be a hash to post an email verification'
|
38
|
+
end
|
39
|
+
request_params[:identity] = identity
|
40
|
+
end
|
41
|
+
|
23
42
|
post(path, request_params)
|
24
43
|
end
|
25
44
|
|
26
45
|
# Create a password change ticket
|
27
46
|
# @see https://auth0.com/docs/api/v2#!/Tickets/post_password_change
|
28
|
-
# @param new_password [string] The password to be set for the user once the ticket is used.
|
29
|
-
# @param user_id [string] The user_id of for which the ticket is to be created.
|
30
47
|
# @param result_url [string] The user will be redirected to this endpoint once the ticket is used.
|
48
|
+
# @param user_id [string] The user_id of for which the ticket is to be created.
|
31
49
|
# @param connection_id [string] The connection that provides the identity for which the password is to be
|
32
50
|
# changed. If sending this parameter, the email is also required and the user_id is invalid.
|
33
51
|
# @param email [string] The user's email.
|
52
|
+
# @param ttl_sec [integer] The ticket's lifetime in seconds starting from the moment of creation. After
|
53
|
+
# expiration, the ticket cannot be used to change the user's password. If not specified or if you send 0,
|
54
|
+
# the Auth0 default lifetime of 5 days will be applied.
|
55
|
+
# @param mark_email_as_verified [boolean] true if email_verified attribute must be set to true once password is
|
56
|
+
# changed, false if email_verified attribute should not be updated
|
57
|
+
# @param includeEmailInRedirect [boolean] Whether or not we include the email as part of the returnUrl
|
58
|
+
# in the reset_email
|
59
|
+
# @param new_password [string] The password to be set for the user once the ticket is used.
|
60
|
+
# @param client_id [string] client id
|
61
|
+
# @param organization_id [string] organization id
|
34
62
|
#
|
35
63
|
# @return [json] Returns the created ticket url.
|
36
|
-
def post_password_change(
|
64
|
+
def post_password_change(
|
65
|
+
result_url: nil,
|
66
|
+
user_id: nil,
|
67
|
+
connection_id: nil,
|
68
|
+
email: nil,
|
69
|
+
ttl_sec: nil,
|
70
|
+
mark_email_as_verified: nil,
|
71
|
+
includeEmailInRedirect: nil,
|
72
|
+
new_password: nil,
|
73
|
+
client_id: nil,
|
74
|
+
organization_id: nil
|
75
|
+
)
|
76
|
+
|
77
|
+
booleans = [true, false]
|
37
78
|
path = "#{tickets_path}/password-change"
|
38
79
|
request_params = {
|
39
|
-
user_id: user_id,
|
40
80
|
result_url: result_url,
|
41
|
-
|
81
|
+
user_id: user_id,
|
42
82
|
connection_id: connection_id,
|
43
|
-
email: email
|
83
|
+
email: email,
|
84
|
+
ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil,
|
85
|
+
mark_email_as_verified: booleans.include?(mark_email_as_verified) ? mark_email_as_verified : nil,
|
86
|
+
includeEmailInRedirect: booleans.include?(includeEmailInRedirect) ? includeEmailInRedirect : nil,
|
87
|
+
new_password: new_password
|
44
88
|
}
|
89
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
90
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
91
|
+
|
45
92
|
post(path, request_params)
|
46
93
|
end
|
47
94
|
|
data/lib/auth0/api/v2/users.rb
CHANGED
@@ -3,20 +3,25 @@ module Auth0
|
|
3
3
|
module V2
|
4
4
|
# Methods to use the users endpoints
|
5
5
|
module Users
|
6
|
+
include Auth0::Mixins::Validation
|
7
|
+
|
6
8
|
attr_reader :users_path
|
7
9
|
|
8
|
-
# Retrieves a list of
|
9
|
-
# @see https://auth0.com/docs/api/v2#!/Users/get_users
|
10
|
-
# @param
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
10
|
+
# Retrieves a list of Auth0 users.
|
11
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_users
|
12
|
+
# @param options [hash] The Hash options used to refine the User results.
|
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 if a query summary must be included in the result.
|
16
|
+
# * :sort [string] The field to use for sorting. 1 == ascending and -1 == descending.
|
17
|
+
# * :connection [string] Connection to filter results by.
|
18
|
+
# * :fields [string] A comma separated list of result fields.
|
19
|
+
# * :include_fields [boolean] True to include :fields, false to exclude.
|
20
|
+
# * :q [string] Query in Lucene query string syntax.
|
21
|
+
# * :search_engine [string] User search engine version.
|
22
|
+
# - Will default to v2 if no value is passed.
|
23
|
+
# - Default will change to v3 on 11/13/2018
|
24
|
+
# - See https://auth0.com/docs/users/search/v3#migrate-from-search-engine-v2-to-v3
|
20
25
|
# @return [json] Returns the list of existing users.
|
21
26
|
def users(options = {})
|
22
27
|
request_params = {
|
@@ -27,9 +32,9 @@ module Auth0
|
|
27
32
|
connection: options.fetch(:connection, nil),
|
28
33
|
fields: options.fetch(:fields, nil),
|
29
34
|
include_fields: options.fetch(:include_fields, nil),
|
30
|
-
q: options.fetch(:q, nil)
|
35
|
+
q: options.fetch(:q, nil),
|
36
|
+
search_engine: options.fetch(:search_engine, nil)
|
31
37
|
}
|
32
|
-
request_params[:search_engine] = :v2 if request_params[:q]
|
33
38
|
get(users_path, request_params)
|
34
39
|
end
|
35
40
|
alias get_users users
|
@@ -38,18 +43,20 @@ module Auth0
|
|
38
43
|
# The attribute connection is always mandatory but depending on the type of connection you are using there
|
39
44
|
# could be others too. For instance, Auth0 DB Connections require email and password.
|
40
45
|
# @see https://auth0.com/docs/api/v2#!/Users/post_users
|
41
|
-
# @param
|
42
|
-
# @param
|
43
|
-
#
|
46
|
+
# @param connection [string] The connection the user belongs to.
|
47
|
+
# @param options [hash] See https://auth0.com/docs/api/management/v2#!/Users/post_users for available options
|
44
48
|
# @return [json] Returns the created user.
|
45
|
-
def create_user(
|
49
|
+
def create_user(connection, options = {})
|
50
|
+
if !connection.is_a?(String) || connection.empty?
|
51
|
+
raise Auth0::MissingParameter, 'Must supply a valid connection'
|
52
|
+
end
|
46
53
|
request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
|
47
|
-
request_params[:
|
54
|
+
request_params[:connection] = connection
|
48
55
|
post(users_path, request_params)
|
49
56
|
end
|
50
57
|
|
51
58
|
# Delete all users - USE WITH CAUTION
|
52
|
-
# @
|
59
|
+
# @deprecated - 4.8.0, endpoint has been removed
|
53
60
|
def delete_users
|
54
61
|
delete(users_path)
|
55
62
|
end
|
@@ -93,12 +100,12 @@ module Auth0
|
|
93
100
|
# If your are updating email or phone_number you need to specify the connection and the client_id properties.
|
94
101
|
# @see https://auth0.com/docs/api/v2#!/Users/patch_users_by_id
|
95
102
|
# @param user_id [string] The user_id of the user to update.
|
96
|
-
# @param body [hash] The optional
|
103
|
+
# @param body [hash] The optional parameters to update.
|
97
104
|
#
|
98
105
|
# @return [json] Returns the updated user.
|
99
106
|
def patch_user(user_id, body)
|
100
107
|
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
101
|
-
raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty?
|
108
|
+
raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
|
102
109
|
path = "#{users_path}/#{user_id}"
|
103
110
|
patch(path, body)
|
104
111
|
end
|
@@ -142,21 +149,23 @@ module Auth0
|
|
142
149
|
# @param secondary_user_id [string] The unique identifier for the user for the identity.
|
143
150
|
#
|
144
151
|
# @return [json] Returns the array of the unlinked account identities.
|
145
|
-
def
|
152
|
+
def unlink_user_account(user_id, provider, secondary_user_id)
|
146
153
|
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
147
154
|
raise Auth0::MissingUserId, 'Must supply a valid secondary user_id' if secondary_user_id.to_s.empty?
|
148
155
|
raise Auth0::InvalidParameter, 'Must supply a valid provider' if provider.to_s.empty?
|
149
156
|
path = "#{users_path}/#{user_id}/identities/#{provider}/#{secondary_user_id}"
|
150
157
|
delete(path)
|
151
158
|
end
|
159
|
+
alias unlink_users_account unlink_user_account
|
152
160
|
|
153
161
|
# Retrieve every log event for a specific user id
|
154
162
|
# @see https://auth0.com/docs/api/management/v2#!/Users/get_logs_by_user
|
155
163
|
# @param user_id [string] The user_id of the logs to retrieve.
|
156
|
-
# @param
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
164
|
+
# @param options [hash]
|
165
|
+
# * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
|
166
|
+
# * :page [integer] The page number. Zero based.
|
167
|
+
# * :include_totals [boolean] True if a query summary must be included in the result.
|
168
|
+
# * :sort [string] The field to use for sorting. 1 == ascending and -1 == descending.
|
160
169
|
#
|
161
170
|
# @return [json] Returns the list of existing log entries for the given user_id.
|
162
171
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
@@ -164,7 +173,6 @@ module Auth0
|
|
164
173
|
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
165
174
|
path = "#{users_path}/#{user_id}/logs"
|
166
175
|
request_params = {
|
167
|
-
user_id: user_id,
|
168
176
|
per_page: options.fetch(:per_page, nil),
|
169
177
|
page: options.fetch(:page, nil),
|
170
178
|
include_totals: options.fetch(:include_totals, nil),
|
@@ -181,12 +189,144 @@ module Auth0
|
|
181
189
|
end
|
182
190
|
alias get_user_log_events user_logs
|
183
191
|
|
192
|
+
# Get all roles assigned to a specific user.
|
193
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_user_roles
|
194
|
+
#
|
195
|
+
# @param user_id [string] The user_id of the roles to retrieve.
|
196
|
+
# @param options [hash]
|
197
|
+
# * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
|
198
|
+
# * :page [integer] The page number. Zero based.
|
199
|
+
# * :include_totals [boolean] True if a query summary must be included in the result.
|
200
|
+
# * :sort [string] The field to use for sorting. 1 == ascending and -1 == descending.
|
201
|
+
#
|
202
|
+
# @return [json] Returns roles for the given user_id.
|
203
|
+
def get_user_roles(user_id, options = {})
|
204
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
205
|
+
path = "#{users_path}/#{user_id}/roles"
|
206
|
+
request_params = {
|
207
|
+
per_page: options.fetch(:per_page, nil),
|
208
|
+
page: options.fetch(:page, nil),
|
209
|
+
include_totals: options.fetch(:include_totals, nil)
|
210
|
+
}
|
211
|
+
get(path, request_params)
|
212
|
+
end
|
213
|
+
|
214
|
+
# Remove one or more roles from a specific user.
|
215
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_user_roles
|
216
|
+
#
|
217
|
+
# @param user_id [string] The user_id of the roles to remove.
|
218
|
+
# @param roles [array] An array of role names to remove.
|
219
|
+
def remove_user_roles(user_id, roles)
|
220
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
221
|
+
validate_strings_array roles
|
222
|
+
path = "#{users_path}/#{user_id}/roles"
|
223
|
+
delete_with_body path, roles: roles
|
224
|
+
end
|
225
|
+
|
226
|
+
# Add one or more roles to a specific user.
|
227
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/post_user_roles
|
228
|
+
#
|
229
|
+
# @param user_id [string] The user_id of the roles to add.
|
230
|
+
# @param roles [array] An array of role ids to add.
|
231
|
+
def add_user_roles(user_id, roles)
|
232
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
233
|
+
validate_strings_array roles
|
234
|
+
path = "#{users_path}/#{user_id}/roles"
|
235
|
+
post(path, roles: roles)
|
236
|
+
end
|
237
|
+
|
238
|
+
# Get all Guardian enrollments for a specific user
|
239
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_enrollments
|
240
|
+
#
|
241
|
+
# @param user_id [string] The user_id of the enrollments to get.
|
242
|
+
#
|
243
|
+
# @return [json] Returns Guardian enrollments for the given user_id.
|
244
|
+
def get_enrollments(user_id)
|
245
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
246
|
+
get "#{users_path}/#{user_id}/enrollments"
|
247
|
+
end
|
248
|
+
|
249
|
+
# Get all permissions for a specific user.
|
250
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/get_permissions
|
251
|
+
#
|
252
|
+
# @param user_id [string] The user_id of the permissions to get.
|
253
|
+
# @param options [hash] A hash of options for getting permissions
|
254
|
+
# * :per_page [integer] The amount of permissions per page. (optional)
|
255
|
+
# * :page [integer] The page number. Zero based. (optional)
|
256
|
+
# * :include_totals [boolean] True if a query summary must be included in the result. (optional)
|
257
|
+
#
|
258
|
+
# @return [json] Returns permissions for the given user_id.
|
259
|
+
def get_user_permissions(user_id, options = {})
|
260
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
261
|
+
|
262
|
+
request_params = {
|
263
|
+
per_page: options.fetch(:per_page, nil),
|
264
|
+
page: options.fetch(:page, nil),
|
265
|
+
include_totals: options.fetch(:include_totals, nil)
|
266
|
+
}
|
267
|
+
|
268
|
+
get "#{users_path}/#{user_id}/permissions", request_params
|
269
|
+
end
|
270
|
+
|
271
|
+
# Remove one or more permissions from a specific user.
|
272
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/delete_permissions
|
273
|
+
#
|
274
|
+
# @param user_id [string] The user_id of the permissions to remove.
|
275
|
+
# @param permissions [array] An array of Permission structs to remove.
|
276
|
+
def remove_user_permissions(user_id, permissions)
|
277
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
278
|
+
permissions = validate_permissions_array permissions
|
279
|
+
delete_with_body "#{users_path}/#{user_id}/permissions", permissions: permissions
|
280
|
+
end
|
281
|
+
|
282
|
+
# Add one or more permissions from a specific user.
|
283
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/post_permissions
|
284
|
+
#
|
285
|
+
# @param user_id [string] The user_id of the permissions to add.
|
286
|
+
# @param permissions [array] An array of Permission structs to add.
|
287
|
+
def add_user_permissions(user_id, permissions)
|
288
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
289
|
+
permissions = validate_permissions_array permissions
|
290
|
+
post "#{users_path}/#{user_id}/permissions", permissions: permissions
|
291
|
+
end
|
292
|
+
|
293
|
+
# Remove the current Guardian recovery code and generates and returns a new one.
|
294
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/post_recovery_code_regeneration
|
295
|
+
#
|
296
|
+
# @param user_id [string] The user_id of the recovery codes to regenerate.
|
297
|
+
def generate_recovery_code(user_id)
|
298
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
299
|
+
post "#{users_path}/#{user_id}/recovery-code-regeneration"
|
300
|
+
end
|
301
|
+
|
302
|
+
# Invalidate all remembered browsers for all authentication factors for a specific user.
|
303
|
+
# @see https://auth0.com/docs/api/management/v2#!/Users/post_invalidate_remember_browser
|
304
|
+
#
|
305
|
+
# @param user_id [string] The user_id of the browsers to invalidate.
|
306
|
+
def invalidate_browsers(user_id)
|
307
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
308
|
+
post "#{users_path}/#{user_id}/multifactor/actions/invalidate-remember-browser"
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
# Get a list of organizations for a user.
|
313
|
+
#
|
314
|
+
# @param user_id [string] The user_id of the permissions to get.
|
315
|
+
#
|
316
|
+
# @return [json] Returns organizations for the given user_id.
|
317
|
+
def get_user_organizations(user_id)
|
318
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
319
|
+
|
320
|
+
get "#{users_path}/#{user_id}/organizations"
|
321
|
+
end
|
322
|
+
|
184
323
|
private
|
185
324
|
|
186
325
|
# Users API path
|
187
326
|
def users_path
|
188
327
|
@users_path ||= '/api/v2/users'
|
189
328
|
end
|
329
|
+
|
190
330
|
end
|
191
331
|
end
|
192
332
|
end
|
@@ -8,9 +8,10 @@ module Auth0
|
|
8
8
|
# Retrieves a list of existing users by their email.
|
9
9
|
# @see https://auth0.com/docs/api/v2#!/Users/get_users
|
10
10
|
# @see https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email
|
11
|
-
# @param fields [string] A comma separated list of fields to include or exclude from the result.
|
12
|
-
# @param include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
|
13
11
|
# @param email [string] E-mail to be searched
|
12
|
+
# @param options [hash]
|
13
|
+
# * :fields [string] A comma separated list of fields to include or exclude from the result.
|
14
|
+
# * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
|
14
15
|
#
|
15
16
|
# @return [json] Returns the list of existing users.
|
16
17
|
def users_by_email(email, options = {})
|
data/lib/auth0/api/v2.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
+
require 'auth0/api/v2/anomaly'
|
1
2
|
require 'auth0/api/v2/blacklists'
|
3
|
+
require 'auth0/api/v2/branding'
|
2
4
|
require 'auth0/api/v2/clients'
|
3
5
|
require 'auth0/api/v2/client_grants'
|
4
6
|
require 'auth0/api/v2/connections'
|
5
7
|
require 'auth0/api/v2/device_credentials'
|
6
8
|
require 'auth0/api/v2/emails'
|
7
9
|
require 'auth0/api/v2/jobs'
|
10
|
+
require 'auth0/api/v2/prompts'
|
11
|
+
require 'auth0/api/v2/organizations'
|
8
12
|
require 'auth0/api/v2/rules'
|
13
|
+
require 'auth0/api/v2/roles'
|
9
14
|
require 'auth0/api/v2/stats'
|
10
15
|
require 'auth0/api/v2/users'
|
11
16
|
require 'auth0/api/v2/users_by_email'
|
@@ -13,28 +18,37 @@ require 'auth0/api/v2/user_blocks'
|
|
13
18
|
require 'auth0/api/v2/tenants'
|
14
19
|
require 'auth0/api/v2/tickets'
|
15
20
|
require 'auth0/api/v2/logs'
|
21
|
+
require 'auth0/api/v2/log_streams'
|
16
22
|
require 'auth0/api/v2/resource_servers'
|
23
|
+
require 'auth0/api/v2/guardian'
|
17
24
|
|
18
25
|
module Auth0
|
19
26
|
module Api
|
20
27
|
# https://auth0.com/docs/apiv2
|
21
28
|
module V2
|
29
|
+
include Auth0::Api::V2::Anomaly
|
22
30
|
include Auth0::Api::V2::Blacklists
|
31
|
+
include Auth0::Api::V2::Branding
|
23
32
|
include Auth0::Api::V2::Clients
|
24
33
|
include Auth0::Api::V2::ClientGrants
|
25
34
|
include Auth0::Api::V2::Connections
|
26
35
|
include Auth0::Api::V2::DeviceCredentials
|
27
36
|
include Auth0::Api::V2::Emails
|
37
|
+
include Auth0::Api::V2::Guardian
|
28
38
|
include Auth0::Api::V2::Jobs
|
39
|
+
include Auth0::Api::V2::Logs
|
40
|
+
include Auth0::Api::V2::LogStreams
|
41
|
+
include Auth0::Api::V2::Prompts
|
42
|
+
include Auth0::Api::V2::Organizations
|
29
43
|
include Auth0::Api::V2::Rules
|
44
|
+
include Auth0::Api::V2::Roles
|
30
45
|
include Auth0::Api::V2::Stats
|
31
46
|
include Auth0::Api::V2::Users
|
32
47
|
include Auth0::Api::V2::UsersByEmail
|
33
48
|
include Auth0::Api::V2::UserBlocks
|
49
|
+
include Auth0::Api::V2::ResourceServers
|
34
50
|
include Auth0::Api::V2::Tenants
|
35
51
|
include Auth0::Api::V2::Tickets
|
36
|
-
include Auth0::Api::V2::Logs
|
37
|
-
include Auth0::Api::V2::ResourceServers
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
data/lib/auth0/client.rb
CHANGED
data/lib/auth0/exception.rb
CHANGED
@@ -2,19 +2,35 @@ module Auth0
|
|
2
2
|
# Default exception in namespace of Auth0
|
3
3
|
# if you want to catch all exceptions, then you should use this one.
|
4
4
|
# Network exceptions are not included
|
5
|
-
class Exception < StandardError
|
5
|
+
class Exception < StandardError
|
6
|
+
attr_reader :error_data
|
7
|
+
def initialize(message,error_data={})
|
8
|
+
super(message)
|
9
|
+
@error_data = error_data
|
10
|
+
end
|
11
|
+
end
|
12
|
+
# Parent for all exceptions that arise out of HTTP error responses.
|
13
|
+
class HTTPError < Auth0::Exception
|
14
|
+
def headers
|
15
|
+
error_data[:headers]
|
16
|
+
end
|
17
|
+
|
18
|
+
def http_code
|
19
|
+
error_data[:code]
|
20
|
+
end
|
21
|
+
end
|
6
22
|
# exception for unauthorized requests, if you see it,
|
7
23
|
# probably Bearer Token is not set correctly
|
8
|
-
class Unauthorized < Auth0::
|
24
|
+
class Unauthorized < Auth0::HTTPError; end
|
9
25
|
# exception for not found resource, you query for an
|
10
26
|
# unexistent resource, or wrong path
|
11
|
-
class NotFound < Auth0::
|
27
|
+
class NotFound < Auth0::HTTPError; end
|
12
28
|
# exception for unknown error
|
13
|
-
class Unsupported < Auth0::
|
29
|
+
class Unsupported < Auth0::HTTPError; end
|
14
30
|
# exception for server error
|
15
|
-
class ServerError < Auth0::
|
31
|
+
class ServerError < Auth0::HTTPError; end
|
16
32
|
# exception for incorrect request, you've sent wrong params
|
17
|
-
class BadRequest < Auth0::
|
33
|
+
class BadRequest < Auth0::HTTPError; end
|
18
34
|
# exception for timeouts
|
19
35
|
class RequestTimeout < Auth0::Exception; end
|
20
36
|
# exception for unset user_id, this might cause removal of
|
@@ -22,15 +38,24 @@ module Auth0
|
|
22
38
|
class MissingUserId < Auth0::Exception; end
|
23
39
|
# exception for unset client_id
|
24
40
|
class MissingClientId < Auth0::Exception; end
|
41
|
+
# exception for unset organization_id
|
42
|
+
class MissingOrganizationId < Auth0::Exception; end
|
25
43
|
# exception for an unset parameter
|
26
44
|
class MissingParameter < Auth0::Exception; end
|
27
45
|
# Api v2 access denied
|
28
|
-
class AccessDenied < Auth0::
|
46
|
+
class AccessDenied < Auth0::HTTPError; end
|
29
47
|
# Invalid parameter passed, e.g. empty where ID is required
|
30
48
|
class InvalidParameter < Auth0::Exception; end
|
31
|
-
# Invalid
|
32
|
-
# or JWT for API v2/
|
49
|
+
# Invalid JWT
|
33
50
|
class InvalidCredentials < Auth0::Exception; end
|
34
51
|
# Invalid Auth0 API namespace
|
35
52
|
class InvalidApiNamespace < Auth0::Exception; end
|
53
|
+
# Auth0 API rate-limiting encountered
|
54
|
+
class RateLimitEncountered < Auth0::HTTPError
|
55
|
+
def reset
|
56
|
+
Time.at(Integer(headers[:x_ratelimit_reset])).utc
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class InvalidIdToken < Auth0::Exception; end
|
36
61
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Auth0::AccessToken = Struct.new(
|
2
|
+
:access_token,
|
3
|
+
:expires_in,
|
4
|
+
:refresh_token,
|
5
|
+
:id_token
|
6
|
+
) do
|
7
|
+
|
8
|
+
def self.from_response(response)
|
9
|
+
new(
|
10
|
+
response['access_token'],
|
11
|
+
response['expires_in'],
|
12
|
+
response['refresh_token'],
|
13
|
+
response['id_token']
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def token
|
18
|
+
access_token
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Auth0
|
4
|
+
module Mixins
|
5
|
+
# Module to provide necessary headers for API requests.
|
6
|
+
module Headers
|
7
|
+
def telemetry
|
8
|
+
telemetry_hash = {
|
9
|
+
name: 'ruby-auth0',
|
10
|
+
version: Auth0::VERSION,
|
11
|
+
env: {
|
12
|
+
ruby: RUBY_VERSION
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
if Gem.loaded_specs['rails'].respond_to? :version
|
17
|
+
telemetry_hash[:env][:rails] = Gem.loaded_specs['rails'].version.to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
telemetry_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
def telemetry_encoded
|
24
|
+
Base64.urlsafe_encode64(JSON.dump(telemetry))
|
25
|
+
end
|
26
|
+
|
27
|
+
def client_headers
|
28
|
+
{
|
29
|
+
'Content-Type' => 'application/json',
|
30
|
+
'Auth0-Client' => telemetry_encoded
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|