Skip to content

Commit

Permalink
Add support for /guardian end-points (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
kailash-b authored Jan 24, 2025
2 parents 1817b83 + 4116f38 commit e6c84e4
Show file tree
Hide file tree
Showing 13 changed files with 717 additions and 65 deletions.
264 changes: 220 additions & 44 deletions src/Auth0.ManagementApi/Clients/GuardianClient.cs

Large diffs are not rendered by default.

155 changes: 147 additions & 8 deletions src/Auth0.ManagementApi/Clients/IGuardianClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public interface IGuardianClient
Task<GuardianEnrollment> GetEnrollmentAsync(string id, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves all factors. Useful to check factor enablement and trial status.
/// Retrieve details of all
/// <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors">
/// multi-factor authentication factors associated with your tenant </a>.
/// </summary>
/// <returns>List of <see cref="GuardianFactor" /> instances with the available factors.</returns>
Task<IList<GuardianFactor>> GetFactorsAsync(CancellationToken cancellationToken = default);
Expand All @@ -52,7 +54,10 @@ public interface IGuardianClient
Task<GuardianSnsConfiguration> GetSnsConfigurationAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Returns configuration for the Guardian Twilio provider.
/// Retrieve configuration details for a Twilio phone provider that has been set up in your tenant.
/// To learn more, review
/// <a href ="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa">
/// Configure SMS and Voice Notifications for MFA. </a>
/// </summary>
/// <returns><see cref="GuardianTwilioConfiguration" /> with the Twilio configuration.</returns>
Task<GuardianTwilioConfiguration> GetTwilioConfigurationAsync(CancellationToken cancellationToken = default);
Expand All @@ -74,28 +79,162 @@ public interface IGuardianClient
Task<GuardianSmsEnrollmentTemplates> UpdateSmsTemplatesAsync(GuardianSmsEnrollmentTemplates templates, CancellationToken cancellationToken = default);

/// <summary>
/// Configure the Guardian Twilio provider.
/// Update the configuration of a Twilio phone provider that has been set up in your tenant.
/// To learn more, review
/// <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa">
/// Configure SMS and Voice Notifications for MFA.</a>
/// </summary>
/// <param name="request">
/// The <see cref="UpdateGuardianTwilioConfigurationRequest" /> containing the configuration settings.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <param name="cancellationToken"><see cref="CancellationToken"/> - The cancellation token to cancel operation.</param>
/// <returns>The <see cref="GuardianTwilioConfiguration" /> containing the updated configuration settings.</returns>
Task<GuardianTwilioConfiguration> UpdateTwilioConfigurationAsync(UpdateGuardianTwilioConfigurationRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve the enabled phone factors for multi-factor authentication
/// Retrieve list of
/// <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa">
/// phone-type MFA factors </a> (i.e., sms and voice) that are enabled for your tenant.
/// </summary>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <returns>A <see cref="GuardianPhoneMessageTypes" /> containing the message types.</returns>
Task<GuardianPhoneMessageTypes> GetPhoneMessageTypesAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Update enabled phone factors for multi-factor authentication
/// Replace the list of
/// <a href="https://auth0.com/docs/secure/multi-factor-authentication/multi-factor-authentication-factors/configure-sms-voice-notifications-mfa">
/// phone-type MFA factors </a> (i.e., sms and voice) that are enabled for your tenant.
/// </summary>
/// <param name="messageTypes">A <see cref="GuardianPhoneMessageTypes" /> containing the list of phone factors to enable on the tenan.</param>
/// <param name="cancellationToken">The cancellation token to cancel operation.</param>
/// <param name="messageTypes">A <see cref="GuardianPhoneMessageTypes" /> containing the list of phone factors to enable on the tenant.</param>
/// <param name="cancellationToken"><see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="GuardianPhoneMessageTypes" /> containing the message types.</returns>
Task<GuardianPhoneMessageTypes> UpdatePhoneMessageTypesAsync(GuardianPhoneMessageTypes messageTypes, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieves the DUO account and factor configuration.
/// </summary>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="DuoConfiguration"/> containing the Duo configuration</returns>
Task<DuoConfiguration> GetDuoConfigurationAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Update the DUO Configuration using PATCH
/// </summary>
/// <param name="configuration"><see cref="DuoConfigurationPatchRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns><see cref="DuoConfiguration"/> containing the updated configuration</returns>
Task<DuoConfiguration> UpdateDuoConfigurationAsync(
DuoConfigurationPatchRequest configuration, CancellationToken cancellationToken = default);

/// <summary>
/// Update the DUO Configuration using PUT
/// </summary>
/// <param name="configuration"><see cref="DuoConfigurationPatchRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns><see cref="DuoConfiguration"/> containing the updated configuration</returns>
Task<DuoConfiguration> UpdateDuoConfigurationAsync(
DuoConfigurationPutRequest configuration, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve details of the multi-factor authentication phone provider configured for your tenant.
/// </summary>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns><see cref="PhoneProviderConfiguration"/></returns>
Task<PhoneProviderConfiguration> GetPhoneProviderConfigurationAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Update Phone provider configuration.
/// </summary>
/// <param name="phoneProviderConfiguraiton"><see cref="PhoneProviderConfiguration"/> - Containing the configuration information to be updated</param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns><see cref="PhoneProviderConfiguration"/></returns>
Task<PhoneProviderConfiguration> UpdatePhoneProviderConfigurationAsync(PhoneProviderConfiguration phoneProviderConfiguraiton, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve details of the multi-factor authentication enrollment and verification templates for
/// phone-type factors available in your tenant.
/// </summary>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="GuardianPhoneEnrollmentTemplate" /> containing the templates.</returns>
Task<GuardianPhoneEnrollmentTemplate> GetPhoneEnrollmentTemplateAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Customize the messages sent to complete phone enrollment and verification (subscription required).
/// </summary>
/// <param name="phoneEnrollmentTemplate">A <see cref="GuardianPhoneEnrollmentTemplate" /> containing the template to be udpated.</param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="GuardianPhoneEnrollmentTemplate" /> containing the templates.</returns>
Task<GuardianPhoneEnrollmentTemplate> UpdatePhoneEnrollmentTemplateAsync(GuardianPhoneEnrollmentTemplate phoneEnrollmentTemplate, CancellationToken cancellationToken = default);

/// <summary>
/// Retrieve configuration details for the multi-factor authentication APNS provider associated with your tenant.
/// </summary>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="PushNotificationApnsConfiguration"/> containing the details regarding APNS Push Notification Provider configuration.</returns>
Task<PushNotificationApnsConfiguration> GetPushNotificationApnsProviderConfigurationAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Overwrite all configuration details of the multi-factor authentication APNS provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="PushNotificationApnsConfigurationPutUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="PushNotificationApnsConfigurationUpdateResponse"/></returns>
Task<PushNotificationApnsConfigurationUpdateResponse> UpdatePushNotificationApnsProviderConfigurationAsync(
PushNotificationApnsConfigurationPutUpdateRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Modify configuration details of the multi-factor authentication APNS provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="PushNotificationApnsConfigurationPatchUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>A <see cref="PushNotificationApnsConfigurationUpdateResponse"/></returns>
Task<PushNotificationApnsConfigurationUpdateResponse> UpdatePushNotificationApnsProviderConfigurationAsync(
PushNotificationApnsConfigurationPatchUpdateRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Modify configuration details of the multi-factor authentication FCM provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="FcmConfigurationPatchUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>An <see cref="object"/> containing information about the FCM configuration</returns>
Task<object> UpdatePushNotificationFcmConfigurationAsync(FcmConfigurationPatchUpdateRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Overwrite all configuration details of the multi-factor authentication FCM provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="FcmConfigurationPutUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns></returns>
Task<object> UpdatePushNotificationFcmConfigurationAsync(FcmConfigurationPutUpdateRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Modify configuration details of the multi-factor authentication FCMV1 provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="FcmV1ConfigurationPatchUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>An <see cref="object"/> containing information about the FCMV1 configuration</returns>
Task<object> UpdatePushNotificationFcmV1ConfigurationAsync(FcmV1ConfigurationPatchUpdateRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Overwrite all configuration details of the multi-factor authentication FCMV1 provider associated with your tenant.
/// </summary>
/// <param name="request"><see cref="FcmV1ConfigurationPutUpdateRequest"/></param>
/// <param name="cancellationToken">
/// <see cref="CancellationToken"/> The cancellation token to cancel operation.</param>
/// <returns>An <see cref="object"/> containing information about the FCMV1 configuration</returns>
Task<object> UpdatePushNotificationFcmV1ConfigurationAsync(FcmV1ConfigurationPutUpdateRequest request, CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@ public class CreateGuardianEnrollmentTicketRequest
/// </summary>
[JsonProperty("user_id")]
public string UserId { get; set; }

/// <summary>
/// Optional. Specify the locale of the enrollment email. Used with send_email.
/// </summary>
[JsonProperty("email_locale")]
public string EmailLocale { get; set; }
}
}
16 changes: 16 additions & 0 deletions src/Auth0.ManagementApi/Models/Guardian/DuoConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
public class DuoConfiguration
{
[JsonProperty("ikey")]
public string Ikey { get; set; }

[JsonProperty("skey")]
public string Skey { get; set; }

[JsonProperty("host")]
public string Host { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Auth0.ManagementApi.Models
{
public class DuoConfigurationPatchRequest : DuoConfiguration
{

}

public class DuoConfigurationPutRequest : DuoConfiguration
{

}
}
18 changes: 18 additions & 0 deletions src/Auth0.ManagementApi/Models/Guardian/FcmConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
public class FcmConfigurationUpdateRequestBase
{
[JsonProperty("server_key")]
public string ServerKey { get; set; }
}

public class FcmConfigurationPatchUpdateRequest : FcmConfigurationUpdateRequestBase
{
}

public class FcmConfigurationPutUpdateRequest : FcmConfigurationUpdateRequestBase
{
}
}
18 changes: 18 additions & 0 deletions src/Auth0.ManagementApi/Models/Guardian/FcmV1Configuration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
public class FcmV1ConfigurationUpdateRequestBase
{
[JsonProperty("server_credentials")]
public string ServerCredentials { get; set; }
}

public class FcmV1ConfigurationPatchUpdateRequest : FcmV1ConfigurationUpdateRequestBase
{
}

public class FcmV1ConfigurationPutUpdateRequest : FcmV1ConfigurationUpdateRequestBase
{
}
}
4 changes: 2 additions & 2 deletions src/Auth0.ManagementApi/Models/Guardian/GuardianFactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Auth0.ManagementApi.Models
public class GuardianFactor
{
/// <summary>
/// States if this factor is enabled.
/// Whether this factor is enabled (true) or disabled (false).
/// </summary>
[JsonProperty("enabled")]
public bool Enabled { get; set; }
Expand All @@ -21,7 +21,7 @@ public class GuardianFactor
public GuardianFactorName? Name { get; set; }

/// <summary>
/// For factors with trial limits (e.g. SMS) states if those limits have been exceeded.
/// Whether trial limits have been exceeded.
/// </summary>
[JsonProperty("trial_expired")]
public bool? IsTrialExpired { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
public class GuardianPhoneEnrollmentTemplate
{
/// <summary>
/// Message sent to the user when they are invited to enroll with a phone number.
/// </summary>
[JsonProperty("enrollment_message")]
public string EnrollmentMessage { get; set; }

/// <summary>
/// Message sent to the user when they are prompted to verify their account.
/// </summary>
[JsonProperty("verification_message")]
public string VerificationMessage { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Auth0.ManagementApi.Models
{
public class PhoneProviderConfiguration
{
[JsonProperty("provider")]
[JsonConverter(typeof(StringEnumConverter))]
public Provider Provider { get; set; }
}

public enum Provider
{
[EnumMember(Value = "auth0")]
Auth0,

[EnumMember(Value = "twilio")]
Twilio,

[EnumMember(Value = "phone-message-hook")]
PhoneMessageHook,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;

namespace Auth0.ManagementApi.Models
{
public class PushNotificationApnsConfiguration
{
[JsonProperty("bundle_id")]
public string BundleId { get; set; }

[JsonProperty("sandbox")]
public bool? Sandbox { get; set; }

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

public class PushNotificationApnsConfigurationUpdateResponse
{
[JsonProperty("bundle_id")]
public string BundleId { get; set; }

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

namespace Auth0.ManagementApi.Models
{
public class PushNotificationApnsConfigurationUpdateRequestBase
{
[JsonProperty("bundle_id")]
public string BundleId { get; set; }

[JsonProperty("sandbox")]
public bool? Sandbox { get; set; }

[JsonProperty("p12")]
public string P12 { get; set; }
}

public class
PushNotificationApnsConfigurationPatchUpdateRequest : PushNotificationApnsConfigurationUpdateRequestBase
{

}

public class
PushNotificationApnsConfigurationPutUpdateRequest : PushNotificationApnsConfigurationUpdateRequestBase
{

}
}
Loading

0 comments on commit e6c84e4

Please sign in to comment.