-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for Self-Service-Profile endpoints
- Loading branch information
Showing
19 changed files
with
715 additions
and
3 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
src/Auth0.ManagementApi/Clients/ISelfServiceProfilesClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Auth0.ManagementApi.Models.SelfServiceProfiles; | ||
using Auth0.ManagementApi.Paging; | ||
|
||
namespace Auth0.ManagementApi.Clients | ||
{ | ||
public interface ISelfServiceProfilesClient | ||
{ | ||
/// <summary> | ||
/// Retrieve self-service-profile information. | ||
/// </summary> | ||
/// <param name="pagination"><see cref="PaginationInfo"/></param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/></param> | ||
/// <returns><see cref="IPagedList{T}"/> of <see cref="SelfServiceProfile"/></returns> | ||
Task<IPagedList<SelfServiceProfile>> GetAllAsync(PaginationInfo pagination = null, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Create self-service-profile. | ||
/// </summary> | ||
/// <param name="request"><see cref="SelfServiceProfileCreateRequest"/></param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/></param> | ||
/// <returns><see cref="SelfServiceProfile"/></returns> | ||
Task<SelfServiceProfile> CreateAsync(SelfServiceProfileCreateRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Retrieve self-service-profile by id. | ||
/// </summary> | ||
/// <param name="id">Self-Service-Profile ID</param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/></param> | ||
/// <returns><see cref="SelfServiceProfile"/></returns> | ||
Task<SelfServiceProfile> GetAsync(string id, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Delete a self-service-profile by id. | ||
/// </summary> | ||
/// <param name="id">Self-Service-Profile ID</param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/></param> | ||
Task DeleteAsync(string id, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Retrieve self-service-profile by id. | ||
/// </summary> | ||
/// <param name="id">Self-Service-Profile ID</param> | ||
/// <param name="request"><see cref="SelfServiceProfileUpdateRequest"/></param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/></param> | ||
/// <returns><see cref="SelfServiceProfile"/></returns> | ||
Task<SelfServiceProfile> UpdateAsync(string id, SelfServiceProfileUpdateRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Creates an sso-access ticket to initiate the Self Service SSO Flow using a self-service profile | ||
/// </summary> | ||
/// <param name="id">The id of the sso-profile to retrieve</param> | ||
/// <param name="request"><see cref="SelfServiceSsoTicketCreateRequest"/></param> | ||
/// <param name="cancellationToken"><see cref="CancellationToken"/></param> | ||
/// <returns><see cref="SelfServiceSsoTicket"/></returns> | ||
Task<SelfServiceSsoTicket> CreateSsoTicketAsync(string id, SelfServiceSsoTicketCreateRequest request, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Revokes an SSO access ticket and invalidates associated sessions. | ||
/// The ticket will no longer be accepted to initiate a Self-Service SSO session. | ||
/// If any users have already started a session through this ticket, their session will be terminated. | ||
/// Clients should expect a 202 Accepted response upon successful processing, indicating that the request | ||
/// has been acknowledged and that the revocation is underway but may not be fully completed at the time of response. | ||
/// If the specified ticket does not exist, a 202 Accepted response is also returned, | ||
/// signaling that no further action is required. | ||
/// Clients should treat these 202 responses as an acknowledgment that the request has been accepted and | ||
/// is in progress, even if the ticket was not found. | ||
/// </summary> | ||
/// <param name="ticketId">The id of the ticket to revoke</param> | ||
/// <param name="profileId">The id of the self-service profile</param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/> </param> | ||
/// <returns><see cref="SelfServiceSsoTicket"/></returns> | ||
Task RevokeSsoTicketAsync(string profileId, string ticketId, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Retrieves text customizations for a given self-service profile, language and Self Service SSO Flow page | ||
/// </summary> | ||
/// <param name="id">The id of the self-service profile.</param> | ||
/// <param name="language">The language of the custom text.</param> | ||
/// <param name="page">The page where the custom text is shown.</param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/> </param> | ||
/// <returns>The list of custom text keys and values.</returns> | ||
Task<object> GetCustomTextForSelfServiceProfileAsync(string id, string language, string page, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Updates text customizations for a given self-service profile, language and Self Service SSO Flow page. | ||
/// </summary> | ||
/// <param name="id">The id of the self-service profile.</param> | ||
/// <param name="language">The language of the custom text.</param> | ||
/// <param name="page">The page where the custom text is shown.</param> | ||
/// <param name="body">The list of text keys and values to customize the self-service SSO page. | ||
/// Values can be plain text or rich HTML content limited to basic styling tags and hyperlinks.</param> | ||
/// <param name="cancellationToken"> <see cref="CancellationToken"/> </param> | ||
/// <returns>The resulting list of custom text keys and values.</returns> | ||
Task<object> SetCustomTextForSelfServiceProfileAsync(string id, string language, string page, object body, CancellationToken cancellationToken = default); | ||
} | ||
} |
172 changes: 172 additions & 0 deletions
172
src/Auth0.ManagementApi/Clients/SelfServiceProfilesClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Auth0.ManagementApi.Models.SelfServiceProfiles; | ||
using Auth0.ManagementApi.Paging; | ||
using Newtonsoft.Json; | ||
|
||
namespace Auth0.ManagementApi.Clients | ||
{ | ||
/// <summary> | ||
/// Client to manage Self Service Profiles. | ||
/// </summary> | ||
public class SelfServiceProfilesClient : BaseClient, ISelfServiceProfilesClient | ||
{ | ||
readonly JsonConverter[] converters = { new PagedListConverter<SelfServiceProfile>("self_service_profiles") }; | ||
public SelfServiceProfilesClient( | ||
IManagementConnection connection, | ||
Uri baseUri, | ||
IDictionary<string, string> defaultHeaders) : base(connection, baseUri, defaultHeaders) | ||
{ | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.GetAllAsync"/> | ||
public Task<IPagedList<SelfServiceProfile>> GetAllAsync(PaginationInfo pagination = null, CancellationToken cancellationToken = default) | ||
{ | ||
var queryStrings = new Dictionary<string, string>(); | ||
|
||
if (pagination != null) | ||
{ | ||
queryStrings["page"] = pagination.PageNo.ToString(); | ||
queryStrings["per_page"] = pagination.PerPage.ToString(); | ||
queryStrings["include_totals"] = pagination.IncludeTotals.ToString().ToLower(); | ||
} | ||
|
||
return Connection.GetAsync<IPagedList<SelfServiceProfile>>( | ||
BuildUri("self-service-profiles", queryStrings), | ||
DefaultHeaders, | ||
converters, | ||
cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.CreateAsync"/> | ||
public Task<SelfServiceProfile> CreateAsync(SelfServiceProfileCreateRequest request, CancellationToken cancellationToken = default) | ||
{ | ||
if (request == null) | ||
throw new ArgumentNullException(nameof(request)); | ||
|
||
return Connection.SendAsync<SelfServiceProfile>( | ||
HttpMethod.Post, | ||
BuildUri("self-service-profiles"), | ||
request, | ||
DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.GetAsync"/> | ||
public Task<SelfServiceProfile> GetAsync(string id, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
return Connection.GetAsync<SelfServiceProfile>( | ||
BuildUri($"self-service-profiles/{EncodePath(id)}"), | ||
DefaultHeaders, | ||
null, | ||
cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.DeleteAsync"/> | ||
public Task DeleteAsync(string id, CancellationToken cancellationToken = default) | ||
{ | ||
return Connection.SendAsync<object>( | ||
HttpMethod.Delete, | ||
BuildUri($"self-service-profiles/{EncodePath(id)}"), | ||
body: null, | ||
headers: DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.UpdateAsync"/> | ||
public Task<SelfServiceProfile> UpdateAsync(string id, SelfServiceProfileUpdateRequest request, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
return Connection.SendAsync<SelfServiceProfile>( | ||
new HttpMethod("PATCH"), | ||
BuildUri($"self-service-profiles/{EncodePath(id)}"), | ||
request, | ||
DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.CreateSsoTicketAsync"/> | ||
public Task<SelfServiceSsoTicket> CreateSsoTicketAsync(string id, SelfServiceSsoTicketCreateRequest request, CancellationToken cancellationToken = default) | ||
{ | ||
if (request == null) | ||
throw new ArgumentNullException(nameof(request)); | ||
|
||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
return Connection.SendAsync<SelfServiceSsoTicket>( | ||
HttpMethod.Post, | ||
BuildUri($"self-service-profiles/{EncodePath(id)}/sso-ticket"), | ||
request, | ||
DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.RevokeSsoTicketAsync"/> | ||
public Task RevokeSsoTicketAsync(string profileId, string ticketId, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(profileId)) | ||
throw new ArgumentNullException(nameof(profileId)); | ||
|
||
if (string.IsNullOrEmpty(ticketId)) | ||
throw new ArgumentNullException(nameof(ticketId)); | ||
|
||
return Connection.SendAsync<SelfServiceSsoTicket>( | ||
HttpMethod.Post, | ||
BuildUri($"self-service-profiles/{EncodePath(profileId)}/sso-ticket/{EncodePath(ticketId)}/revoke"), | ||
null, | ||
DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.GetCustomTextForSelfServiceProfileAsync"/> | ||
public Task<object> GetCustomTextForSelfServiceProfileAsync(string id, string language, string page, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
if (string.IsNullOrEmpty(language)) | ||
throw new ArgumentNullException(nameof(language)); | ||
|
||
if (string.IsNullOrEmpty(page)) | ||
throw new ArgumentNullException(nameof(page)); | ||
|
||
return Connection.GetAsync<object>( | ||
BuildUri($"self-service-profiles/{EncodePath(id)}/custom-text/{EncodePath(language)}/{EncodePath(page)}"), | ||
DefaultHeaders, | ||
null, | ||
cancellationToken); | ||
} | ||
|
||
/// <inheritdoc cref="ISelfServiceProfilesClient.SetCustomTextForSelfServiceProfileAsync"/> | ||
public Task<object> SetCustomTextForSelfServiceProfileAsync(string id, string language, string page, object body, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(id)) | ||
throw new ArgumentNullException(nameof(id)); | ||
|
||
if (string.IsNullOrEmpty(language)) | ||
throw new ArgumentNullException(nameof(language)); | ||
|
||
if (string.IsNullOrEmpty(page)) | ||
throw new ArgumentNullException(nameof(page)); | ||
|
||
return Connection | ||
.SendAsync<object>( | ||
HttpMethod.Put, | ||
BuildUri($"self-service-profiles/{EncodePath(id)}/custom-text/{EncodePath(language)}/{EncodePath(page)}"), | ||
body, | ||
DefaultHeaders, | ||
cancellationToken: cancellationToken); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Auth0.ManagementApi/Models/SelfServiceProfiles/Branding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Auth0.ManagementApi.Models.SelfServiceProfiles | ||
{ | ||
public class Branding | ||
{ | ||
/// <summary> | ||
/// Logo Url | ||
/// </summary> | ||
[JsonProperty("logo_url")] | ||
public string LogoUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Branding Colors | ||
/// </summary> | ||
[JsonProperty("colors")] | ||
public Color Color { get; set; } | ||
} | ||
|
||
public class Color | ||
{ | ||
[JsonProperty("primary")] | ||
public string Primary { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Auth0.ManagementApi/Models/SelfServiceProfiles/EnabledOrganization.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Auth0.ManagementApi.Models.SelfServiceProfiles | ||
{ | ||
/// <summary> | ||
/// List of organizations that the connection will be enabled for. | ||
/// </summary> | ||
public class EnabledOrganization | ||
{ | ||
/// <summary> | ||
/// Organization identifier | ||
/// </summary> | ||
[JsonProperty("organization_id")] | ||
public string OrganizationId { get; set; } | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Auth0.ManagementApi/Models/SelfServiceProfiles/SelfServiceProfile.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace Auth0.ManagementApi.Models.SelfServiceProfiles | ||
{ | ||
public class SelfServiceProfile : SelfServiceProfileBase | ||
{ | ||
/// <summary> | ||
/// The unique ID of the self-service profile. | ||
/// </summary> | ||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// The time when this self-service Profile was created. | ||
/// </summary> | ||
[JsonProperty("created_at")] | ||
public DateTime CreatedAt { get; set; } | ||
|
||
/// <summary> | ||
/// The time when this self-service Profile was updated. | ||
/// </summary> | ||
[JsonProperty("updated_at")] | ||
public DateTime UpdatedAt { get; set; } | ||
} | ||
} |
Oops, something went wrong.