mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 19:21:10 +00:00
Merge pull request #153 from BinaryAlley/feature/presentation-web-fastendpoints
Feature/presentation web fastendpoints
This commit is contained in:
596 files changed
+12604
-2402
No files matched your search
@@ -1,3 +1,7 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Contracts.Requests.Authentication;
|
namespace Lumina.Contracts.Requests.Authentication;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -7,6 +11,7 @@ namespace Lumina.Contracts.Requests.Authentication;
|
|||||||
/// <param name="CurrentPassword">The current password of the account. Required.</param>
|
/// <param name="CurrentPassword">The current password of the account. Required.</param>
|
||||||
/// <param name="NewPassword">The new password of the account. Required.</param>
|
/// <param name="NewPassword">The new password of the account. Required.</param>
|
||||||
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account. Required.</param>
|
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account. Required.</param>
|
||||||
|
[DebuggerDisplay("Username: {Username}")]
|
||||||
public record ChangePasswordRequest(
|
public record ChangePasswordRequest(
|
||||||
string? Username,
|
string? Username,
|
||||||
string? CurrentPassword,
|
string? CurrentPassword,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Contracts.Requests.Authorization;
|
namespace Lumina.Contracts.Requests.Authorization;
|
||||||
@@ -8,6 +9,7 @@ namespace Lumina.Contracts.Requests.Authorization;
|
|||||||
/// Represents the request model for retrieving the authorization permissions of a user identified by <paramref name="UserId"/>.
|
/// Represents the request model for retrieving the authorization permissions of a user identified by <paramref name="UserId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="UserId">The unique identifier of the user for whom to get the authorization permissions. Required.</param>
|
/// <param name="UserId">The unique identifier of the user for whom to get the authorization permissions. Required.</param>
|
||||||
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
public record GetUserPermissionsRequest(
|
public record GetUserPermissionsRequest(
|
||||||
Guid? UserId
|
Guid? UserId
|
||||||
);
|
);
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Contracts.Requests.Authorization;
|
namespace Lumina.Contracts.Requests.Authorization;
|
||||||
@@ -8,6 +9,7 @@ namespace Lumina.Contracts.Requests.Authorization;
|
|||||||
/// Represents the request model for retrieving the authorization role of a user identified by <paramref name="UserId"/>.
|
/// Represents the request model for retrieving the authorization role of a user identified by <paramref name="UserId"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="UserId">The unique identifier of the user for whom to get the authorization role. Required.</param>
|
/// <param name="UserId">The unique identifier of the user for whom to get the authorization role. Required.</param>
|
||||||
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
public record GetUserRoleRequest(
|
public record GetUserRoleRequest(
|
||||||
Guid? UserId
|
Guid? UserId
|
||||||
);
|
);
|
||||||
@@ -6,9 +6,9 @@ using System.Text.Json.Serialization;
|
|||||||
namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
|
namespace Lumina.Contracts.Requests.FileSystemManagement.Path;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get the root of a file system path.
|
/// Represents the request for retrieving the parent path of a file system path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Path">The file system path for which to get the root. Required.</param>
|
/// <param name="Path">The path for which the parent path is retrieved.</param>
|
||||||
[DebuggerDisplay("Path: {Path}")]
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
public record GetPathParentRequest(
|
public record GetPathParentRequest(
|
||||||
string? Path
|
string? Path
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public class AddRoleEndpoint : BaseEndpoint<AddRoleRequest, IResult>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new authorization role.
|
/// Adds a new authorization role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request containing the authorization role to be created.</param>
|
/// <param name="request">The request containing the authorization role to be created.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||||
|
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
using Lumina.Presentation.Web.Common.Exceptions;
|
using Lumina.Presentation.Web.Common.Exceptions;
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Configuration;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using System;
|
using System;
|
||||||
@@ -35,13 +35,13 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
/// <param name="httpClient">Injected HttpClient for interacting with the API.</param>
|
/// <param name="httpClient">Injected HttpClient for interacting with the API.</param>
|
||||||
/// <param name="httpContextAccessor">Injected service for providing the current HTTP context.</param>
|
/// <param name="httpContextAccessor">Injected service for providing the current HTTP context.</param>
|
||||||
/// <param name="serverConfigurationOptions">Injected server configuration application settings.</param>
|
/// <param name="serverConfigurationOptions">Injected server configuration application settings.</param>
|
||||||
public ApiHttpClient(HttpClient httpClient, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot<ServerConfigurationModel> serverConfigurationOptions)
|
public ApiHttpClient(HttpClient httpClient, IHttpContextAccessor httpContextAccessor, IOptionsSnapshot<ServerConfigurationDto> serverConfigurationOptions)
|
||||||
{
|
{
|
||||||
_httpClient = httpClient;
|
_httpClient = httpClient;
|
||||||
_httpContext = httpContextAccessor.HttpContext;
|
_httpContext = httpContextAccessor.HttpContext;
|
||||||
// read the API server configuration values from the configuration, and assign them to the injected client
|
// read the API server configuration values from the configuration, and assign them to the injected client
|
||||||
ServerConfigurationModel serverConfigurationModel = serverConfigurationOptions.Value;
|
ServerConfigurationDto serverConfiguration = serverConfigurationOptions.Value;
|
||||||
httpClient.BaseAddress = new Uri($"{serverConfigurationModel.BaseAddress}:{serverConfigurationModel.Port}/api/v{serverConfigurationModel.ApiVersion}/");
|
httpClient.BaseAddress = new Uri($"{serverConfiguration.BaseAddress}:{serverConfiguration.Port}/api/v{serverConfiguration.ApiVersion}/");
|
||||||
|
|
||||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
/// <returns>A model containing the deserialized blob.</returns>
|
/// <returns>A model containing the deserialized blob.</returns>
|
||||||
public async Task<BlobDataModel> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
|
public async Task<BlobDataDto> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
using HttpRequestMessage request = new(HttpMethod.Get, endpoint);
|
using HttpRequestMessage request = new(HttpMethod.Get, endpoint);
|
||||||
AuthenticationHeaderValue? authenticationHeader = GetAuthenticationHeader();
|
AuthenticationHeaderValue? authenticationHeader = GetAuthenticationHeader();
|
||||||
@@ -112,10 +112,10 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
{
|
{
|
||||||
// read the content as a string, for error messages
|
// read the content as a string, for error messages
|
||||||
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||||
ProblemDetailsModel? problemDetails = null;
|
ProblemDetailsDto? problemDetails = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
|
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
|
||||||
}
|
}
|
||||||
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
||||||
throw new ApiException(problemDetails, response.StatusCode);
|
throw new ApiException(problemDetails, response.StatusCode);
|
||||||
@@ -123,7 +123,7 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
// if the response is successful, read it as a byte array
|
// if the response is successful, read it as a byte array
|
||||||
byte[] responseContent = await response.Content.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);
|
byte[] responseContent = await response.Content.ReadAsByteArrayAsync(cancellationToken).ConfigureAwait(false);
|
||||||
string contentType = response.Content.Headers.ContentType?.ToString() ?? "application/octet-stream";
|
string contentType = response.Content.Headers.ContentType?.ToString() ?? "application/octet-stream";
|
||||||
return new BlobDataModel { Data = responseContent, ContentType = contentType };
|
return new BlobDataDto { Data = responseContent, ContentType = contentType };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -142,12 +142,12 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
HttpResponseMessage response = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
ProblemDetailsModel? problemDetails = null;
|
ProblemDetailsDto? problemDetails = null;
|
||||||
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
string content = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||||
// attempt to deserialize the response content to ProblemDetailsModel if the request fails
|
// attempt to deserialize the response content to ProblemDetailsDto if the request fails
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
|
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
|
||||||
}
|
}
|
||||||
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
||||||
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
|
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
|
||||||
@@ -194,13 +194,13 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends an HTTP request and deserializes the response into the specified type if the request is successful.
|
/// Sends an HTTP request and deserializes the response into the specified type if the request is successful.
|
||||||
/// If the request fails, it attempts to deserialize the response content into a <see cref="ProblemDetailsModel"/> and throws an <see cref="ApiException"/>.
|
/// If the request fails, it attempts to deserialize the response content into a <see cref="ProblemDetailsDto"/> and throws an <see cref="ApiException"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
|
/// <typeparam name="TResponse">The expected type of the response content.</typeparam>
|
||||||
/// <param name="request">The <see cref="HttpRequestMessage"/> to be sent.</param>
|
/// <param name="request">The <see cref="HttpRequestMessage"/> to be sent.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
/// <returns>The deserialized response content as an object of type <typeparamref name="TResponse"/>.</returns>
|
/// <returns>The deserialized response content as an object of type <typeparamref name="TResponse"/>.</returns>
|
||||||
/// <exception cref="ApiException">Thrown if the response is not successful, with the <see cref="ProblemDetailsModel"/> if available.</exception>
|
/// <exception cref="ApiException">Thrown if the response is not successful, with the <see cref="ProblemDetailsDto"/> if available.</exception>
|
||||||
private async Task<TResponse> SendRequestAsync<TResponse>(HttpRequestMessage request, CancellationToken cancellationToken)
|
private async Task<TResponse> SendRequestAsync<TResponse>(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// send the HTTP request and read the response
|
// send the HTTP request and read the response
|
||||||
@@ -216,11 +216,11 @@ public class ApiHttpClient : IApiHttpClient
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ProblemDetailsModel? problemDetails = null;
|
ProblemDetailsDto? problemDetails = null;
|
||||||
// attempt to deserialize the response content to ProblemDetailsModel if the request fails
|
// attempt to deserialize the response content to ProblemDetailsDto if the request fails
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
problemDetails = JsonSerializer.Deserialize<ProblemDetailsModel>(content, _jsonOptions);
|
problemDetails = JsonSerializer.Deserialize<ProblemDetailsDto>(content, _jsonOptions);
|
||||||
}
|
}
|
||||||
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
catch { /* if we can't deserialize to ProblemDetails, we'll just use the status code */ }
|
||||||
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
|
throw new ApiException(problemDetails, response.StatusCode, request.RequestUri?.AbsolutePath);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -36,7 +36,7 @@ public interface IApiHttpClient
|
|||||||
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
/// <param name="endpoint">The API endpoint where the request is being sent.</param>
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
/// <returns>A model containing the deserialized blob.</returns>
|
/// <returns>A model containing the deserialized blob.</returns>
|
||||||
Task<BlobDataModel> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default);
|
Task<BlobDataDto> GetBlobAsync(string endpoint, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a DELETE request to the specified <paramref name="endpoint"/> as an asynchronous operation.
|
/// Sends a DELETE request to the specified <paramref name="endpoint"/> as an asynchronous operation.
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
|
||||||
using Lumina.Presentation.Web.Common.Filters.TypeFilters;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Attributes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attribute that restricts endpoint access to users with specified permissions.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Can be applied to controllers or individual actions. Multiple permissions create an OR condition.
|
|
||||||
/// </remarks>
|
|
||||||
public class RequirePermissionAttribute : ApiAuthorizationAttribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="RequirePermissionAttribute"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="permissions">One or more permissions that are allowed to access the endpoint.</param>
|
|
||||||
public RequirePermissionAttribute(params AuthorizationPermission[] permissions) : base()
|
|
||||||
{
|
|
||||||
Arguments = [new AuthorizationRequirementModel { Permissions = permissions }];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Filters.TypeFilters;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
using System;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Attributes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attribute that restricts endpoint access based on a custom authorization policy.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Can be applied to controllers or individual actions.
|
|
||||||
/// </remarks>
|
|
||||||
public class RequirePolicyAttribute : ApiAuthorizationAttribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="RequirePolicyAttribute"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="policyType">The type of the authorization policy to apply.</param>
|
|
||||||
public RequirePolicyAttribute(Type policyType) : base()
|
|
||||||
{
|
|
||||||
Arguments = [new AuthorizationRequirementModel { PolicyType = policyType }];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Filters.TypeFilters;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Attributes;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attribute that restricts endpoint access to users with specified roles.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Can be applied to controllers or individual actions. Multiple roles create an OR condition.
|
|
||||||
/// </remarks>
|
|
||||||
public class RequireRoleAttribute : ApiAuthorizationAttribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="RequireRoleAttribute"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="roles">One or more roles that are allowed to access the endpoint.</param>
|
|
||||||
public RequireRoleAttribute(params string[] roles) : base()
|
|
||||||
{
|
|
||||||
Arguments = [new AuthorizationRequirementModel { Roles = roles }];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains the names of the authorization policies defined in the Web application.
|
||||||
|
/// </summary>
|
||||||
|
public static class AuthorizationPolicies
|
||||||
|
{
|
||||||
|
public const string REQUIRE_ADMIN_ROLE = "RequireAdminRole";
|
||||||
|
public const string REQUIRE_CREATE_LIBRARIES_PERMISSION = "RequireCreateLibrariesPermission";
|
||||||
|
public const string REQUIRE_INITIALIZATION = "RequireInitialization";
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Api;
|
using Lumina.Presentation.Web.Common.Api;
|
||||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
using Lumina.Presentation.Web.Common.Responses.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -55,42 +55,6 @@ public class AuthorizationService : IAuthorizationService
|
|||||||
return authorization.Role == role;
|
return authorization.Role == role;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization policy.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TAuthorizationPolicy">The type of authorization policy to evaluate.</typeparam>
|
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
|
||||||
/// <returns><see langword="true"/> if the currently logged in user satisfies the policy, <see langword="false"/> otherwise.</returns>
|
|
||||||
public Task<bool> EvaluatePolicyAsync<TAuthorizationPolicy>(CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization requirement.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requirement">The authorization requirements to check.</param>
|
|
||||||
/// <returns><see langword="true"/> if the currently logged in user satisfies the requirement, <see langword="false"/> otherwise.</returns>
|
|
||||||
public async Task<bool> EvaluateAuthorizationAsync(AuthorizationRequirementModel requirement)
|
|
||||||
{
|
|
||||||
GetAuthorizationResponse authorization = await GetUserAuthorizationAsync(CancellationToken.None);
|
|
||||||
|
|
||||||
if (requirement.Roles?.Length > 0 && !requirement.Roles.Any(role => authorization.Role?.Contains(role) == true))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (requirement.Permissions?.Length > 0 && !requirement.Permissions.Any(permission => authorization.Permissions.Contains(permission)))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
//if (_requirement.PolicyType is not null)
|
|
||||||
//{
|
|
||||||
// bool response = await _apiHttpClient.PostAsync<bool, object>($"auth/evaluate-policy/{_requirement.PolicyType.Name}", null!);
|
|
||||||
// if (!response)
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves user authorization details from the authorization service.
|
/// Retrieves user authorization details from the authorization service.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -98,8 +62,10 @@ public class AuthorizationService : IAuthorizationService
|
|||||||
/// <returns>The user's authorization details.</returns>
|
/// <returns>The user's authorization details.</returns>
|
||||||
private async Task<GetAuthorizationResponse> GetUserAuthorizationAsync(CancellationToken cancellationToken)
|
private async Task<GetAuthorizationResponse> GetUserAuthorizationAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// get the id of the currently logged in user
|
// anonymous users and users without an identifier claim have no role or permissions, so deny without querying the API
|
||||||
string userId = _httpContextAccessor.HttpContext!.User.FindFirst(ClaimTypes.NameIdentifier)!.Value;
|
string? userId = _httpContextAccessor.HttpContext?.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
|
||||||
return await _apiHttpClient.GetAsync<GetAuthorizationResponse>($"auth/get-authorization?userId={Uri.EscapeDataString(userId.ToString())}", cancellationToken);
|
if (string.IsNullOrEmpty(userId))
|
||||||
|
return new GetAuthorizationResponse(Guid.Empty, string.Empty, []);
|
||||||
|
return await _apiHttpClient.GetAsync<GetAuthorizationResponse>($"auth/get-authorization?userId={Uri.EscapeDataString(userId)}", cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -27,19 +26,4 @@ public interface IAuthorizationService
|
|||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
/// <returns><see langword="true"/> if the currently logged in user is in the specified role, <see langword="false"/> otherwise.</returns>
|
/// <returns><see langword="true"/> if the currently logged in user is in the specified role, <see langword="false"/> otherwise.</returns>
|
||||||
Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken);
|
Task<bool> IsInRoleAsync(string role, CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization policy.
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="TAuthorizationPolicy">The type of authorization policy to evaluate.</typeparam>
|
|
||||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
|
||||||
/// <returns><see langword="true"/> if the currently logged in user satisfies the policy, <see langword="false"/> otherwise.</returns>
|
|
||||||
Task<bool> EvaluatePolicyAsync<TAuthorizationPolicy>(CancellationToken cancellationToken);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates whether the currently logged in user meets the conditions defined in the specified authorization requirement.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="requirement">The authorization requirements to check.</param>
|
|
||||||
/// <returns><see langword="true"/> if the currently logged in user satisfies the requirement, <see langword="false"/> otherwise.</returns>
|
|
||||||
Task<bool> EvaluateAuthorizationAsync(AuthorizationRequirementModel requirement);
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using FastEndpoints;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// FastEndpoints pre-processor that runs the application initialization check before the endpoint handler executes.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The check runs the <c>RequireInitialization</c> authorization policy, which queries the remote API and records the pending super admin setup state in the session.
|
||||||
|
/// Its result is deliberately ignored, because the pages that use this processor must be reachable both before and after the application is initialized.
|
||||||
|
/// </remarks>
|
||||||
|
/// <typeparam name="TRequest">The type of the request of the endpoint to which this pre-processor is applied.</typeparam>
|
||||||
|
public class InitializationCheckPreProcessor<TRequest> : IPreProcessor<TRequest> where TRequest : notnull
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Runs the initialization check for the current request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="preProcessorContext">The pre-processor context for the current request.</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||||
|
public async Task PreProcessAsync(IPreProcessorContext<TRequest> preProcessorContext, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
HttpContext httpContext = preProcessorContext.HttpContext;
|
||||||
|
Microsoft.AspNetCore.Authorization.IAuthorizationService authorizationService = httpContext.RequestServices.GetRequiredService<Microsoft.AspNetCore.Authorization.IAuthorizationService>();
|
||||||
|
await authorizationService.AuthorizeAsync(httpContext.User, httpContext, AuthorizationPolicies.REQUIRE_INITIALIZATION).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Api;
|
using Lumina.Presentation.Web.Common.Api;
|
||||||
using Lumina.Presentation.Web.Common.Http;
|
using Lumina.Presentation.Web.Common.Http;
|
||||||
using Lumina.Presentation.Web.Common.Models.UsersManagement;
|
using Lumina.Presentation.Web.Common.Responses.UsersManagement;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -28,17 +28,17 @@ public class InitializationHandler : AuthorizationHandler<InitializationRequirem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks the application initialization status and authorizes the requirement if initialized.
|
/// Checks the application initialization status and authorizes the requirement if initialized.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">The authorization context.</param>
|
/// <param name="authorizationHandlerContext">The authorization context.</param>
|
||||||
/// <param name="requirement">The initialization requirement to be evaluated.</param>
|
/// <param name="initializationRequirement">The initialization requirement to be evaluated.</param>
|
||||||
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, InitializationRequirement requirement)
|
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, InitializationRequirement initializationRequirement)
|
||||||
{
|
{
|
||||||
InitializationModel result = await _apiHttpClient.GetAsync<InitializationModel>("initialization/").ConfigureAwait(false);
|
InitializationResponse result = await _apiHttpClient.GetAsync<InitializationResponse>("initialization/").ConfigureAwait(false);
|
||||||
HttpContext? httpContext = context.Resource as HttpContext;
|
HttpContext? httpContext = authorizationHandlerContext.Resource as HttpContext;
|
||||||
if (result.IsInitialized)
|
if (result.IsInitialized)
|
||||||
{
|
{
|
||||||
// admin account was registered, remove this requirement from the session
|
// admin account was registered, remove this requirement from the session
|
||||||
httpContext?.Session.Remove(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP);
|
httpContext?.Session.Remove(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP);
|
||||||
context.Succeed(requirement);
|
authorizationHandlerContext.Succeed(initializationRequirement);
|
||||||
}
|
}
|
||||||
else // store in session that super admin setup is needed
|
else // store in session that super admin setup is needed
|
||||||
httpContext?.Session.SetString(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, "true");
|
httpContext?.Session.SetString(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, "true");
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the <see cref="PermissionRequirement"/> by checking the currently logged in user's permissions against the remote API.
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
|
||||||
|
{
|
||||||
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PermissionAuthorizationHandler"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="authorizationService">Injected service for authorization checks against the remote API.</param>
|
||||||
|
public PermissionAuthorizationHandler(IAuthorizationService authorizationService)
|
||||||
|
{
|
||||||
|
_authorizationService = authorizationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Succeeds the requirement when the currently logged in user holds any of the required permissions.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="authorizationHandlerContext">The authorization context.</param>
|
||||||
|
/// <param name="permissionRequirement">The permission requirement to evaluate.</param>
|
||||||
|
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, PermissionRequirement permissionRequirement)
|
||||||
|
{
|
||||||
|
foreach (AuthorizationPermission permission in permissionRequirement.Permissions)
|
||||||
|
{
|
||||||
|
if (await _authorizationService.HasPermissionAsync(permission, CancellationToken.None).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
authorizationHandlerContext.Succeed(permissionRequirement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a requirement that the user must hold at least one of the specified permissions.
|
||||||
|
/// </summary>
|
||||||
|
public class PermissionRequirement : IAuthorizationRequirement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the permissions that allow access, of which the user must hold at least one.
|
||||||
|
/// </summary>
|
||||||
|
public AuthorizationPermission[] Permissions { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PermissionRequirement"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="permissions">The permissions that allow access.</param>
|
||||||
|
public PermissionRequirement(params AuthorizationPermission[] permissions)
|
||||||
|
{
|
||||||
|
Permissions = permissions;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the <see cref="RoleRequirement"/> by checking the currently logged in user's role against the remote API.
|
||||||
|
/// </summary>
|
||||||
|
public class RoleAuthorizationHandler : AuthorizationHandler<RoleRequirement>
|
||||||
|
{
|
||||||
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RoleAuthorizationHandler"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="authorizationService">Injected service for authorization checks against the remote API.</param>
|
||||||
|
public RoleAuthorizationHandler(IAuthorizationService authorizationService)
|
||||||
|
{
|
||||||
|
_authorizationService = authorizationService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Succeeds the requirement when the currently logged in user belongs to any of the required roles.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="authorizationHandlerContext">The authorization context.</param>
|
||||||
|
/// <param name="roleRequirement">The role requirement to evaluate.</param>
|
||||||
|
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext authorizationHandlerContext, RoleRequirement roleRequirement)
|
||||||
|
{
|
||||||
|
foreach (string role in roleRequirement.Roles)
|
||||||
|
{
|
||||||
|
if (await _authorizationService.IsInRoleAsync(role, CancellationToken.None).ConfigureAwait(false))
|
||||||
|
{
|
||||||
|
authorizationHandlerContext.Succeed(roleRequirement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a requirement that the user must belong to at least one of the specified roles.
|
||||||
|
/// </summary>
|
||||||
|
public class RoleRequirement : IAuthorizationRequirement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the roles that allow access, of which the user must belong to at least one.
|
||||||
|
/// </summary>
|
||||||
|
public string[] Roles { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RoleRequirement"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roles">The roles that allow access.</param>
|
||||||
|
public RoleRequirement(params string[] roles)
|
||||||
|
{
|
||||||
|
Roles = roles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for an authorization permission.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Id">The unique identifier of the permission.</param>
|
||||||
|
/// <param name="PermissionName">The name of the permission.</param>
|
||||||
|
[DebuggerDisplay("Id: {Id}, PermissionName: {PermissionName}")]
|
||||||
|
public record PermissionDto(
|
||||||
|
Guid Id,
|
||||||
|
AuthorizationPermission PermissionName
|
||||||
|
);
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for an authorization role.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Id">The unique identifier of the role.</param>
|
||||||
|
/// <param name="RoleName">The name of the role.</param>
|
||||||
|
[DebuggerDisplay("Id: {Id}, RoleName: {RoleName}")]
|
||||||
|
public record RoleDto(
|
||||||
|
Guid Id,
|
||||||
|
string RoleName
|
||||||
|
);
|
||||||
+7
-5
@@ -1,14 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a model for an authorization role with its permissions.
|
/// Data transfer object for a model for an authorization role with its permissions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Role">The authorization role.</param>
|
/// <param name="Role">The authorization role.</param>
|
||||||
/// <param name="Permissions">The permissions of the authorization role.</param>
|
/// <param name="Permissions">The permissions of the authorization role.</param>
|
||||||
public record RolePermissionsModel(
|
[DebuggerDisplay("Role: {Role}")]
|
||||||
RoleModel Role,
|
public record RolePermissionsDto(
|
||||||
PermissionModel[] Permissions
|
RoleDto Role,
|
||||||
|
PermissionDto[] Permissions
|
||||||
);
|
);
|
||||||
+8
-6
@@ -1,15 +1,17 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.UsersManagement;
|
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
namespace Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a model for a user with its authorization permissions.
|
/// Data transfer object for a user with its authorization permissions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="User">The user.</param>
|
/// <param name="User">The user.</param>
|
||||||
/// <param name="Permissions">The authorization permissions of the user.</param>
|
/// <param name="Permissions">The authorization permissions of the user.</param>
|
||||||
public record UserPermissionsModel(
|
[DebuggerDisplay("User: {User}")]
|
||||||
UserModel User,
|
public record UserPermissionsDto(
|
||||||
PermissionModel[] Permissions
|
UserDto User,
|
||||||
|
PermissionDto[] Permissions
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for the data shown on the error page.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("RequestId: {RequestId}, ShowRequestId: {ShowRequestId}")]
|
||||||
|
public class ErrorViewDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the request identifier to display.
|
||||||
|
/// </summary>
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the request identifier should be shown.
|
||||||
|
/// </summary>
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
+3
-3
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get genre information.
|
/// Data transfer object for a request to get genre information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Name}")]
|
[DebuggerDisplay("{Name}")]
|
||||||
public class GenreModel
|
public class GenreDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the genre element of the media item.
|
/// Gets the name of the genre element of the media item.
|
||||||
+3
-3
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get language information.
|
/// Data transfer object for a request to get language information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{LanguageName}")]
|
[DebuggerDisplay("{LanguageName}")]
|
||||||
public class LanguageInfoModel
|
public class LanguageInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the ISO 639-1 two-letter language code.
|
/// Gets the ISO 639-1 two-letter language code.
|
||||||
+5
-3
@@ -1,17 +1,19 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
using Lumina.Presentation.Web.Common.Enums.Notifications;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Model for notifications.
|
/// Data transfer object for notifications.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Id">The id of the notification.</param>
|
/// <param name="Id">The id of the notification.</param>
|
||||||
/// <param name="Message">The message of the notification.</param>
|
/// <param name="Message">The message of the notification.</param>
|
||||||
/// <param name="Type">The type of the notification.</param>
|
/// <param name="Type">The type of the notification.</param>
|
||||||
public record struct NotificationModel(
|
[DebuggerDisplay("Id: {Id}, Message: {Message}")]
|
||||||
|
public record struct NotificationDto(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
string Message,
|
string Message,
|
||||||
NotificationType Type
|
NotificationType Type
|
||||||
+4
-4
@@ -1,17 +1,17 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Model that follows the RFC 7807 standard for problem details in HTTP APIs.
|
/// Data transfer object that follows the RFC 7807 standard for problem details in HTTP APIs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title} ({Status})")]
|
[DebuggerDisplay("{Title} ({Status})")]
|
||||||
public class ProblemDetailsModel
|
public class ProblemDetailsDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the URI reference that identifies the problem type.
|
/// Gets or sets the URI reference that identifies the problem type.
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a rating.
|
/// Data transfer object for a rating.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
[DebuggerDisplay("Value: {Value}, MaxValue: {MaxValue}")]
|
||||||
public abstract class RatingModel
|
public abstract class RatingDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the numeric value of the rating.
|
/// Gets the numeric value of the rating.
|
||||||
+4
-4
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get release information.
|
/// Data transfer object for a request to get release information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{OriginalReleaseDate}")]
|
[DebuggerDisplay("OriginalReleaseDate: {OriginalReleaseDate}")]
|
||||||
public class ReleaseInfoModel
|
public class ReleaseInfoDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the optional original release date of the media item.
|
/// Gets the optional original release date of the media item.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Response data transfer object for the JSON responses of the web application that do not carry a payload.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Success">Whether the operation succeeded or not.</param>
|
||||||
|
public record SuccessResponse(
|
||||||
|
[property: JsonPropertyName("success")] bool Success
|
||||||
|
);
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Response data transfer object for the JSON responses of the web application that carry a payload.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TData">The type of the payload of the response.</typeparam>
|
||||||
|
/// <param name="Success">Whether the operation succeeded or not.</param>
|
||||||
|
/// <param name="Data">The payload of the response.</param>
|
||||||
|
public record SuccessResponse<TData>(
|
||||||
|
[property: JsonPropertyName("success")] bool Success,
|
||||||
|
[property: JsonPropertyName("data")] TData? Data
|
||||||
|
);
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
namespace Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get tag information.
|
/// Data transfer object for a request to get tag information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public class TagModel
|
public class TagDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the tag element of the media item.
|
/// Gets the name of the tag element of the media item.
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Configuration;
|
namespace Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Model for deserializing media settings.
|
/// Data transfer object for deserializing media settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{SECTION_NAME}")]
|
[DebuggerDisplay("Section name: {SECTION_NAME}")]
|
||||||
public class EncryptionSettingsModel
|
public class EncryptionSettingsDto
|
||||||
{
|
{
|
||||||
public const string SECTION_NAME = "EncryptionSettings";
|
public const string SECTION_NAME = "EncryptionSettings";
|
||||||
|
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Configuration;
|
namespace Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Model for deserializing server configuration settings.
|
/// Data transfer object for deserializing server configuration settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{SECTION_NAME}")]
|
[DebuggerDisplay("Section name: {SECTION_NAME}")]
|
||||||
public class ServerConfigurationModel
|
public class ServerConfigurationDto
|
||||||
{
|
{
|
||||||
public const string SECTION_NAME = "ServerConfiguration";
|
public const string SECTION_NAME = "ServerConfiguration";
|
||||||
|
|
||||||
+5
-5
@@ -1,14 +1,14 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a model for storing binary data (blob).
|
/// Data transfer object for a model for storing binary data (blob).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{ContentType} (Data.Length)")]
|
[DebuggerDisplay("ContentType: {ContentType} (Data.Length)")]
|
||||||
public class BlobDataModel
|
public class BlobDataDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the binary data as a byte array.
|
/// Gets or sets the binary data as a byte array.
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for directories displayed in custom directory/file browser dialogs.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
|
public class DirectoryDto : FileSystemItemDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the children items of the directory.
|
||||||
|
/// </summary>
|
||||||
|
public List<FileSystemItemDto> Items { get; set; } = [];
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for files displayed in custom directory/file browser dialogs.
|
||||||
|
/// </summary>
|
||||||
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
|
public class FileDto : FileSystemItemDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the size of the file, in bytes
|
||||||
|
/// </summary>
|
||||||
|
public long Size { get; set; }
|
||||||
|
}
|
||||||
+5
-5
@@ -1,15 +1,15 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base model for files and directories displayed in custom directory/file browser dialogs.
|
/// Base data transfer object for files and directories displayed in custom directory/file browser dialogs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Path}")]
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
public abstract class FileSystemItemModel
|
public abstract class FileSystemItemDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the full path to the file system item.
|
/// Gets or sets the full path to the file system item.
|
||||||
+6
-6
@@ -1,16 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic file system node.
|
/// Data transfer object for a file system node.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Path}")]
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
public class FileSystemTreeNodeModel
|
public class FileSystemTreeNodeDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the full path of the file or directory.
|
/// Gets or sets the full path of the file or directory.
|
||||||
@@ -40,5 +40,5 @@ public class FileSystemTreeNodeModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of child nodes.
|
/// Gets or sets the list of child nodes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<FileSystemTreeNodeModel> Children { get; set; } = [];
|
public List<FileSystemTreeNodeDto> Children { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object containing the file system platform type.
|
||||||
|
/// </summary>`
|
||||||
|
[DebuggerDisplay("PlatformType: {PlatformType}")]
|
||||||
|
public class FileSystemTypeDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the file system platform type.
|
||||||
|
/// </summary>
|
||||||
|
public PlatformType PlatformType { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for a response to the inquiry about the existence of a file system path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Exists">Whether a file system path exists or not.</param>
|
||||||
|
[DebuggerDisplay("Exists: {Exists}")]
|
||||||
|
public record PathExistsDto(
|
||||||
|
bool Exists
|
||||||
|
);
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a response containing a file system path.
|
/// Data transfer object for a response containing a file system path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Path}")]
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
public class PathSegmentModel
|
public class PathSegmentDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the returned path.
|
/// Gets or sets the returned path.
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for a file system path separator.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Separator">The system's path separator.</param>
|
||||||
|
[DebuggerDisplay("Separator: {Separator}")]
|
||||||
|
public record PathSeparatorDto(
|
||||||
|
string Separator
|
||||||
|
);
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data transfer object for a response to the inquiry about the validity of a file system path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="IsValid">Whether a file system path is valid or not.</param>
|
||||||
|
[DebuggerDisplay("IsValid: {IsValid}")]
|
||||||
|
public record PathValidDto(
|
||||||
|
bool IsValid
|
||||||
|
);
|
||||||
+3
-3
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a lightweight book element, containing only the properties needed by the client for card-style navigation.
|
/// Data transfer object for a lightweight book element, containing only the properties needed by the client for card-style navigation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("Title: {Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class BookLiteModel
|
public class BookLiteDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Id of the book.
|
/// Gets or sets the Id of the book.
|
||||||
+4
-4
@@ -5,13 +5,13 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a library element.
|
/// Data transfer object for a library element.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class LibraryModel
|
public class LibraryDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the media library.
|
/// Gets or sets the unique identifier of the media library.
|
||||||
+3
-3
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media library scan job progress model.
|
/// Data transfer object for a media library scan job progress model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}")]
|
[DebuggerDisplay("CompletedItems: {CompletedItems}; TotalItems: {TotalItems}")]
|
||||||
public class LibraryScanJobProgressModel
|
public class LibraryScanJobProgressDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the number of completed items of the media library scan job.
|
/// Gets or sets the number of completed items of the media library scan job.
|
||||||
+4
-4
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media library scan progress model.
|
/// Data transfer object for a media library scan progress model.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}; LibraryId: {LibraryId}")]
|
[DebuggerDisplay("ScanId: {ScanId}; UserId: {UserId}; LibraryId: {LibraryId}")]
|
||||||
public class LibraryScanProgressModel
|
public class LibraryScanProgressDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the media library scan.
|
/// Gets or sets the unique identifier of the media library scan.
|
||||||
@@ -39,7 +39,7 @@ public class LibraryScanProgressModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the optional current job progress of the media library scan.
|
/// Gets or sets the optional current job progress of the media library scan.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LibraryScanJobProgressModel? CurrentJobProgress { get; set; }
|
public LibraryScanJobProgressDto? CurrentJobProgress { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the status of the media library scan.
|
/// Gets or sets the status of the media library scan.
|
||||||
+4
-4
@@ -3,18 +3,18 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a paginated collection of lightweight book elements, together with pagination metadata.
|
/// Data transfer object for a paginated collection of lightweight book elements, together with pagination metadata.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
|
[DebuggerDisplay("CurrentPage: {CurrentPage}; Count: {Count}")]
|
||||||
public class PaginatedBookLiteModel
|
public class PaginatedBookLiteDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the collection of lightweight book elements associated with this instance.
|
/// Gets or sets the collection of lightweight book elements associated with this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IReadOnlyList<BookLiteModel> Data { get; set; } = [];
|
public IReadOnlyList<BookLiteDto> Data { get; set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the current page number in a paginated collection.
|
/// Gets or sets the current page number in a paginated collection.
|
||||||
+3
-3
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Libraries;
|
namespace Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media library scan response.
|
/// Data transfer object for a media library scan response.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
|
[DebuggerDisplay("ScanId: {ScanId} LibraryId: {LibraryId}")]
|
||||||
public class ScanLibraryModel
|
public class ScanLibraryDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the Id of the media library scan.
|
/// Gets or sets the Id of the media library scan.
|
||||||
+6
-6
@@ -2,21 +2,21 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media contributor.
|
/// Data transfer object for a media contributor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public class MediaContributorModel
|
public class MediaContributorDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of the contributor.
|
/// Gets the name of the contributor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MediaContributorNameModel? Name { get; set; }
|
public MediaContributorNameDto? Name { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the role of the contributor.
|
/// Gets the role of the contributor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MediaContributorRoleModel? Role { get; set; }
|
public MediaContributorRoleDto? Role { get; set; }
|
||||||
}
|
}
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media contributor name.
|
/// Data transfer object for a media contributor name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{DisplayName}")]
|
[DebuggerDisplay("DisplayName: {DisplayName}")]
|
||||||
public class MediaContributorNameModel
|
public class MediaContributorNameDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name by which the contributor is popularly known.
|
/// Gets the name by which the contributor is popularly known.
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.MediaContributors;
|
namespace Lumina.Presentation.Web.Common.DTO.MediaContributors;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a media contributor role.
|
/// Data transfer object for a media contributor role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public class MediaContributorRoleModel
|
public class MediaContributorRoleDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value representing this object.
|
/// Gets the value representing this object.
|
||||||
+3
-3
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Plugins;
|
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a metadata provider configured for a media library.
|
/// Data transfer object for a metadata provider configured for a media library.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("Name: {Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public class LibraryMetadataProviderModel
|
public class LibraryMetadataProviderDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the plugin providing the metadata.
|
/// Gets or sets the unique identifier of the plugin providing the metadata.
|
||||||
+3
-3
@@ -5,13 +5,13 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Plugins;
|
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a detected plugin.
|
/// Data transfer object for a detected plugin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("Name: {Name}")]
|
[DebuggerDisplay("Name: {Name}")]
|
||||||
public class PluginModel
|
public class PluginDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the plugin.
|
/// Gets or sets the unique identifier of the plugin.
|
||||||
+5
-3
@@ -1,14 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Enums.Plugins;
|
using Lumina.Presentation.Web.Common.Enums.Plugins;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Plugins;
|
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes a single setting of a plugin.
|
/// Data transfer object for a single setting of a plugin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginSettingDescriptorModel
|
[DebuggerDisplay("Key: {Key}, Label: {Label}")]
|
||||||
|
public class PluginSettingDescriptorDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique key of the setting.
|
/// Gets or sets the unique key of the setting.
|
||||||
+6
-4
@@ -1,14 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Plugins;
|
namespace Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the settings of a plugin and their schema.
|
/// Data transfer object for the settings of a plugin and their schema.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PluginSettingsModel
|
[DebuggerDisplay("PluginId: {PluginId}")]
|
||||||
|
public class PluginSettingsDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the plugin.
|
/// Gets or sets the unique identifier of the plugin.
|
||||||
@@ -18,7 +20,7 @@ public class PluginSettingsModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the schema of the plugin settings.
|
/// Gets or sets the schema of the plugin settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<PluginSettingDescriptorModel> Schema { get; set; } = [];
|
public List<PluginSettingDescriptorDto> Schema { get; set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the current values of the plugin settings.
|
/// Gets or sets the current values of the plugin settings.
|
||||||
+5
-3
@@ -1,15 +1,17 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.UsersManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a model for a user.
|
/// Data transfer object for a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="Id">The unique identifier of the user.</param>
|
/// <param name="Id">The unique identifier of the user.</param>
|
||||||
/// <param name="Username">The username of the user.</param>
|
/// <param name="Username">The username of the user.</param>
|
||||||
public record UserModel(
|
[DebuggerDisplay("Id: {Id}, Username: {Username}")]
|
||||||
|
public record UserDto(
|
||||||
Guid Id,
|
Guid Id,
|
||||||
string Username
|
string Username
|
||||||
);
|
);
|
||||||
+3
-3
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.UsersManagement;
|
namespace Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the settings of a user.
|
/// Data transfer object for the settings of a user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
|
||||||
public class UserSettingsModel
|
public class UserSettingsDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the unique identifier of the user that owns these settings.
|
/// Gets or sets the unique identifier of the user that owns these settings.
|
||||||
+9
-9
@@ -1,17 +1,17 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a book.
|
/// Data transfer object for a book.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class BookModel
|
public class BookDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Id of the media item.
|
/// Gets the Id of the media item.
|
||||||
@@ -107,12 +107,12 @@ public class BookModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of tags associated with the media item.
|
/// Gets the list of tags associated with the media item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HashSet<TagModel> Tags { get; set; } = [];
|
public HashSet<TagDto> Tags { get; set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of genres associated with the media item.
|
/// Gets the list of genres associated with the media item.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public HashSet<GenreModel> Genres { get; set; } = [];
|
public HashSet<GenreDto> Genres { get; set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the publisher of the written content.
|
/// Gets the publisher of the written content.
|
||||||
@@ -192,7 +192,7 @@ public class BookModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of ISBN (International Standard Book Number) of the book.
|
/// Gets the list of ISBN (International Standard Book Number) of the book.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<IsbnModel> ISBNs { get; set; } = [];
|
public List<IsbnDto> ISBNs { get; set; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
|
/// Gets the list of media contributors (actors, directors, etc) starring in this book.
|
||||||
@@ -202,7 +202,7 @@ public class BookModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the list of ratings for this book.
|
/// Gets the list of ratings for this book.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<BookRatingModel> Ratings { get; init; } = [];
|
public List<BookRatingDto> Ratings { get; init; } = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the time and date when the entity was added.
|
/// Gets the time and date when the entity was added.
|
||||||
+5
-5
@@ -1,16 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
|
using Lumina.Presentation.Web.Common.Enums.BookLibrary;
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a book rating.
|
/// Data transfer object for a book rating.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Value}/{MaxValue}")]
|
[DebuggerDisplay("Value: {Value}, MaxValue: {MaxValue}")]
|
||||||
public class BookRatingModel : RatingModel
|
public class BookRatingDto : RatingDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the source of the book rating (e.g., a specific website or platform).
|
/// Gets or sets the source of the book rating (e.g., a specific website or platform).
|
||||||
+4
-4
@@ -2,13 +2,13 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get book series information.
|
/// Data transfer object for a request to get book series information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class BookSeriesModel
|
public class BookSeriesDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the title of the book series.
|
/// Gets or sets the title of the book series.
|
||||||
+4
-4
@@ -3,13 +3,13 @@ using Lumina.Presentation.Web.Common.Enums.BookLibrary;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a request to get ISBN information.
|
/// Data transfer object for a request to get ISBN information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Value} ({Format})")]
|
[DebuggerDisplay("Value: {Value} ({Format})")]
|
||||||
public class IsbnModel
|
public class IsbnDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the ISBN value.
|
/// Gets or sets the ISBN value.
|
||||||
+4
-4
@@ -3,13 +3,13 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a preview of important properties of a book.
|
/// Data transfer object for a preview of important properties of a book.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class LightBookModel
|
public class LightBookDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Id of the media item.
|
/// Gets the Id of the media item.
|
||||||
+10
-10
@@ -1,16 +1,16 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary;
|
namespace Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents written content metadata.
|
/// Data transfer object for written content metadata.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DebuggerDisplay("{Title}")]
|
[DebuggerDisplay("Title: {Title}")]
|
||||||
public class WrittenContentMetadataModel
|
public class WrittenContentMetadataDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the title of the written content.
|
/// Gets or sets the title of the written content.
|
||||||
@@ -30,27 +30,27 @@ public class WrittenContentMetadataModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the release information, including release date and other relevant details.
|
/// Gets or sets the release information, including release date and other relevant details.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReleaseInfoModel? ReleaseInfo { get; set; }
|
public ReleaseInfoDto? ReleaseInfo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of genres associated with the written content.
|
/// Gets or sets the list of genres associated with the written content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<GenreModel>? Genres { get; set; }
|
public List<GenreDto>? Genres { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the list of tags that further describe or categorize the written content.
|
/// Gets or sets the list of tags that further describe or categorize the written content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<TagModel>? Tags { get; set; }
|
public List<TagDto>? Tags { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the language in which the written content is written.
|
/// Gets or sets the language in which the written content is written.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LanguageInfoModel? Language { get; set; }
|
public LanguageInfoDto? Language { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the original language of the written content, if it has been translated.
|
/// Gets or sets the original language of the written content, if it has been translated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LanguageInfoModel? OriginalLanguage { get; set; }
|
public LanguageInfoDto? OriginalLanguage { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the name of the publisher of the written content.
|
/// Gets or sets the name of the publisher of the written content.
|
||||||
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.Configuration;
|
using Lumina.Presentation.Web.Common.DTO.Configuration;
|
||||||
using Lumina.Presentation.Web.Common.Utilities;
|
using Lumina.Presentation.Web.Common.Utilities;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -26,13 +26,13 @@ internal static class PresentationWebLayerConfiguration
|
|||||||
configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||||
configuration.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
|
configuration.AddJsonFile("appsettings.development.json", optional: true, reloadOnChange: true);
|
||||||
|
|
||||||
serviceCollection.AddOptions<ServerConfigurationModel>()
|
serviceCollection.AddOptions<ServerConfigurationDto>()
|
||||||
.Bind(configuration.GetRequiredSection(ServerConfigurationModel.SECTION_NAME))
|
.Bind(configuration.GetRequiredSection(ServerConfigurationDto.SECTION_NAME))
|
||||||
.ValidateFluently()
|
.ValidateFluently()
|
||||||
.ValidateOnStart();
|
.ValidateOnStart();
|
||||||
|
|
||||||
serviceCollection.AddOptions<EncryptionSettingsModel>()
|
serviceCollection.AddOptions<EncryptionSettingsDto>()
|
||||||
.Bind(configuration.GetRequiredSection(EncryptionSettingsModel.SECTION_NAME))
|
.Bind(configuration.GetRequiredSection(EncryptionSettingsDto.SECTION_NAME))
|
||||||
.ValidateFluently()
|
.ValidateFluently()
|
||||||
.ValidateOnStart();
|
.ValidateOnStart();
|
||||||
|
|
||||||
|
|||||||
+61
-14
@@ -1,13 +1,13 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using FastEndpoints;
|
||||||
|
using FastEndpoints.Swagger;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Lumina.Presentation.Web.Common.Api;
|
using Lumina.Presentation.Web.Common.Api;
|
||||||
using Lumina.Presentation.Web.Common.Authorization;
|
using Lumina.Presentation.Web.Common.Authorization;
|
||||||
|
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
||||||
using Lumina.Presentation.Web.Common.Exceptions;
|
using Lumina.Presentation.Web.Common.Exceptions;
|
||||||
using Lumina.Presentation.Web.Common.Filters.ActionFilters;
|
|
||||||
using Lumina.Presentation.Web.Common.Filters.AuthorizationFilters;
|
|
||||||
using Lumina.Presentation.Web.Common.Http;
|
using Lumina.Presentation.Web.Common.Http;
|
||||||
using Lumina.Presentation.Web.Common.MiddlewareFilters;
|
using Lumina.Presentation.Web.Common.Localization;
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
using Lumina.Presentation.Web.Common.Security;
|
using Lumina.Presentation.Web.Common.Security;
|
||||||
using Lumina.Presentation.Web.Common.Services;
|
using Lumina.Presentation.Web.Common.Services;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
@@ -18,6 +18,7 @@ using Microsoft.AspNetCore.HttpOverrides;
|
|||||||
using Microsoft.AspNetCore.Localization;
|
using Microsoft.AspNetCore.Localization;
|
||||||
using Microsoft.AspNetCore.Localization.Routing;
|
using Microsoft.AspNetCore.Localization.Routing;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Localization;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Polly;
|
using Polly;
|
||||||
@@ -49,11 +50,7 @@ public static class PresentationWebLayerServices
|
|||||||
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
|
||||||
public static IServiceCollection AddPresentationWebLayerServices(this IServiceCollection services)
|
public static IServiceCollection AddPresentationWebLayerServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddControllersWithViews(mvcOptions =>
|
services.AddControllersWithViews()
|
||||||
{
|
|
||||||
mvcOptions.Filters.Add(new MiddlewareFilterAttribute(typeof(LocalizationPipeline))); // add localization middleware filter
|
|
||||||
mvcOptions.Filters.Add<StoreLastViewFilter>();
|
|
||||||
})
|
|
||||||
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
|
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
|
||||||
.AddDataAnnotationsLocalization()
|
.AddDataAnnotationsLocalization()
|
||||||
.AddJsonOptions(jsonOptions =>
|
.AddJsonOptions(jsonOptions =>
|
||||||
@@ -62,11 +59,50 @@ public static class PresentationWebLayerServices
|
|||||||
jsonOptions.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
|
jsonOptions.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
|
||||||
jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// configure the locations where the Razor view engine looks for views and layouts, since the views live under the Core directory
|
||||||
|
services.Configure<RazorViewEngineOptions>(razorViewEngineOptions =>
|
||||||
|
{
|
||||||
|
razorViewEngineOptions.ViewLocationFormats.Clear();
|
||||||
|
razorViewEngineOptions.ViewLocationFormats.Add("/Core/Views/{1}/{0}.cshtml");
|
||||||
|
razorViewEngineOptions.ViewLocationFormats.Add("/Core/Views/Shared/{0}.cshtml");
|
||||||
|
});
|
||||||
|
|
||||||
|
// configure the JSON serialization settings used by Results.Json, so that the JSON responses of the endpoints match the MVC responses they replace
|
||||||
|
services.Configure<Microsoft.AspNetCore.Http.Json.JsonOptions>(jsonOptions =>
|
||||||
|
{
|
||||||
|
jsonOptions.SerializerOptions.MaxDepth = 256;
|
||||||
|
jsonOptions.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles; // needed because file system API responses can have very nested structures
|
||||||
|
jsonOptions.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||||
|
});
|
||||||
|
|
||||||
|
// register the FastEndpoints library, which replaces the MVC controllers for handling the application routes
|
||||||
|
services.AddFastEndpoints();
|
||||||
|
// add OpenAPI document generation, so that the endpoints exposed by the web application are discoverable and their contracts are visible
|
||||||
|
services.AddOpenApi();
|
||||||
|
services.SwaggerDocument(documentOptions =>
|
||||||
|
{
|
||||||
|
documentOptions.SerializerSettings = jsonSerializerOptions =>
|
||||||
|
{
|
||||||
|
jsonSerializerOptions.PropertyNamingPolicy = null;
|
||||||
|
jsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
|
||||||
|
};
|
||||||
|
documentOptions.DocumentSettings = aspNetCoreOpenApiDocumentGeneratorSettings =>
|
||||||
|
{
|
||||||
|
aspNetCoreOpenApiDocumentGeneratorSettings.DocumentName = "v1";
|
||||||
|
aspNetCoreOpenApiDocumentGeneratorSettings.Title = "Lumina Web";
|
||||||
|
aspNetCoreOpenApiDocumentGeneratorSettings.Version = "v1";
|
||||||
|
};
|
||||||
|
documentOptions.RemoveEmptyRequestSchema = true;
|
||||||
|
documentOptions.ShortSchemaNames = true;
|
||||||
|
});
|
||||||
// configure URL-based localization
|
// configure URL-based localization
|
||||||
services.AddLocalization(localizationOptions =>
|
services.AddLocalization(localizationOptions =>
|
||||||
{
|
{
|
||||||
localizationOptions.ResourcesPath = "Resources";
|
localizationOptions.ResourcesPath = "Core/Resources";
|
||||||
});
|
});
|
||||||
|
// resolve the resources of the views that live under the Core/Views directory
|
||||||
|
services.AddSingleton<IHtmlLocalizerFactory, CoreHtmlLocalizerFactory>();
|
||||||
|
|
||||||
services.Configure<RequestLocalizationOptions>(requestLocalizationOptions =>
|
services.Configure<RequestLocalizationOptions>(requestLocalizationOptions =>
|
||||||
{
|
{
|
||||||
@@ -190,9 +226,20 @@ public static class PresentationWebLayerServices
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// add an authorization policy that ensures application is initialized with super admin account before allowing access
|
// add authorization policies that ensure the application is initialized with the super admin account before allowing access,
|
||||||
|
// and that restrict access based on the roles and permissions retrieved from the remote API
|
||||||
services.AddAuthorizationBuilder()
|
services.AddAuthorizationBuilder()
|
||||||
.AddPolicy("RequireInitialization", authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new InitializationRequirement()));
|
.AddPolicy(AuthorizationPolicies.REQUIRE_INITIALIZATION, authorizationPolicyBuilder => authorizationPolicyBuilder.Requirements.Add(new InitializationRequirement()))
|
||||||
|
.AddPolicy(AuthorizationPolicies.REQUIRE_ADMIN_ROLE, authorizationPolicyBuilder =>
|
||||||
|
{
|
||||||
|
authorizationPolicyBuilder.Requirements.Add(new RoleRequirement("Admin"));
|
||||||
|
authorizationPolicyBuilder.RequireAuthenticatedUser();
|
||||||
|
})
|
||||||
|
.AddPolicy(AuthorizationPolicies.REQUIRE_CREATE_LIBRARIES_PERMISSION, authorizationPolicyBuilder =>
|
||||||
|
{
|
||||||
|
authorizationPolicyBuilder.Requirements.Add(new PermissionRequirement(AuthorizationPermission.CanCreateLibraries));
|
||||||
|
authorizationPolicyBuilder.RequireAuthenticatedUser();
|
||||||
|
});
|
||||||
|
|
||||||
// add forwarded headers middleware to handle reverse proxy scenarios
|
// add forwarded headers middleware to handle reverse proxy scenarios
|
||||||
services.Configure<ForwardedHeadersOptions>(forwardedHeadersOptions =>
|
services.Configure<ForwardedHeadersOptions>(forwardedHeadersOptions =>
|
||||||
@@ -237,13 +284,13 @@ public static class PresentationWebLayerServices
|
|||||||
.AddPolicyHandler(circuitBreakerPolicy);
|
.AddPolicyHandler(circuitBreakerPolicy);
|
||||||
|
|
||||||
services.AddScoped<CachedAuthorizationHandler>();
|
services.AddScoped<CachedAuthorizationHandler>();
|
||||||
services.AddScoped<ApiAuthorizationFilter>();
|
|
||||||
services.AddScoped<AuthorizationRequirementModel>();
|
|
||||||
|
|
||||||
// enable access to the current HTTP context in non-controller classes
|
// enable access to the current HTTP context in non-controller classes
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
|
|
||||||
services.AddScoped<IAuthorizationHandler, InitializationHandler>();
|
services.AddScoped<IAuthorizationHandler, InitializationHandler>();
|
||||||
|
services.AddScoped<IAuthorizationHandler, RoleAuthorizationHandler>();
|
||||||
|
services.AddScoped<IAuthorizationHandler, PermissionAuthorizationHandler>();
|
||||||
services.AddScoped<Authorization.IAuthorizationService, AuthorizationService>();
|
services.AddScoped<Authorization.IAuthorizationService, AuthorizationService>();
|
||||||
services.AddSingleton<ICryptographyService, CryptographyService>();
|
services.AddSingleton<ICryptographyService, CryptographyService>();
|
||||||
services.AddSingleton<IUrlService, UrlService>();
|
services.AddSingleton<IUrlService, UrlService>();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
#endregion
|
#endregion
|
||||||
@@ -19,7 +19,7 @@ public class ApiException : Exception
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the problem details represented by this exception.
|
/// Gets or sets the problem details represented by this exception.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ProblemDetailsModel? ProblemDetails { get; }
|
public ProblemDetailsDto? ProblemDetails { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the absolute path of the API endpoint that produced this exception.
|
/// Gets or sets the absolute path of the API endpoint that produced this exception.
|
||||||
@@ -32,7 +32,7 @@ public class ApiException : Exception
|
|||||||
/// <param name="problemDetails">The problem details object returned by the API.</param>
|
/// <param name="problemDetails">The problem details object returned by the API.</param>
|
||||||
/// <param name="httpStatusCode">The HTTP status code returned by the API.</param>
|
/// <param name="httpStatusCode">The HTTP status code returned by the API.</param>
|
||||||
/// <param name="requestPath">The absolute path of the API endpoint that produced this exception.</param>
|
/// <param name="requestPath">The absolute path of the API endpoint that produced this exception.</param>
|
||||||
public ApiException(ProblemDetailsModel? problemDetails, HttpStatusCode httpStatusCode, string? requestPath = null) : base(problemDetails?.Title ?? "An error occurred.")
|
public ApiException(ProblemDetailsDto? problemDetails, HttpStatusCode httpStatusCode, string? requestPath = null) : base(problemDetails?.Title ?? "An error occurred.")
|
||||||
{
|
{
|
||||||
ProblemDetails = problemDetails;
|
ProblemDetails = problemDetails;
|
||||||
HttpStatusCode = httpStatusCode;
|
HttpStatusCode = httpStatusCode;
|
||||||
|
|||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Filters.ActionFilters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attribute that enforces application initialization checks on controller actions.
|
|
||||||
/// </summary>
|
|
||||||
public class InitializationCheckAttribute : ActionFilterAttribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Asynchronously executes the initialization check before the action executes.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The context for the action being executed.</param>
|
|
||||||
/// <param name="next">Delegate to execute the next action filter in the pipeline.</param>
|
|
||||||
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
|
||||||
{
|
|
||||||
IAuthorizationService authorizationService = context.HttpContext.RequestServices.GetRequiredService<IAuthorizationService>();
|
|
||||||
await authorizationService.AuthorizeAsync(context.HttpContext.User, context.HttpContext, "RequireInitialization").ConfigureAwait(false);
|
|
||||||
await next().ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Http;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Filters.ActionFilters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stores the current view path in session, for actions that return ViewResult. This is needed because when JWT expires, user is redirected to Login view, with a returnUrl.
|
|
||||||
/// This returnUrl needs to be that of the last displayed view, not of the call that triggered the re-authentication request, which can be an API call for data.
|
|
||||||
/// </summary>
|
|
||||||
public class StoreLastViewFilter : IActionFilter
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Executes before the action method is called.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The action executing context.</param>
|
|
||||||
public void OnActionExecuting(ActionExecutingContext context)
|
|
||||||
{
|
|
||||||
// no action needed before execution
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Executes after the action method is called.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The action executed context containing the action result.</param>
|
|
||||||
public void OnActionExecuted(ActionExecutedContext context)
|
|
||||||
{
|
|
||||||
if (context.Result is ViewResult)
|
|
||||||
{
|
|
||||||
HttpContext httpContext = context.HttpContext;
|
|
||||||
// ignore the login endpoint, because it is incorrect to be redirected to the login URL, with the login URL as the return URL
|
|
||||||
if (httpContext.Request.Path != "/en-us/auth/login")
|
|
||||||
httpContext.Session.SetString(HttpContextItemKeys.LAST_DISPLAYED_VIEW, $"{httpContext.Request.PathBase}{httpContext.Request.Path}{httpContext.Request.QueryString}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-54
@@ -1,54 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Authorization;
|
|
||||||
using Lumina.Presentation.Web.Common.Exceptions;
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Authentication;
|
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Filters.AuthorizationFilters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Implements authorization filter logic for API endpoints by validating user roles, permissions, and policies.
|
|
||||||
/// </summary>
|
|
||||||
public class ApiAuthorizationFilter : IAsyncAuthorizationFilter
|
|
||||||
{
|
|
||||||
private readonly IAuthorizationService _authorizationService;
|
|
||||||
private readonly AuthorizationRequirementModel _requirement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiAuthorizationFilter"/> class.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="authorizationService">Injected service for interactions with the API.</param>
|
|
||||||
/// <param name="requirement">Authorization requirements to evaluate.</param>
|
|
||||||
public ApiAuthorizationFilter(IAuthorizationService authorizationService, AuthorizationRequirementModel requirement)
|
|
||||||
{
|
|
||||||
_authorizationService = authorizationService;
|
|
||||||
_requirement = requirement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Performs authorization for the current request.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="context">The authorization filter context.</param>
|
|
||||||
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!await _authorizationService.EvaluateAuthorizationAsync(_requirement))
|
|
||||||
context.Result = new ForbidResult();
|
|
||||||
}
|
|
||||||
catch (ApiException ex) // TODO: check if it should really catch exceptions here
|
|
||||||
{
|
|
||||||
if (ex.HttpStatusCode == System.Net.HttpStatusCode.Unauthorized)
|
|
||||||
{
|
|
||||||
await context.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme).ConfigureAwait(false);
|
|
||||||
context.HttpContext.Response.Cookies.Delete("Token");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Filters.AuthorizationFilters;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Filters.TypeFilters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Authorization filter for API endpoints.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// This attribute can be applied to both classes and methods and supports multiple instances on the same target.
|
|
||||||
/// </remarks>
|
|
||||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
|
|
||||||
public class ApiAuthorizationAttribute : TypeFilterAttribute
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Initializes a new instance of the <see cref="ApiAuthorizationAttribute"/> class.
|
|
||||||
/// </summary>
|
|
||||||
public ApiAuthorizationAttribute() : base(typeof(ApiAuthorizationFilter))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Infrastructure;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||||
|
using Microsoft.AspNetCore.Routing;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Http;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="IResult"/> that renders a Razor view through the MVC view engine, enabling FastEndpoints endpoints to serve the Razor views of the application.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The <see cref="Results"/> class does not expose a method for rendering Razor views, so this custom result reuses the MVC
|
||||||
|
/// <see cref="ViewResult"/> execution machinery, which preserves layouts, sections, view components and tag helpers.
|
||||||
|
/// </remarks>
|
||||||
|
public sealed class RazorViewResult : IResult
|
||||||
|
{
|
||||||
|
private readonly string _viewName;
|
||||||
|
private readonly object? _model;
|
||||||
|
private readonly IReadOnlyDictionary<string, object?> _viewData;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RazorViewResult"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="viewName">The name or path of the view to render.</param>
|
||||||
|
/// <param name="model">The model to pass to the view.</param>
|
||||||
|
/// <param name="viewData">Optional additional view data entries made available to the view via <c>ViewData</c>.</param>
|
||||||
|
public RazorViewResult(string viewName, object? model = null, IReadOnlyDictionary<string, object?>? viewData = null)
|
||||||
|
{
|
||||||
|
_viewName = viewName;
|
||||||
|
_model = model;
|
||||||
|
_viewData = viewData ?? new Dictionary<string, object?>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Renders the configured Razor view to the response.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="httpContext">The <see cref="HttpContext"/> for the current request.</param>
|
||||||
|
public async Task ExecuteAsync(HttpContext httpContext)
|
||||||
|
{
|
||||||
|
// the only accessible ViewDataDictionary constructors require either a model state or an existing dictionary, so start from an empty one and assign the model
|
||||||
|
// through the Model setter; the setter rebases the model metadata on the runtime type of the value, which is what makes the asp-for tag helpers resolve the
|
||||||
|
// properties of the actual model type instead of a plain object
|
||||||
|
IModelMetadataProvider metadataProvider = httpContext.RequestServices.GetRequiredService<IModelMetadataProvider>();
|
||||||
|
ViewDataDictionary viewData = new(metadataProvider, new ModelStateDictionary()) { Model = _model };
|
||||||
|
foreach ((string key, object? value) in _viewData)
|
||||||
|
viewData[key] = value;
|
||||||
|
|
||||||
|
// delegate to the MVC view execution machinery instead of rendering the view manually: it discovers the layout and _ViewStart, evaluates the sections,
|
||||||
|
// and resolves the view components and tag helpers, none of which the Results class can do since it has no view rendering support
|
||||||
|
ViewResult viewResult = new() { ViewName = _viewName, ViewData = viewData };
|
||||||
|
IActionResultExecutor<ViewResult> executor = httpContext.RequestServices.GetRequiredService<IActionResultExecutor<ViewResult>>();
|
||||||
|
// the view engine needs an ActionContext, which FastEndpoints does not provide; synthesize one that carries over the current route data, so that the
|
||||||
|
// culture route value (and therefore the URL-based localization) keeps working while the view is rendered
|
||||||
|
ActionContext actionContext = new(httpContext, httpContext.GetRouteData() ?? new RouteData(), new ActionDescriptor());
|
||||||
|
await executor.ExecuteAsync(actionContext, viewResult).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using Microsoft.AspNetCore.Mvc.Localization;
|
||||||
|
using Microsoft.Extensions.Localization;
|
||||||
|
using System;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Localization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <see cref="IHtmlLocalizerFactory"/> that resolves the resources of the views that live under the <c>Core/Views</c> directory.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// The view localizer derives the resource base name from the executing view path, so a view at <c>/Core/Views/Auth/Login.cshtml</c> produces the base name
|
||||||
|
/// <c>{ApplicationName}.Core.Views.Auth.Login</c>. Because the <c>Core</c> segment is only the directory that hosts the views and not part of the resource path,
|
||||||
|
/// it is stripped here, so that the resources are looked up at <c>{ApplicationName}.Core.Resources.Views.Auth.Login</c>, matching the resource files under
|
||||||
|
/// <c>Core/Resources/Views/Auth</c>.
|
||||||
|
/// </remarks>
|
||||||
|
public class CoreHtmlLocalizerFactory : IHtmlLocalizerFactory
|
||||||
|
{
|
||||||
|
private readonly HtmlLocalizerFactory _innerFactory;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="CoreHtmlLocalizerFactory"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stringLocalizerFactory">Injected factory used to create the underlying string localizers.</param>
|
||||||
|
public CoreHtmlLocalizerFactory(IStringLocalizerFactory stringLocalizerFactory)
|
||||||
|
{
|
||||||
|
_innerFactory = new HtmlLocalizerFactory(stringLocalizerFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an <see cref="IHtmlLocalizer"/> for the specified base name and location.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="baseName">The base name of the resource to load strings from.</param>
|
||||||
|
/// <param name="location">The location to load resources from.</param>
|
||||||
|
/// <returns>The created <see cref="IHtmlLocalizer"/>.</returns>
|
||||||
|
public IHtmlLocalizer Create(string baseName, string location)
|
||||||
|
{
|
||||||
|
string prefix = location + ".Core.";
|
||||||
|
string resourceBaseName = baseName.StartsWith(prefix, StringComparison.Ordinal)
|
||||||
|
? location + "." + baseName.Substring(prefix.Length)
|
||||||
|
: baseName;
|
||||||
|
return _innerFactory.Create(resourceBaseName, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates an <see cref="IHtmlLocalizer"/> for the specified resource source type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="resourceSource">The type of the resource to load strings from.</param>
|
||||||
|
/// <returns>The created <see cref="IHtmlLocalizer"/>.</returns>
|
||||||
|
public IHtmlLocalizer Create(Type resourceSource)
|
||||||
|
{
|
||||||
|
return _innerFactory.Create(resourceSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Localization;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.MiddlewareFilters;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines a pipeline for configuring middleware to handle localization.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// To use a MiddlewareFilter, you first need to create a pipeline. This acts as a mini startup configuration where you define an <see cref="IApplicationBuilder"/>
|
|
||||||
/// to specify the middleware that should run as part of the pipeline. Multiple middleware can be configured in this way.
|
|
||||||
/// </remarks>
|
|
||||||
public class LocalizationPipeline
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Configures the middleware pipeline to include the <see cref="RequestLocalizationMiddleware"/> for handling localization.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="app">The <see cref="IApplicationBuilder"/> used to configure the middleware pipeline.</param>
|
|
||||||
/// <param name="options">The <see cref="IOptions{TOptions}"/> instance for <see cref="RequestLocalizationOptions"/>, containing localization settings to be applied.</param>
|
|
||||||
public void Configure(IApplicationBuilder app, IOptions<RequestLocalizationOptions> options)
|
|
||||||
{
|
|
||||||
// runs the RequestLocalizationMiddleware with the provided options
|
|
||||||
app.UseRequestLocalization(options.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
|
||||||
using System;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Model for storing the authorization requirements for accessing a resource.
|
|
||||||
/// </summary>
|
|
||||||
public class AuthorizationRequirementModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The collection of roles required for accessing the resource.
|
|
||||||
/// </summary>
|
|
||||||
public string[]? Roles { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The collection of permissions required for accessing the resource.
|
|
||||||
/// </summary>
|
|
||||||
public AuthorizationPermission[]? Permissions { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The type of the policy required for accessing the resource.
|
|
||||||
/// </summary>
|
|
||||||
public Type? PolicyType { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Enums.Authorization;
|
|
||||||
using System;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a model for an authorization permission.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Id">The unique identifier of the authorization permission.</param>
|
|
||||||
/// <param name="PermissionName">The authorization permission.</param>
|
|
||||||
public record PermissionModel(
|
|
||||||
Guid Id,
|
|
||||||
AuthorizationPermission PermissionName
|
|
||||||
);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a model for an authorization role.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Id">The unique identifier of the authorization role.</param>
|
|
||||||
/// <param name="RoleName">The authorization role.</param>
|
|
||||||
public record RoleModel(
|
|
||||||
Guid Id,
|
|
||||||
string RoleName
|
|
||||||
);
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the request model for updating an existing authorization role.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="RoleId">The unique identifier of the role.</param>
|
|
||||||
/// <param name="RoleName">The name of the role.</param>
|
|
||||||
/// <param name="Permissions">The collection of Ids of the permissions of the role.</param>
|
|
||||||
public record UpdateRoleRequestModel(
|
|
||||||
Guid RoleId,
|
|
||||||
string? RoleName,
|
|
||||||
List<Guid>? Permissions
|
|
||||||
);
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the request model for updating the authorization role and permissions of a user.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="RoleId">The unique identifier of the user.</param>
|
|
||||||
/// <param name="RoleId">The unique identifier of the role.</param>
|
|
||||||
/// <param name="Permissions">The collection of Ids of the permissions of the user.</param>
|
|
||||||
public record UpdateUserRoleAndPermissionsRequestModel(
|
|
||||||
Guid UserId,
|
|
||||||
Guid? RoleId,
|
|
||||||
List<Guid>? Permissions
|
|
||||||
);
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace Lumina.Presentation.Web.Common.Models.Common;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Record used for empty requests and responses.
|
|
||||||
/// </summary>
|
|
||||||
public record struct EmptyModel();
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Model for directories displayed in custom directory/file browser dialogs.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{Path}")]
|
|
||||||
public class DirectoryModel : FileSystemItemModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the children items of the directory.
|
|
||||||
/// </summary>
|
|
||||||
public List<FileSystemItemModel> Items { get; set; } = [];
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Model for files displayed in custom directory/file browser dialogs.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{Path}")]
|
|
||||||
public class FileModel : FileSystemItemModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the size of the file, in bytes
|
|
||||||
/// </summary>
|
|
||||||
public long Size { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Enums.FileSystem;
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Model containing the file system platform type.
|
|
||||||
/// </summary>`
|
|
||||||
[DebuggerDisplay("{PlatformType}")]
|
|
||||||
public class FileSystemTypeModel
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the file system platform type.
|
|
||||||
/// </summary>
|
|
||||||
public PlatformType PlatformType { get; set; }
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a response to the inquiry about the existence of a file system path.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Exists">Whether a file system path exists or not.</param>
|
|
||||||
[DebuggerDisplay("{Exists}")]
|
|
||||||
public record PathExistsModel(
|
|
||||||
bool Exists
|
|
||||||
);
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A model representing a file system path separator.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Separator">The system's path separator.</param>
|
|
||||||
[DebuggerDisplay("{Separator}")]
|
|
||||||
public record PathSeparatorModel(
|
|
||||||
string Separator
|
|
||||||
);
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.FileSystemManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a response to the inquiry about the validity of a file system path.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="IsValid">Whether a file system path is valid or not.</param>
|
|
||||||
[DebuggerDisplay("{IsValid}")]
|
|
||||||
public record PathValidModel(
|
|
||||||
bool IsValid
|
|
||||||
);
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
namespace Lumina.Presentation.Web.Common.Models.UsersManagement;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the request model for account password change.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Username">The username of the account.</param>
|
|
||||||
/// <param name="CurrentPassword">The current password of the account.</param>
|
|
||||||
/// <param name="NewPassword">The new password of the account.</param>
|
|
||||||
/// <param name="NewPasswordConfirm">The confirmation of the new password of the account.</param>
|
|
||||||
public record ChangePasswordRequestModel(
|
|
||||||
string? Username,
|
|
||||||
string? CurrentPassword,
|
|
||||||
string? NewPassword,
|
|
||||||
string? NewPasswordConfirm
|
|
||||||
);
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
|
||||||
using Lumina.Presentation.Web.Common.Models.Common;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.WrittenContentLibrary.BookLibrary;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents a book.
|
|
||||||
/// </summary>
|
|
||||||
[DebuggerDisplay("{Title}")]
|
|
||||||
public class BooksModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
+7
-5
@@ -1,16 +1,18 @@
|
|||||||
#region ========================================================================= USING =====================================================================================
|
#region ========================================================================= USING =====================================================================================
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Lumina.Presentation.Web.Common.Models.Authorization;
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the request model for adding an authorization role.
|
/// Represents a request for adding an authorization role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="RoleName">The name of the role.</param>
|
/// <param name="RoleName">The name of the role. Required.</param>
|
||||||
/// <param name="Permissions">The collection or permissions of the role.</param>
|
/// <param name="Permissions">The collection or permissions of the role. Required.</param>
|
||||||
public record AddRoleRequestModel(
|
[DebuggerDisplay("RoleName: {RoleName}")]
|
||||||
|
public record AddRoleRequest(
|
||||||
string? RoleName,
|
string? RoleName,
|
||||||
List<Guid>? Permissions
|
List<Guid>? Permissions
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request for deleting an authorization role.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RoleId">The unique identifier of the role. Required.</param>
|
||||||
|
[DebuggerDisplay("RoleId: {RoleId}")]
|
||||||
|
public record DeleteRoleRequest(
|
||||||
|
Guid RoleId
|
||||||
|
);
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request to get the authorization permissions of a role identified by <paramref name="RoleId"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RoleId">The Id of authorization role. Required.</param>
|
||||||
|
[DebuggerDisplay("RoleId: {RoleId}")]
|
||||||
|
public record GetRolePermissionsRequest(
|
||||||
|
Guid RoleId
|
||||||
|
);
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the request model for retrieving the authorization permissions of a user identified by <paramref name="UserId"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="UserId">The unique identifier of the user for whom to get the authorization permissions. Required.</param>
|
||||||
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
|
public record GetUserPermissionsRequest(
|
||||||
|
Guid UserId
|
||||||
|
);
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the request model for retrieving the authorization role of a user identified by <paramref name="UserId"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="UserId">The unique identifier of the user for whom to get the authorization role. Required.</param>
|
||||||
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
|
public record GetUserRoleRequest(
|
||||||
|
Guid UserId
|
||||||
|
);
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request for updating an existing authorization role.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="RoleId">The unique identifier of the role. Required.</param>
|
||||||
|
/// <param name="RoleName">The name of the role. Required.</param>
|
||||||
|
/// <param name="Permissions">The collection of Ids of the permissions of the role. Required.</param>
|
||||||
|
[DebuggerDisplay("RoleName: {RoleName}")]
|
||||||
|
public record UpdateRoleRequest(
|
||||||
|
Guid RoleId,
|
||||||
|
string? RoleName,
|
||||||
|
List<Guid>? Permissions
|
||||||
|
);
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request for updating the authorization role and permissions of a user.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="UserId">The unique identifier of the user. Required.</param>
|
||||||
|
/// <param name="RoleId">The unique identifier of the role. Optional.</param>
|
||||||
|
/// <param name="Permissions">The collection of Ids of the permissions of the role. Optional.</param>
|
||||||
|
[DebuggerDisplay("UserId: {UserId}")]
|
||||||
|
public record UpdateUserRoleAndPermissionsRequest(
|
||||||
|
Guid UserId,
|
||||||
|
Guid? RoleId,
|
||||||
|
List<Guid>? Permissions
|
||||||
|
);
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Lumina.Presentation.Web.Common.Requests.Common;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Record used for empty requests and responses.
|
||||||
|
/// </summary>
|
||||||
|
public record struct EmptyRequest();
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request to get the directories of a file system path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Path">The file system path for which to get the directories. Required.</param>
|
||||||
|
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
|
||||||
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
|
public record GetDirectoriesRequest(
|
||||||
|
string? Path,
|
||||||
|
bool IncludeHiddenElements
|
||||||
|
);
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#region ========================================================================= USING =====================================================================================
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a request to get the files at a file system path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Path">The file system path for which to get the files. Required.</param>
|
||||||
|
/// <param name="IncludeHiddenElements">Whether to include hidden file system elements or not. Optional.</param>
|
||||||
|
[DebuggerDisplay("Path: {Path}")]
|
||||||
|
public record GetFilesRequest(
|
||||||
|
string? Path,
|
||||||
|
bool IncludeHiddenElements
|
||||||
|
);
|
||||||
Loaded 100 of 596 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user