auth0 6.5.0 → 6.7.0

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 (176) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +3 -3
  3. data/.fern/replay.lock +362 -48
  4. data/.version +1 -1
  5. data/CHANGELOG.md +15 -0
  6. data/EXAMPLES.md +20 -0
  7. data/README.md +18 -0
  8. data/examples/ruby-api/Gemfile.lock +3 -3
  9. data/lib/auth0/attack_protection/brute_force_protection/types/update_brute_force_settings_request_content.rb +2 -2
  10. data/lib/auth0/attack_protection/client.rb +0 -5
  11. data/lib/auth0/auth_client.rb +27 -2
  12. data/lib/auth0/client.rb +15 -2
  13. data/lib/auth0/clients/client.rb +3 -0
  14. data/lib/auth0/clients/types/create_client_request_content.rb +4 -0
  15. data/lib/auth0/clients/types/list_clients_request_parameters.rb +2 -0
  16. data/lib/auth0/clients/types/update_client_request_content.rb +4 -0
  17. data/lib/auth0/connections/keys/client.rb +19 -5
  18. data/lib/auth0/emails/provider/client.rb +1 -6
  19. data/lib/auth0/emails/provider/types/create_email_provider_request_content.rb +1 -1
  20. data/lib/auth0/experimentation/experiments/client.rb +2 -1
  21. data/lib/auth0/experimentation/experiments/types/create_experiment_request_content.rb +1 -1
  22. data/lib/auth0/experimentation/segments/client.rb +4 -1
  23. data/lib/auth0/experimentation/segments/types/list_segments_request_parameters.rb +2 -0
  24. data/lib/auth0/internal/http/rate_limit.rb +103 -0
  25. data/lib/auth0/internal/http/raw_client.rb +14 -2
  26. data/lib/auth0/mixins/httpproxy.rb +9 -1
  27. data/lib/auth0/mixins/initializer.rb +5 -0
  28. data/lib/auth0/portals/client.rb +198 -0
  29. data/lib/auth0/portals/types/create_portal_request_content.rb +21 -0
  30. data/lib/auth0/portals/types/update_portal_request_content.rb +23 -0
  31. data/lib/auth0/resource_servers/types/create_resource_server_request_content.rb +4 -0
  32. data/lib/auth0/resource_servers/types/update_resource_server_request_content.rb +4 -0
  33. data/lib/auth0/self_service_profiles/sso_ticket/types/create_self_service_profile_sso_ticket_request_content.rb +2 -0
  34. data/lib/auth0/types/client.rb +6 -0
  35. data/lib/auth0/types/client_credential_algorithm_enum.rb +2 -0
  36. data/lib/auth0/types/client_oidc_support.rb +15 -0
  37. data/lib/auth0/types/client_oidc_support_patch.rb +2 -1
  38. data/lib/auth0/types/client_oidc_support_post.rb +2 -2
  39. data/lib/auth0/types/client_profile_client_configuration.rb +2 -0
  40. data/lib/auth0/types/client_profile_client_configuration_oidc_support.rb +10 -0
  41. data/lib/auth0/types/client_profile_client_configuration_oidc_support_allowed_scopes_enum.rb +14 -0
  42. data/lib/auth0/types/client_profile_client_configuration_oidc_support_default_value.rb +15 -0
  43. data/lib/auth0/types/client_search_response.rb +6 -0
  44. data/lib/auth0/types/{list_attack_protection_captcha_policies_response_content.rb → connection_client_id_samlxaa_requesting_app.rb} +2 -2
  45. data/lib/auth0/types/connection_client_secret_samlxaa_requesting_app.rb +23 -0
  46. data/lib/auth0/types/connection_options_auth0.rb +2 -0
  47. data/lib/auth0/types/connection_options_saml.rb +10 -0
  48. data/lib/auth0/types/connection_otp_channel_settings.rb +12 -0
  49. data/lib/auth0/types/connection_otp_settings.rb +12 -0
  50. data/lib/auth0/types/connection_passkey_authentication_method.rb +2 -0
  51. data/lib/auth0/types/connection_password_options_dictionary.rb +2 -0
  52. data/lib/auth0/types/connection_properties_options.rb +6 -0
  53. data/lib/auth0/types/connection_response_content_saml.rb +2 -0
  54. data/lib/auth0/types/consent_signing_key.rb +15 -0
  55. data/lib/auth0/types/create_client_response_content.rb +6 -0
  56. data/lib/auth0/types/create_connection_request_content_saml.rb +2 -0
  57. data/lib/auth0/types/create_resource_server_response_content.rb +4 -0
  58. data/lib/auth0/types/event_stream_cloud_event_context.rb +2 -0
  59. data/lib/auth0/types/event_stream_cloud_event_context_transaction.rb +30 -0
  60. data/lib/auth0/types/event_stream_cloud_event_context_transaction_protocol_enum.rb +24 -0
  61. data/lib/auth0/types/event_stream_cloud_event_context_transaction_response_mode_enum.rb +14 -0
  62. data/lib/auth0/types/event_stream_cloud_event_context_transaction_response_type_item_enum.rb +13 -0
  63. data/lib/auth0/types/express_configuration.rb +2 -0
  64. data/lib/auth0/types/express_configuration_or_null.rb +2 -0
  65. data/lib/auth0/types/get_brute_force_settings_response_content.rb +2 -2
  66. data/lib/auth0/types/get_client_response_content.rb +6 -0
  67. data/lib/auth0/types/get_resource_server_response_content.rb +4 -0
  68. data/lib/auth0/types/google_account_linking_configuration.rb +10 -0
  69. data/lib/auth0/types/google_account_linking_configuration_create.rb +10 -0
  70. data/lib/auth0/types/google_account_linking_configuration_or_null.rb +10 -0
  71. data/lib/auth0/types/guardian_factor_name_enum.rb +1 -0
  72. data/lib/auth0/types/include_user_profile_size_header_enum.rb +11 -0
  73. data/lib/auth0/types/internal_server_error_body.rb +13 -0
  74. data/lib/auth0/types/internal_server_error_body_error.rb +11 -0
  75. data/lib/auth0/types/list_portals_response_content.rb +9 -0
  76. data/lib/auth0/types/list_user_consent_signing_keys_response_content.rb +9 -0
  77. data/lib/auth0/types/log_stream_filter_group_name_enum.rb +3 -0
  78. data/lib/auth0/types/oauth_scope.rb +4 -0
  79. data/lib/auth0/types/page_component.rb +33 -0
  80. data/lib/auth0/types/page_component_auth0form.rb +9 -0
  81. data/lib/auth0/types/page_component_auth0form_config.rb +11 -0
  82. data/lib/auth0/types/page_component_auth0media_image.rb +9 -0
  83. data/lib/auth0/types/page_component_auth0media_image_config.rb +13 -0
  84. data/lib/auth0/types/page_component_auth0my_account_mfa_management.rb +9 -0
  85. data/lib/auth0/types/page_component_auth0my_account_mfa_management_config.rb +7 -0
  86. data/lib/auth0/types/page_component_auth0my_account_passkey_management.rb +9 -0
  87. data/lib/auth0/types/page_component_auth0my_account_passkey_management_config.rb +7 -0
  88. data/lib/auth0/types/page_component_auth0my_organization_details_edit.rb +9 -0
  89. data/lib/auth0/types/page_component_auth0my_organization_details_edit_config.rb +7 -0
  90. data/lib/auth0/types/page_component_auth0my_organization_domain_table.rb +9 -0
  91. data/lib/auth0/types/page_component_auth0my_organization_domain_table_config.rb +7 -0
  92. data/lib/auth0/types/page_component_auth0my_organization_member_management.rb +9 -0
  93. data/lib/auth0/types/page_component_auth0my_organization_member_management_config.rb +7 -0
  94. data/lib/auth0/types/page_component_auth0structure_section.rb +9 -0
  95. data/lib/auth0/types/page_component_auth0structure_section_config.rb +15 -0
  96. data/lib/auth0/types/page_component_auth0structure_section_variant_enum.rb +12 -0
  97. data/lib/auth0/types/page_component_auth0structure_separator.rb +9 -0
  98. data/lib/auth0/types/page_component_auth0structure_separator_config.rb +11 -0
  99. data/lib/auth0/types/page_component_auth0structure_separator_variant_enum.rb +13 -0
  100. data/lib/auth0/types/page_component_auth0typography_heading.rb +9 -0
  101. data/lib/auth0/types/page_component_auth0typography_heading_config.rb +11 -0
  102. data/lib/auth0/types/page_component_auth0typography_rich_text.rb +9 -0
  103. data/lib/auth0/types/page_component_auth0typography_rich_text_config.rb +9 -0
  104. data/lib/auth0/types/page_component_no_children.rb +31 -0
  105. data/lib/auth0/types/page_slug.rb +23 -0
  106. data/lib/auth0/types/password_dictionary_match_type_enum.rb +12 -0
  107. data/lib/auth0/types/portal.rb +25 -0
  108. data/lib/auth0/types/portal_client_secret_post.rb +11 -0
  109. data/lib/auth0/types/portal_client_secret_post_request.rb +13 -0
  110. data/lib/auth0/types/portal_client_secret_post_request_token_endpoint_auth_method.rb +11 -0
  111. data/lib/auth0/types/portal_client_secret_post_token_endpoint_auth_method.rb +11 -0
  112. data/lib/auth0/types/portal_custom_code.rb +9 -0
  113. data/lib/auth0/types/portal_custom_code_nullable.rb +23 -0
  114. data/lib/auth0/types/portal_date_time.rb +23 -0
  115. data/lib/auth0/types/portal_id.rb +23 -0
  116. data/lib/auth0/types/portal_name.rb +23 -0
  117. data/lib/auth0/types/portal_navigation.rb +9 -0
  118. data/lib/auth0/types/portal_navigation_nullable.rb +23 -0
  119. data/lib/auth0/types/portal_page.rb +13 -0
  120. data/lib/auth0/types/portal_pages_by_type.rb +11 -0
  121. data/lib/auth0/types/portal_pages_by_type_nullable.rb +23 -0
  122. data/lib/auth0/types/portal_slug.rb +23 -0
  123. data/lib/auth0/types/portal_summary.rb +17 -0
  124. data/lib/auth0/types/position.rb +13 -0
  125. data/lib/auth0/types/post_connection_keys_request_content.rb +2 -0
  126. data/lib/auth0/types/resource_server.rb +4 -0
  127. data/lib/auth0/types/resource_server_agent_subject_claims_response_enum.rb +12 -0
  128. data/lib/auth0/types/resource_server_agent_subject_claims_schema_enum.rb +12 -0
  129. data/lib/auth0/types/resource_server_search_response.rb +4 -0
  130. data/lib/auth0/types/resource_server_type_enum.rb +12 -0
  131. data/lib/auth0/types/rotate_client_secret_response_content.rb +6 -0
  132. data/lib/auth0/types/rotate_connection_keys_request_content.rb +2 -0
  133. data/lib/auth0/types/screen_group_name_enum.rb +1 -0
  134. data/lib/auth0/types/self_service_profile_sso_ticket_universal_logout_config.rb +10 -0
  135. data/lib/auth0/types/sidebar.rb +9 -0
  136. data/lib/auth0/types/sidebar_component.rb +19 -0
  137. data/lib/auth0/types/sidebar_component_auth0external_link.rb +10 -0
  138. data/lib/auth0/types/sidebar_component_auth0external_link_config.rb +13 -0
  139. data/lib/auth0/types/sidebar_component_auth0external_link_v2.rb +9 -0
  140. data/lib/auth0/types/sidebar_component_auth0external_link_v2config.rb +13 -0
  141. data/lib/auth0/types/sidebar_component_auth0internal_link.rb +10 -0
  142. data/lib/auth0/types/sidebar_component_auth0internal_link_config.rb +13 -0
  143. data/lib/auth0/types/sidebar_component_auth0internal_link_v2.rb +9 -0
  144. data/lib/auth0/types/sidebar_component_auth0internal_link_v2config.rb +13 -0
  145. data/lib/auth0/types/tenant_settings_flags.rb +0 -2
  146. data/lib/auth0/types/update_brute_force_settings_response_content.rb +2 -2
  147. data/lib/auth0/types/update_client_response_content.rb +6 -0
  148. data/lib/auth0/types/update_connection_options.rb +6 -0
  149. data/lib/auth0/types/update_connection_request_content_saml.rb +2 -0
  150. data/lib/auth0/types/update_resource_server_response_content.rb +4 -0
  151. data/lib/auth0/types/update_variation_overrides_map.rb +1 -1
  152. data/lib/auth0/users/client.rb +120 -0
  153. data/lib/auth0/version.rb +1 -1
  154. data/lib/auth0.rb +86 -23
  155. data/wiremock/wiremock-mappings.json +310 -190
  156. metadata +87 -23
  157. data/lib/auth0/attack_protection/captcha_policies/client.rb +0 -210
  158. data/lib/auth0/attack_protection/captcha_policies/types/create_attack_protection_captcha_policy_request_content.rb +0 -21
  159. data/lib/auth0/attack_protection/captcha_policies/types/update_attack_protection_captcha_policy_request_content.rb +0 -23
  160. data/lib/auth0/types/attack_protection_captcha_policy.rb +0 -24
  161. data/lib/auth0/types/attack_protection_captcha_policy_action.rb +0 -24
  162. data/lib/auth0/types/attack_protection_captcha_policy_action_input.rb +0 -24
  163. data/lib/auth0/types/attack_protection_captcha_policy_match.rb +0 -12
  164. data/lib/auth0/types/captcha_active_provider_enum.rb +0 -17
  165. data/lib/auth0/types/captcha_policy_action_arkose.rb +0 -16
  166. data/lib/auth0/types/captcha_policy_action_arkose_input.rb +0 -18
  167. data/lib/auth0/types/captcha_policy_action_auth_challenge.rb +0 -10
  168. data/lib/auth0/types/captcha_policy_action_friendly_captcha.rb +0 -10
  169. data/lib/auth0/types/captcha_policy_action_friendly_captcha_input.rb +0 -12
  170. data/lib/auth0/types/captcha_policy_action_hcaptcha.rb +0 -10
  171. data/lib/auth0/types/captcha_policy_action_hcaptcha_input.rb +0 -12
  172. data/lib/auth0/types/captcha_policy_action_recaptcha_enterprise.rb +0 -12
  173. data/lib/auth0/types/captcha_policy_action_recaptcha_enterprise_input.rb +0 -14
  174. data/lib/auth0/types/captcha_policy_action_recaptcha_v2.rb +0 -10
  175. data/lib/auth0/types/captcha_policy_action_recaptcha_v2input.rb +0 -12
  176. data/lib/auth0/types/captcha_policy_action_simple_captcha.rb +0 -8
@@ -54,6 +54,7 @@ module Auth0
54
54
  # @option params [Boolean, nil] :is_first_party
55
55
  # @option params [String, nil] :app_type
56
56
  # @option params [String, nil] :external_client_id
57
+ # @option params [String, nil] :agent_id
57
58
  # @option params [String, nil] :q
58
59
  #
59
60
  # @example
@@ -67,6 +68,7 @@ module Auth0
67
68
  # is_first_party: true,
68
69
  # app_type: "app_type",
69
70
  # external_client_id: "external_client_id",
71
+ # agent_id: "agent_id",
70
72
  # q: "q"
71
73
  # )
72
74
  #
@@ -83,6 +85,7 @@ module Auth0
83
85
  query_params["is_first_party"] = params[:is_first_party] if params.key?(:is_first_party)
84
86
  query_params["app_type"] = params[:app_type] if params.key?(:app_type)
85
87
  query_params["external_client_id"] = params[:external_client_id] if params.key?(:external_client_id)
88
+ query_params["agent_id"] = params[:agent_id] if params.key?(:agent_id)
86
89
  query_params["q"] = params[:q] if params.key?(:q)
87
90
 
88
91
  Auth0::Internal::OffsetItemIterator.new(
@@ -120,8 +120,12 @@ module Auth0
120
120
 
121
121
  field :my_organization_configuration, -> { Auth0::Types::ClientMyOrganizationPostConfiguration }, optional: true, nullable: false
122
122
 
123
+ field :google_account_linking, -> { Auth0::Types::GoogleAccountLinkingConfigurationCreate }, optional: true, nullable: false
124
+
123
125
  field :async_approval_notification_channels, -> { Internal::Types::Array[Auth0::Types::AsyncApprovalNotificationsChannelsEnum] }, optional: true, nullable: false
124
126
 
127
+ field :agent_id, -> { String }, optional: true, nullable: false
128
+
125
129
  field :oidc_support, -> { Auth0::Types::ClientOidcSupportPost }, optional: true, nullable: false
126
130
  end
127
131
  end
@@ -22,6 +22,8 @@ module Auth0
22
22
 
23
23
  field :external_client_id, -> { String }, optional: true, nullable: false
24
24
 
25
+ field :agent_id, -> { String }, optional: true, nullable: false
26
+
25
27
  field :q, -> { String }, optional: true, nullable: false
26
28
  end
27
29
  end
@@ -118,12 +118,16 @@ module Auth0
118
118
 
119
119
  field :my_organization_configuration, -> { Auth0::Types::ClientMyOrganizationPatchConfiguration }, optional: true, nullable: false
120
120
 
121
+ field :google_account_linking, -> { Auth0::Types::GoogleAccountLinkingConfigurationOrNull }, optional: true, nullable: false
122
+
121
123
  field :async_approval_notification_channels, -> { Internal::Types::Array[Auth0::Types::AsyncApprovalNotificationsChannelsEnum] }, optional: true, nullable: false
122
124
 
123
125
  field :third_party_security_mode, -> { Auth0::Types::ClientThirdPartySecurityModeEnum }, optional: true, nullable: false
124
126
 
125
127
  field :redirection_policy, -> { Auth0::Types::ClientRedirectionPolicyEnum }, optional: true, nullable: false
126
128
 
129
+ field :agent_id, -> { String }, optional: true, nullable: false
130
+
127
131
  field :oidc_support, -> { Auth0::Types::ClientOidcSupportPatch }, optional: true, nullable: false
128
132
  end
129
133
  end
@@ -11,7 +11,9 @@ module Auth0
11
11
  @client = client
12
12
  end
13
13
 
14
- # Gets the connection keys for the Okta or OIDC connection strategy.
14
+ # Gets the connection keys for the Okta, OIDC, or SAML (samlp) connection strategy. The response includes both
15
+ # signing keys and encryption keys, told apart by `key_use`. Encryption keys apply only to OIDC and Okta
16
+ # connections.
15
17
  #
16
18
  # @param request_options [Hash]
17
19
  # @param params [Hash]
@@ -48,9 +50,14 @@ module Auth0
48
50
  end
49
51
  end
50
52
 
51
- # Provision initial connection keys for Okta or OIDC connection strategies. This endpoint allows you to create
52
- # keys before configuring the connection to use Private Key JWT authentication, enabling zero-downtime
53
- # transitions.
53
+ # Provision initial connection keys for Okta, OIDC, or SAML (samlp) connection strategies. This endpoint allows
54
+ # you to create keys before configuring the connection to use Private Key JWT authentication or encrypted ID
55
+ # tokens, enabling zero-downtime transitions.
56
+ #
57
+ # Set `key_use` to `signing` (default) to provision signing keys, optionally choosing `signing_alg`, or to
58
+ # `encryption` to provision encryption keys, optionally choosing `encryption_alg`. `signing_alg` and
59
+ # `encryption_alg` each apply only to their own key use. Encryption keys and encrypted ID tokens apply only to
60
+ # OIDC and Okta connections. The response lists all of the connection's keys.
54
61
  #
55
62
  # @param request_options [Hash]
56
63
  # @param params [Hash]
@@ -94,7 +101,14 @@ module Auth0
94
101
  end
95
102
  end
96
103
 
97
- # Rotates the connection keys for the Okta or OIDC connection strategies.
104
+ # Rotates the connection keys for the Okta, OIDC, or SAML (samlp) connection strategies.
105
+ #
106
+ # Set `key_use` to `signing` (default) to rotate the signing key, optionally choosing `signing_alg`, or to
107
+ # `encryption` to rotate the encryption key, optionally choosing `encryption_alg`. Rotating signing keys
108
+ # requires the connection to be configured to use JWT Client Authentication. Rotating encryption keys requires
109
+ # the connection to be configured to use encrypted ID tokens (`id_token_encrypted_response_alg` set), which
110
+ # applies only to OIDC and Okta connections. When `encryption_alg` is omitted, the new encryption key uses
111
+ # `id_token_encrypted_response_alg`.
98
112
  #
99
113
  # @param request_options [Hash]
100
114
  # @param params [Hash]
@@ -94,12 +94,7 @@ module Auth0
94
94
  # @option request_options [Integer] :timeout_in_seconds
95
95
  #
96
96
  # @example
97
- # client.emails.provider.create(
98
- # name: "mailgun",
99
- # credentials: {
100
- # api_key: "api_key"
101
- # }
102
- # )
97
+ # client.emails.provider.create(name: "mailgun")
103
98
  #
104
99
  # @return [Auth0::Types::CreateEmailProviderResponseContent]
105
100
  def create(request_options: {}, **params)
@@ -11,7 +11,7 @@ module Auth0
11
11
 
12
12
  field :default_from_address, -> { String }, optional: true, nullable: false
13
13
 
14
- field :credentials, -> { Auth0::Types::EmailProviderCredentialsSchema }, optional: false, nullable: false
14
+ field :credentials, -> { Auth0::Types::EmailProviderCredentialsSchema }, optional: true, nullable: false
15
15
 
16
16
  field :settings, -> { Internal::Types::Hash[String, Object] }, optional: true, nullable: false
17
17
  end
@@ -88,7 +88,8 @@ module Auth0
88
88
  # client.experimentation.experiments.create(
89
89
  # name: "name",
90
90
  # feature_flag_id: "feature_flag_id",
91
- # authentication_flow: "authentication"
91
+ # authentication_flow: "authentication",
92
+ # allocation_strategy: "percentage"
92
93
  # )
93
94
  #
94
95
  # @return [Auth0::Types::CreateExperimentResponseContent]
@@ -15,7 +15,7 @@ module Auth0
15
15
 
16
16
  field :default_config, -> { Auth0::Types::DefaultConfigEnum }, optional: true, nullable: false
17
17
 
18
- field :allocation_strategy, -> { Auth0::Types::AllocationStrategyEnum }, optional: true, nullable: false
18
+ field :allocation_strategy, -> { Auth0::Types::AllocationStrategyEnum }, optional: false, nullable: false
19
19
 
20
20
  field :allocations, -> { Internal::Types::Array[Auth0::Types::AllocationRequestItem] }, optional: true, nullable: false
21
21
 
@@ -23,12 +23,14 @@ module Auth0
23
23
  # @option params [String, nil] :from
24
24
  # @option params [Integer, nil] :take
25
25
  # @option params [Auth0::Types::SegmentTypeFilterEnum, nil] :type
26
+ # @option params [Auth0::Types::SegmentStatusEnum, nil] :status
26
27
  #
27
28
  # @example
28
29
  # client.experimentation.segments.list(
29
30
  # from: "from",
30
31
  # take: 1,
31
- # type: "auth0"
32
+ # type: "auth0",
33
+ # status: "active"
32
34
  # )
33
35
  #
34
36
  # @return [Auth0::Types::ListSegmentsResponseContent]
@@ -38,6 +40,7 @@ module Auth0
38
40
  query_params["from"] = params[:from] if params.key?(:from)
39
41
  query_params["take"] = params.fetch(:take, 50)
40
42
  query_params["type"] = params[:type] if params.key?(:type)
43
+ query_params["status"] = params[:status] if params.key?(:status)
41
44
 
42
45
  Auth0::Internal::CursorItemIterator.new(
43
46
  cursor_field: :next_,
@@ -10,6 +10,8 @@ module Auth0
10
10
  field :take, -> { Integer }, optional: true, nullable: false
11
11
 
12
12
  field :type, -> { Auth0::Types::SegmentTypeFilterEnum }, optional: true, nullable: false
13
+
14
+ field :status, -> { Auth0::Types::SegmentStatusEnum }, optional: true, nullable: false
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Auth0
4
+ module Internal
5
+ module Http
6
+ # Rate limit information parsed from the `x-ratelimit-*` headers Auth0
7
+ # returns on API responses.
8
+ #
9
+ # @see https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy
10
+ class RateLimit
11
+ # @return [Integer, nil] the maximum number of requests allowed in the current window
12
+ attr_reader :limit
13
+ # @return [Integer, nil] the number of requests remaining in the current window
14
+ attr_reader :remaining
15
+ # @return [Time, nil] the UTC time at which the current window resets
16
+ attr_reader :reset
17
+
18
+ # @param limit [Integer, nil]
19
+ # @param remaining [Integer, nil]
20
+ # @param reset [Time, nil]
21
+ def initialize(limit:, remaining:, reset:)
22
+ @limit = limit
23
+ @remaining = remaining
24
+ @reset = reset
25
+ end
26
+
27
+ # Build from an object that exposes headers via `#[]` using the HTTP
28
+ # header name (e.g. a `Net::HTTPResponse`, whose `#[]` is
29
+ # case-insensitive). Used by the Management API (RawClient) path.
30
+ #
31
+ # @param response [#[]] responds to `[]` with header access
32
+ # @return [Auth0::Internal::Http::RateLimit]
33
+ def self.from_http_response(response)
34
+ build(
35
+ response["x-ratelimit-limit"],
36
+ response["x-ratelimit-remaining"],
37
+ response["x-ratelimit-reset"]
38
+ )
39
+ end
40
+
41
+ # Build from a plain headers hash (e.g. RestClient's, whose keys are
42
+ # symbols like `:x_ratelimit_remaining`). Keys are matched
43
+ # case-insensitively and dash/underscore-agnostically. Used by the
44
+ # Authentication API (HTTPProxy) path.
45
+ #
46
+ # @param headers [Hash, nil]
47
+ # @return [Auth0::Internal::Http::RateLimit]
48
+ def self.from_headers(headers)
49
+ normalized = (headers || {}).each_with_object({}) do |(key, value), acc|
50
+ acc[key.to_s.downcase.tr("-", "_")] = value
51
+ end
52
+
53
+ build(
54
+ normalized["x_ratelimit_limit"],
55
+ normalized["x_ratelimit_remaining"],
56
+ normalized["x_ratelimit_reset"]
57
+ )
58
+ end
59
+
60
+ # Invokes the handler with the given rate limit. A handler error must
61
+ # never break the caller's request, so it is rescued and warned rather
62
+ # than raised. Parsing happens before this call, so a parsing bug is not
63
+ # misattributed to the handler.
64
+ #
65
+ # @param handler [#call, nil] the configured rate limit handler
66
+ # @param rate_limit [Auth0::Internal::Http::RateLimit]
67
+ # @return [void]
68
+ def self.deliver(handler, rate_limit)
69
+ return if handler.nil?
70
+
71
+ handler.call(rate_limit)
72
+ rescue StandardError => e
73
+ warn "[auth0] rate_limit_handler raised #{e.class}: #{e.message}"
74
+ end
75
+
76
+ # @param limit [String, nil] raw `x-ratelimit-limit` value
77
+ # @param remaining [String, nil] raw `x-ratelimit-remaining` value
78
+ # @param reset [String, nil] raw `x-ratelimit-reset` value
79
+ # @return [Auth0::Internal::Http::RateLimit]
80
+ def self.build(limit, remaining, reset)
81
+ reset_epoch = to_integer(reset)
82
+
83
+ new(
84
+ limit: to_integer(limit),
85
+ remaining: to_integer(remaining),
86
+ reset: reset_epoch.nil? ? nil : Time.at(reset_epoch).utc
87
+ )
88
+ end
89
+ private_class_method :build
90
+
91
+ # Parse an integer header value, returning nil for blank or non-numeric
92
+ # input (so a malformed header is never silently reported as 0).
93
+ #
94
+ # @param value [String, nil] the raw header value
95
+ # @return [Integer, nil]
96
+ def self.to_integer(value)
97
+ Integer(value.to_s.strip, exception: false)
98
+ end
99
+ private_class_method :to_integer
100
+ end
101
+ end
102
+ end
103
+ end
@@ -3,6 +3,8 @@
3
3
  # This file was auto-generated by Fern from our API Definition.
4
4
  # Modified by Auth0 to use Auth0 telemetry format with dynamic versioning.
5
5
 
6
+ require_relative "rate_limit"
7
+
6
8
  module Auth0
7
9
  module Internal
8
10
  module Http
@@ -20,14 +22,21 @@ module Auth0
20
22
  # @return [String] The base URL for requests
21
23
  attr_reader :base_url
22
24
 
25
+ # @return [#call, nil] Optional callback invoked with an
26
+ # {Auth0::Internal::Http::RateLimit} after every response.
27
+ attr_accessor :rate_limit_handler
28
+
23
29
  # @param base_url [String] The base url for the request.
24
30
  # @param max_retries [Integer] The number of times to retry a failed request, defaults to 2.
25
31
  # @param timeout [Float] The timeout for the request, defaults to 60.0 seconds.
26
32
  # @param headers [Hash] The headers for the request.
27
- def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {})
33
+ # @param rate_limit_handler [#call, nil] Optional callback invoked with the
34
+ # parsed rate limit (from the `x-ratelimit-*` headers) after every response.
35
+ def initialize(base_url:, max_retries: 2, timeout: 60.0, headers: {}, rate_limit_handler: nil)
28
36
  @base_url = base_url
29
37
  @max_retries = max_retries
30
38
  @timeout = timeout
39
+ @rate_limit_handler = rate_limit_handler
31
40
 
32
41
  # Auth0 telemetry in standard format
33
42
  telemetry = {
@@ -45,7 +54,7 @@ module Auth0
45
54
  end
46
55
 
47
56
  # @param request [Auth0::Internal::Http::BaseRequest] The HTTP request.
48
- # @return [HTTP::Response] The HTTP response.
57
+ # @return [Net::HTTPResponse] The HTTP response.
49
58
  def send(request)
50
59
  url = build_url(request)
51
60
  attempt = 0
@@ -67,6 +76,9 @@ module Auth0
67
76
 
68
77
  response = conn.request(http_request)
69
78
 
79
+ # Report rate limit on every response, including retried 429s.
80
+ RateLimit.deliver(@rate_limit_handler, RateLimit.from_http_response(response)) if @rate_limit_handler
81
+
70
82
  break unless should_retry?(response, attempt)
71
83
 
72
84
  delay = retry_delay(response, attempt)
@@ -1,13 +1,14 @@
1
1
  require "addressable/uri"
2
2
  require "retryable"
3
3
  require_relative "../exception.rb"
4
+ require_relative "../internal/http/rate_limit"
4
5
 
5
6
  module Auth0
6
7
  module Mixins
7
8
  # here's the proxy for Rest calls based on rest-client, we're building all request on that gem
8
9
  # for now, if you want to feel free to use your own http client
9
10
  module HTTPProxy
10
- attr_accessor :headers, :base_uri, :timeout, :retry_count
11
+ attr_accessor :headers, :base_uri, :timeout, :retry_count, :rate_limit_handler
11
12
  DEFAULT_RETRIES = 3
12
13
  MAX_ALLOWED_RETRIES = 10
13
14
  MAX_REQUEST_RETRY_JITTER = 250
@@ -95,6 +96,13 @@ module Auth0
95
96
  call(method, encode_uri(uri), timeout, headers, body.to_json)
96
97
  end
97
98
 
99
+ # Surface rate limit for each response, including 429 retries. `call`
100
+ # returns nil for some errors (e.g. a dropped connection), so skip it then.
101
+ if @rate_limit_handler && !result.nil?
102
+ rate_limit = Auth0::Internal::Http::RateLimit.from_headers(result.headers)
103
+ Auth0::Internal::Http::RateLimit.deliver(@rate_limit_handler, rate_limit)
104
+ end
105
+
98
106
  case result.code
99
107
  when 200...226 then safe_parse_json(result.body)
100
108
  when 400 then raise Auth0::BadRequest.new(result.body, code: result.code, headers: result.headers)
@@ -21,6 +21,11 @@ module Auth0
21
21
  @management_timeout = options[:management_timeout]
22
22
  @management_max_retries = options[:management_max_retries]
23
23
  @management_additional_headers = options[:management_additional_headers]
24
+ handler = options[:rate_limit_handler]
25
+ raise ArgumentError, "rate_limit_handler must respond to #call" if handler && !handler.respond_to?(:call)
26
+
27
+ @rate_limit_handler = handler
28
+
24
29
  extend Auth0::Api::AuthenticationEndpoints
25
30
 
26
31
  @client_id = options[:client_id]
@@ -0,0 +1,198 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Auth0
4
+ module Portals
5
+ class Client
6
+ # @param client [Auth0::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # @param request_options [Hash]
14
+ # @param _params [Hash]
15
+ # @option request_options [String] :base_url
16
+ # @option request_options [Hash{String => Object}] :additional_headers
17
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
18
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
19
+ # @option request_options [Integer] :timeout_in_seconds
20
+ #
21
+ # @example
22
+ # client.portals.list
23
+ #
24
+ # @return [Auth0::Types::ListPortalsResponseContent]
25
+ def list(request_options: {}, **_params)
26
+ request = Auth0::Internal::JSON::Request.new(
27
+ base_url: request_options[:base_url],
28
+ method: "GET",
29
+ path: "portals",
30
+ request_options: request_options
31
+ )
32
+ begin
33
+ response = @client.send(request)
34
+ rescue Net::HTTPRequestTimeout
35
+ raise Auth0::Errors::TimeoutError
36
+ end
37
+ code = response.code.to_i
38
+ if code.between?(200, 299)
39
+ (response.body.to_s.empty? ? nil : Auth0::Types::ListPortalsResponseContent.load(response.body))
40
+ else
41
+ error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
42
+ raise error_class.new(response.body, code: code)
43
+ end
44
+ end
45
+
46
+ # @param request_options [Hash]
47
+ # @param params [Auth0::Portals::Types::CreatePortalRequestContent]
48
+ # @option request_options [String] :base_url
49
+ # @option request_options [Hash{String => Object}] :additional_headers
50
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
51
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
52
+ # @option request_options [Integer] :timeout_in_seconds
53
+ #
54
+ # @example
55
+ # client.portals.create(
56
+ # slug: "slug",
57
+ # name: "name",
58
+ # client: {
59
+ # token_endpoint_auth_method: "client_secret_post",
60
+ # client_id: "client_id",
61
+ # client_secret: "client_secret"
62
+ # }
63
+ # )
64
+ #
65
+ # @return [Auth0::Types::Portal]
66
+ def create(request_options: {}, **params)
67
+ params = Auth0::Internal::Types::Utils.normalize_keys(params)
68
+ request = Auth0::Internal::JSON::Request.new(
69
+ base_url: request_options[:base_url],
70
+ method: "POST",
71
+ path: "portals",
72
+ body: Auth0::Portals::Types::CreatePortalRequestContent.new(params).to_h,
73
+ request_options: request_options
74
+ )
75
+ begin
76
+ response = @client.send(request)
77
+ rescue Net::HTTPRequestTimeout
78
+ raise Auth0::Errors::TimeoutError
79
+ end
80
+ code = response.code.to_i
81
+ if code.between?(200, 299)
82
+ (response.body.to_s.empty? ? nil : Auth0::Types::Portal.load(response.body))
83
+ else
84
+ error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
85
+ raise error_class.new(response.body, code: code)
86
+ end
87
+ end
88
+
89
+ # @param request_options [Hash]
90
+ # @param params [Hash]
91
+ # @option request_options [String] :base_url
92
+ # @option request_options [Hash{String => Object}] :additional_headers
93
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
94
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
95
+ # @option request_options [Integer] :timeout_in_seconds
96
+ # @option params [Auth0::Types::PortalID] :id
97
+ #
98
+ # @example
99
+ # client.portals.get(id: "id")
100
+ #
101
+ # @return [Auth0::Types::Portal]
102
+ def get(request_options: {}, **params)
103
+ params = Auth0::Internal::Types::Utils.normalize_keys(params)
104
+ request = Auth0::Internal::JSON::Request.new(
105
+ base_url: request_options[:base_url],
106
+ method: "GET",
107
+ path: "portals/#{URI.encode_uri_component(params[:id].to_s)}",
108
+ request_options: request_options
109
+ )
110
+ begin
111
+ response = @client.send(request)
112
+ rescue Net::HTTPRequestTimeout
113
+ raise Auth0::Errors::TimeoutError
114
+ end
115
+ code = response.code.to_i
116
+ if code.between?(200, 299)
117
+ (response.body.to_s.empty? ? nil : Auth0::Types::Portal.load(response.body))
118
+ else
119
+ error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
120
+ raise error_class.new(response.body, code: code)
121
+ end
122
+ end
123
+
124
+ # @param request_options [Hash]
125
+ # @param params [Hash]
126
+ # @option request_options [String] :base_url
127
+ # @option request_options [Hash{String => Object}] :additional_headers
128
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
129
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
130
+ # @option request_options [Integer] :timeout_in_seconds
131
+ # @option params [Auth0::Types::PortalID] :id
132
+ #
133
+ # @example
134
+ # client.portals.delete(id: "id")
135
+ #
136
+ # @return [untyped]
137
+ def delete(request_options: {}, **params)
138
+ params = Auth0::Internal::Types::Utils.normalize_keys(params)
139
+ request = Auth0::Internal::JSON::Request.new(
140
+ base_url: request_options[:base_url],
141
+ method: "DELETE",
142
+ path: "portals/#{URI.encode_uri_component(params[:id].to_s)}",
143
+ request_options: request_options
144
+ )
145
+ begin
146
+ response = @client.send(request)
147
+ rescue Net::HTTPRequestTimeout
148
+ raise Auth0::Errors::TimeoutError
149
+ end
150
+ code = response.code.to_i
151
+ return if code.between?(200, 299)
152
+
153
+ error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
154
+ raise error_class.new(response.body, code: code)
155
+ end
156
+
157
+ # @param request_options [Hash]
158
+ # @param params [Auth0::Portals::Types::UpdatePortalRequestContent]
159
+ # @option request_options [String] :base_url
160
+ # @option request_options [Hash{String => Object}] :additional_headers
161
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
162
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
163
+ # @option request_options [Integer] :timeout_in_seconds
164
+ # @option params [Auth0::Types::PortalID] :id
165
+ #
166
+ # @example
167
+ # client.portals.update(id: "id")
168
+ #
169
+ # @return [Auth0::Types::Portal]
170
+ def update(request_options: {}, **params)
171
+ params = Auth0::Internal::Types::Utils.normalize_keys(params)
172
+ request_data = Auth0::Portals::Types::UpdatePortalRequestContent.new(params).to_h
173
+ non_body_param_names = %w[id]
174
+ body = request_data.except(*non_body_param_names)
175
+
176
+ request = Auth0::Internal::JSON::Request.new(
177
+ base_url: request_options[:base_url],
178
+ method: "PATCH",
179
+ path: "portals/#{URI.encode_uri_component(params[:id].to_s)}",
180
+ body: body,
181
+ request_options: request_options
182
+ )
183
+ begin
184
+ response = @client.send(request)
185
+ rescue Net::HTTPRequestTimeout
186
+ raise Auth0::Errors::TimeoutError
187
+ end
188
+ code = response.code.to_i
189
+ if code.between?(200, 299)
190
+ (response.body.to_s.empty? ? nil : Auth0::Types::Portal.load(response.body))
191
+ else
192
+ error_class = Auth0::Errors::ResponseError.subclass_for_code(code)
193
+ raise error_class.new(response.body, code: code)
194
+ end
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Auth0
4
+ module Portals
5
+ module Types
6
+ class CreatePortalRequestContent < Internal::Types::Model
7
+ field :slug, -> { String }, optional: false, nullable: false
8
+
9
+ field :name, -> { String }, optional: false, nullable: false
10
+
11
+ field :client, -> { Auth0::Types::PortalClientSecretPostRequest }, optional: false, nullable: false
12
+
13
+ field :navigation, -> { Auth0::Types::PortalNavigation }, optional: true, nullable: false
14
+
15
+ field :pages, -> { Auth0::Types::PortalPagesByType }, optional: true, nullable: false
16
+
17
+ field :custom_code, -> { Auth0::Types::PortalCustomCode }, optional: true, nullable: false
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Auth0
4
+ module Portals
5
+ module Types
6
+ class UpdatePortalRequestContent < Internal::Types::Model
7
+ field :id, -> { String }, optional: false, nullable: false
8
+
9
+ field :slug, -> { String }, optional: true, nullable: false
10
+
11
+ field :name, -> { String }, optional: true, nullable: false
12
+
13
+ field :client, -> { Auth0::Types::PortalClientSecretPostRequest }, optional: true, nullable: false
14
+
15
+ field :navigation, -> { Auth0::Types::PortalNavigation }, optional: true, nullable: false
16
+
17
+ field :pages, -> { Auth0::Types::PortalPagesByType }, optional: true, nullable: false
18
+
19
+ field :custom_code, -> { Auth0::Types::PortalCustomCode }, optional: true, nullable: false
20
+ end
21
+ end
22
+ end
23
+ end
@@ -45,6 +45,10 @@ module Auth0
45
45
  field :subject_type_authorization, -> { Auth0::Types::ResourceServerSubjectTypeAuthorization }, optional: true, nullable: false
46
46
 
47
47
  field :authorization_policy, -> { Auth0::Types::ResourceServerAuthorizationPolicy }, optional: true, nullable: false
48
+
49
+ field :agent_subject_claims, -> { Auth0::Types::ResourceServerAgentSubjectClaimsSchemaEnum }, optional: true, nullable: false
50
+
51
+ field :type, -> { Auth0::Types::ResourceServerTypeEnum }, optional: true, nullable: false
48
52
  end
49
53
  end
50
54
  end
@@ -45,6 +45,10 @@ module Auth0
45
45
  field :subject_type_authorization, -> { Auth0::Types::ResourceServerSubjectTypeAuthorization }, optional: true, nullable: false
46
46
 
47
47
  field :authorization_policy, -> { Auth0::Types::ResourceServerAuthorizationPolicy }, optional: true, nullable: false
48
+
49
+ field :agent_subject_claims, -> { Auth0::Types::ResourceServerAgentSubjectClaimsSchemaEnum }, optional: true, nullable: false
50
+
51
+ field :type, -> { Auth0::Types::ResourceServerTypeEnum }, optional: true, nullable: false
48
52
  end
49
53
  end
50
54
  end
@@ -25,6 +25,8 @@ module Auth0
25
25
 
26
26
  field :third_party_client_access_config, -> { Auth0::Types::ThirdPartyClientAccessConfig }, optional: true, nullable: false
27
27
 
28
+ field :universal_logout_config, -> { Auth0::Types::SelfServiceProfileSSOTicketUniversalLogoutConfig }, optional: true, nullable: false
29
+
28
30
  field :enabled_features, -> { Auth0::Types::SelfServiceProfileSSOTicketEnabledFeatures }, optional: true, nullable: false
29
31
  end
30
32
  end