Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support PhoneNumber as a flexible identifier #746

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Auth0.AuthenticationApi/Models/SignupUserRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,11 @@ public class SignupUserRequest : UserMaintenanceRequestBase
/// </summary>
[JsonProperty("user_metadata")]
public dynamic UserMetadata { get; set; }

/// <summary>
/// The user's phone number.
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }
}
}
6 changes: 6 additions & 0 deletions src/Auth0.AuthenticationApi/Models/SignupUserResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,11 @@ public string Id
/// </summary>
[JsonProperty("user_metadata")]
public dynamic UserMetadata { get; set; }

/// <summary>
/// The user's phone number.
/// </summary>
[JsonProperty("phone_number")]
public string PhoneNumber { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Newtonsoft.Json;

using Auth0.ManagementApi.Models.Connections;
namespace Auth0.ManagementApi.Models
{
/// <summary>
Expand All @@ -24,5 +24,9 @@ public class Connection : ConnectionBase
/// </summary>
[JsonProperty("provisioning_ticket_url")]
public string ProvisioningTicketUrl { get; set; }

/// <inheritdoc cref="ConnectionOptions"/>
[JsonProperty("options")]
public dynamic Options { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Auth0.ManagementApi.Models.Connections;
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
Expand Down Expand Up @@ -27,13 +28,7 @@ public abstract class ConnectionBase
/// </summary>
[JsonProperty("metadata")]
public dynamic Metadata { get; set; }

/// <summary>
/// The options for the connection.
/// </summary>
[JsonProperty("options")]
public dynamic Options { get; set; }


/// <summary>
/// Defines the realms for which the connection will be used (ie: email domains). If the array is empty or the property is not specified, the connection name will be added as realm. Maximum of 10 items.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Auth0.ManagementApi.Models.Connections;
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
Expand All @@ -15,5 +16,9 @@ public class ConnectionCreateRequest : ConnectionBase
/// </summary>
[JsonProperty("strategy")]
public string Strategy { get; set; }

/// <inheritdoc cref="ConnectionOptions"/>
[JsonProperty("options")]
public dynamic Options { get; set; }
}
}
125 changes: 125 additions & 0 deletions src/Auth0.ManagementApi/Models/Connections/ConnectionOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
using System.Collections.Specialized;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
/// The connection's options.
/// </summary>
public class ConnectionOptions
{
/// <inheritdoc cref="ConnectionOptionsValidation"/>
[JsonProperty("validation")]
public ConnectionOptionsValidation Validation { get; set; }

/// <summary>
/// An array of user fields that should not be stored in the Auth0 database
/// <a href="https://auth0.com/docs/security/data-security/denylist">https://auth0.com/docs/security/data-security/denylist</a>
/// </summary>
[JsonProperty("non_persistent_attrs")]
public string[] NonPersistentAttributes { get; set; }

/// <summary>
/// Order of precedence for attribute types. If the property is not specified,
/// the default precedence of attributes will be used.
/// </summary>
[JsonProperty("precedence", ItemConverterType = typeof(StringEnumConverter))]
public ConnectionOptionsPrecedence[] Precedence { get; set; }

/// <inheritdoc cref="ConnectionOptionsAttributes"/>
[JsonProperty("attributes")]
public ConnectionOptionsAttributes Attributes { get; set; }

[JsonProperty("enable_script_context")]
public bool? EnableScriptContext { get; set; }

/// <summary>
/// Set to true to use a legacy user store
/// </summary>
[JsonProperty("enabledDatabaseCustomization")]
public bool? EnableDatabaseCustomization { get; set; }

/// <summary>
/// Enable this if you have a legacy user store and you want to gradually migrate
/// those users to the Auth0 user store
/// </summary>
[JsonProperty("import_mode")]
public bool? ImportMode { get; set; }

/// <inheritdoc cref="ConnectionOptionsCustomScripts"/>
[JsonProperty("customScripts")]
public ConnectionOptionsCustomScripts CustomScripts { get; set; }

/// <inheritdoc cref="ConnectionOptionsAuthenticationMethods"/>
[JsonProperty("authentication_methods")]
public ConnectionOptionsAuthenticationMethods AuthenticationMethods { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasskeyOptions"/>
[JsonProperty("passkey_options")]
public ConnectionOptionsPasskeyOptions PasskeyOptions { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasswordPolicy"/>
[JsonProperty("passwordPolicy")]
[JsonConverter(typeof(StringEnumConverter))]
public ConnectionOptionsPasswordPolicy? PasswordPolicy { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasswordComplexityOptions"/>
[JsonProperty("password_complexity_options")]
public ConnectionOptionsPasswordComplexityOptions PasswordComplexityOptions { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasswordHistory"/>
[JsonProperty("password_history")]
public ConnectionOptionsPasswordHistory PasswordHistory { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasswordNoPersonalInfo"/>
[JsonProperty("password_no_personal_info")]
public ConnectionOptionsPasswordNoPersonalInfo PasswordNoPersonalInfo { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasswordNoPersonalInfo"/>
[JsonProperty("password_dictionary")]
public ConnectionOptionsPasswordDictionary PasswordDictionary { get; set; }

[JsonProperty("api_enable_users")]
public bool? ApiEnableUsers { get; set; }

[JsonProperty("basic_profile")]
public bool? BasicProfile { get; set; }

[JsonProperty("ext_admin")]
public bool? ExtAdmin { get; set; }

[JsonProperty("ext_is_suspended")]
public bool? ExtIsSuspended { get; set; }

[JsonProperty("ext_agreed_terms")]
public bool? ExtAgreedTerms { get; set; }

[JsonProperty("ext_groups")]
public bool? ExtGroups { get; set; }

[JsonProperty("ext_assigned_plans")]
public bool? ExtAssignedPlans { get; set; }

[JsonProperty("ext_profile")]
public bool? ExtProfile { get; set; }

[JsonProperty("disable_self_service_change_password")]
public bool? DisableSelfServiceChangePassword { get; set; }

/// <summary>
/// Options for adding parameters in the request to the upstream IdP
/// </summary>
[JsonProperty("upstream_params")]
public dynamic UpstreamParams { get; set; }

/// <inheritdoc cref="Auth0.ManagementApi.Models.Connections.SetUserRootAttributes"/>
[JsonProperty("set_user_root_attributes")]
[JsonConverter(typeof(StringEnumConverter))]
public SetUserRootAttributes? SetUserRootAttributes { get; set; }

/// <inheritdoc cref="Auth0.ManagementApi.Models.Connections.SetUserRootAttributes"/>
[JsonProperty("gateway_authentication")]
public GatewayAuthentication GatewayAuthentication { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
///
/// </summary>
public class ConnectionOptionsAttributeBase
{
[JsonProperty("identifier")]
public ConnectionOptionsAttributeIdentifier Identifier { get; set; }

/// <summary>
/// Determines if property should be required for users
/// </summary>
[JsonProperty("profile_required")]
public bool? ProfileRequired { get; set; }
}

public class ConnectionOptionsAttributeIdentifier
{
/// <summary>
/// Determines if the attribute is used for identification
/// </summary>
[JsonProperty("active")]
public bool? Active { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
/// Attribute Validation
/// </summary>
public class ConnectionOptionsAttributeValidation
{
/// <summary>
/// Minimum allowed length
/// </summary>
[JsonProperty("min_length")]
public int MinLength { get; set; }

/// <summary>
/// Maximum allowed length
/// </summary>
[JsonProperty("max_length")]
public int MaxLength { get; set; }

[JsonProperty("allowed_types")]
public ConnectionOptionsAttributeAllowedTypes AllowedTypes { get; set; }
}

public class ConnectionOptionsAttributeAllowedTypes
{
[JsonProperty("email")]
public bool? Email { get; set; }

[JsonProperty("phone_number")]
public bool? PhoneNumber { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
/// Attribute Configuration
/// </summary>
public class ConnectionOptionsAttributes
{
/// <inheritdoc cref="ConnectionOptionsEmailAttribute"/>
[JsonProperty("email")]
public ConnectionOptionsEmailAttribute Email { get; set; }

/// <inheritdoc cref="ConnectionOptionsPhoneNumberAttribute"/>
[JsonProperty("phone_number")]
public ConnectionOptionsPhoneNumberAttribute PhoneNumber { get; set; }

/// <inheritdoc cref="ConnectionOptionsUsernameAttribute"/>
[JsonProperty("username")]
public ConnectionOptionsUsernameAttribute Username { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
/// Options for enabling authentication methods.
/// </summary>
public class ConnectionOptionsAuthenticationMethods
{
/// <inheritdoc cref="ConnectionOptionsPasswordAuthenticationMethod"/>
[JsonProperty("password")]
public ConnectionOptionsPasswordAuthenticationMethod Password { get; set; }

/// <inheritdoc cref="ConnectionOptionsPasskeyAuthenticationMethod"/>
[JsonProperty("passkey")]
public ConnectionOptionsPasskeyAuthenticationMethod Passkey { get; set; }
}

public class ConnectionOptionsAuthenticationMethodsBase
{
[JsonProperty("enabled")]
public bool? Enabled { get; set; }
}

/// <summary>
/// Password authentication enablement
/// </summary>
public class ConnectionOptionsPasswordAuthenticationMethod : ConnectionOptionsAuthenticationMethodsBase
{

}

/// <summary>
/// Passkey authentication enablement
/// </summary>
public class ConnectionOptionsPasskeyAuthenticationMethod : ConnectionOptionsAuthenticationMethodsBase
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models.Connections
{
/// <summary>
/// A map of scripts used to integrate with a custom database.
/// </summary>
public class ConnectionOptionsCustomScripts
{
[JsonProperty("login")]
public string Login { get; set; }

[JsonProperty("get_user")]
public string GetUser { get; set; }

[JsonProperty("delete")]
public string Delete { get; set; }

[JsonProperty("change_password")]
public string ChangePassword { get; set; }

[JsonProperty("verify")]
public string Verify { get; set; }

[JsonProperty("create")]
public string Create { get; set; }

[JsonProperty("change_username")]
public string ChangeUsername { get; set; }

[JsonProperty("change_email")]
public string ChangeEmail { get; set; }

[JsonProperty("change_phone_number")]
public string ChangePhoneNumber { get; set; }
}
}
Loading
Loading