Compare commits
No commits in common. "e8450400c7fbd90833595bf05f5dd2a432d5ac17" and "ae0f437e2c6cab0f129315184996ac2c73f0f44e" have entirely different histories.
e8450400c7
...
ae0f437e2c
@ -5,9 +5,9 @@
|
|||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Company>Winsomnia</Company>
|
<Company>Winsomnia</Company>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0-a0</Version>
|
||||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.3.0</FileVersion>
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
<AssemblyName>Mirea.Api.Dto</AssemblyName>
|
<AssemblyName>Mirea.Api.Dto</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||||
|
@ -9,11 +9,10 @@ namespace Mirea.Api.Endpoint.Common.Attributes;
|
|||||||
[AttributeUsage(AttributeTargets.Method)]
|
[AttributeUsage(AttributeTargets.Method)]
|
||||||
public class TokenAuthenticationAttribute : Attribute, IActionFilter
|
public class TokenAuthenticationAttribute : Attribute, IActionFilter
|
||||||
{
|
{
|
||||||
public const string AuthToken = "AuthToken";
|
|
||||||
public void OnActionExecuting(ActionExecutingContext context)
|
public void OnActionExecuting(ActionExecutingContext context)
|
||||||
{
|
{
|
||||||
var setupToken = context.HttpContext.RequestServices.GetRequiredService<ISetupToken>();
|
var setupToken = context.HttpContext.RequestServices.GetRequiredService<ISetupToken>();
|
||||||
if (!context.HttpContext.Request.Cookies.TryGetValue(AuthToken, out string? tokenFromCookie))
|
if (!context.HttpContext.Request.Cookies.TryGetValue("AuthToken", out string? tokenFromCookie))
|
||||||
{
|
{
|
||||||
context.Result = new UnauthorizedResult();
|
context.Result = new UnauthorizedResult();
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Versioning;
|
using Microsoft.AspNetCore.Mvc.Versioning;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class ApiVersioningConfiguration
|
public static class ApiVersioningConfiguration
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Mirea.Api.Endpoint.Common.Settings;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
using Mirea.Api.Endpoint.Configuration.General.Settings;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class CacheConfiguration
|
public static class CacheConfiguration
|
||||||
{
|
{
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class EnvironmentConfiguration
|
public static class EnvironmentConfiguration
|
||||||
{
|
{
|
@ -7,7 +7,7 @@ using Mirea.Api.Security.Common.Interfaces;
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class JwtConfiguration
|
public static class JwtConfiguration
|
||||||
{
|
{
|
@ -9,7 +9,7 @@ using Serilog.Filters;
|
|||||||
using Serilog.Formatting.Compact;
|
using Serilog.Formatting.Compact;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class LoggerConfiguration
|
public static class LoggerConfiguration
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ using Mirea.Api.Endpoint.Configuration.General.Settings;
|
|||||||
using Mirea.Api.Security;
|
using Mirea.Api.Security;
|
||||||
using Mirea.Api.Security.Common.Interfaces;
|
using Mirea.Api.Security.Common.Interfaces;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class SecureConfiguration
|
public static class SecureConfiguration
|
||||||
{
|
{
|
@ -4,12 +4,12 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
using Mirea.Api.Endpoint.Configuration.SwaggerOptions;
|
using Mirea.Api.Endpoint.Configuration.Swagger;
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
namespace Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
|
|
||||||
public static class SwaggerConfiguration
|
public static class SwaggerConfiguration
|
||||||
{
|
{
|
@ -5,7 +5,7 @@ using Microsoft.OpenApi.Models;
|
|||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions;
|
namespace Mirea.Api.Endpoint.Configuration.Swagger;
|
||||||
|
|
||||||
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
|
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
|
||||||
{
|
{
|
@ -6,7 +6,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions;
|
namespace Mirea.Api.Endpoint.Configuration.Swagger;
|
||||||
|
|
||||||
public class SwaggerDefaultValues : IOperationFilter
|
public class SwaggerDefaultValues : IOperationFilter
|
||||||
{
|
{
|
@ -3,7 +3,7 @@ using Mirea.Api.Endpoint.Common.Attributes;
|
|||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions;
|
namespace Mirea.Api.Endpoint.Configuration.Swagger;
|
||||||
|
|
||||||
public class SwaggerExampleFilter : ISchemaFilter
|
public class SwaggerExampleFilter : ISchemaFilter
|
||||||
{
|
{
|
@ -20,7 +20,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Mail;
|
using System.Net.Mail;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
@ -69,10 +68,9 @@ public class SetupController(
|
|||||||
[HttpGet("CheckToken")]
|
[HttpGet("CheckToken")]
|
||||||
public ActionResult<bool> CheckToken([FromQuery] string token)
|
public ActionResult<bool> CheckToken([FromQuery] string token)
|
||||||
{
|
{
|
||||||
if (!setupToken.MatchToken(Convert.FromBase64String(token)))
|
if (!setupToken.MatchToken(Convert.FromBase64String(token))) return Unauthorized("The token is not valid");
|
||||||
return Unauthorized("The token is not valid");
|
|
||||||
|
|
||||||
Response.Cookies.Append(TokenAuthenticationAttribute.AuthToken, token, new CookieOptions
|
Response.Cookies.Append("AuthToken", token, new CookieOptions
|
||||||
{
|
{
|
||||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||||
Domain = HttpContext.GetCurrentDomain(),
|
Domain = HttpContext.GetCurrentDomain(),
|
||||||
@ -95,10 +93,6 @@ public class SetupController(
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
connection.Close();
|
connection.Close();
|
||||||
|
|
||||||
if (connection is SqliteConnection)
|
|
||||||
SqliteConnection.ClearAllPools();
|
|
||||||
}
|
|
||||||
|
|
||||||
var general = GeneralConfig;
|
var general = GeneralConfig;
|
||||||
general.DbSettings = new DbSettings
|
general.DbSettings = new DbSettings
|
||||||
{
|
{
|
||||||
@ -158,21 +152,12 @@ public class SetupController(
|
|||||||
else
|
else
|
||||||
Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite);
|
Directory.CreateDirectory(path, UnixFileMode.UserRead | UnixFileMode.UserWrite);
|
||||||
}
|
}
|
||||||
else if (Directory.GetDirectories(path).Length != 0 ||
|
else
|
||||||
!Directory.GetFiles(path).Select(x => string.Equals(Path.GetFileName(x), "database.db3")).All(x => x))
|
|
||||||
throw new ControllerArgumentException("Such a folder exists. Enter a different name");
|
throw new ControllerArgumentException("Such a folder exists. Enter a different name");
|
||||||
|
|
||||||
var filePath = Path.Combine(path, "database.db3");
|
string connectionString = $"Data Source={PathBuilder.Combine(path, "database.db3")}";
|
||||||
var connectionString = $"Data Source={filePath}";
|
|
||||||
|
|
||||||
//System.IO.File.Create(filePath);
|
return SetDatabase<SqliteConnection, SqliteException>(connectionString, DbSettings.DatabaseEnum.Sqlite);
|
||||||
|
|
||||||
var result = SetDatabase<SqliteConnection, SqliteException>(connectionString, DbSettings.DatabaseEnum.Sqlite);
|
|
||||||
|
|
||||||
foreach (var file in Directory.GetFiles(path))
|
|
||||||
System.IO.File.Delete(file);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("SetRedis")]
|
[HttpPost("SetRedis")]
|
||||||
@ -226,7 +211,7 @@ public class SetupController(
|
|||||||
[BadRequestResponse]
|
[BadRequestResponse]
|
||||||
public ActionResult<string> CreateAdmin([FromBody] CreateUserRequest user)
|
public ActionResult<string> CreateAdmin([FromBody] CreateUserRequest user)
|
||||||
{
|
{
|
||||||
if (!PasswordHashService.HasPasswordInPolicySecurity(user.Password))
|
if (PasswordHashService.HasPasswordInPolicySecurity(user.Password))
|
||||||
throw new ControllerArgumentException("The password must be at least 8 characters long and contain at least one uppercase letter and one special character.");
|
throw new ControllerArgumentException("The password must be at least 8 characters long and contain at least one uppercase letter and one special character.");
|
||||||
|
|
||||||
if (!MailAddress.TryCreate(user.Email, out _))
|
if (!MailAddress.TryCreate(user.Email, out _))
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Company>Winsomnia</Company>
|
<Company>Winsomnia</Company>
|
||||||
<Version>1.0.0-rc0</Version>
|
<Version>1.0.0-b3</Version>
|
||||||
<AssemblyVersion>1.0.2.0</AssemblyVersion>
|
<AssemblyVersion>1.0.1.3</AssemblyVersion>
|
||||||
<FileVersion>1.0.2.0</FileVersion>
|
<FileVersion>1.0.1.3</FileVersion>
|
||||||
<AssemblyName>Mirea.Api.Endpoint</AssemblyName>
|
<AssemblyName>Mirea.Api.Endpoint</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
@ -34,8 +34,8 @@
|
|||||||
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.8" />
|
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.8" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.7.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.7.2" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore.Versioning" Version="2.0.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore.Versioning" Version="2.0.0" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -11,7 +11,7 @@ using Mirea.Api.DataAccess.Persistence.Common;
|
|||||||
using Mirea.Api.Endpoint.Common.Interfaces;
|
using Mirea.Api.Endpoint.Common.Interfaces;
|
||||||
using Mirea.Api.Endpoint.Common.Services;
|
using Mirea.Api.Endpoint.Common.Services;
|
||||||
using Mirea.Api.Endpoint.Common.Settings;
|
using Mirea.Api.Endpoint.Common.Settings;
|
||||||
using Mirea.Api.Endpoint.Configuration.ApplicationConfiguration;
|
using Mirea.Api.Endpoint.Configuration.AppConfig;
|
||||||
using Mirea.Api.Endpoint.Configuration.General;
|
using Mirea.Api.Endpoint.Configuration.General;
|
||||||
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
using Mirea.Api.Endpoint.Configuration.General.Validators;
|
||||||
using Mirea.Api.Endpoint.Middleware;
|
using Mirea.Api.Endpoint.Middleware;
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Company>Winsomnia</Company>
|
<Company>Winsomnia</Company>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0-rc0</Version>
|
||||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
<AssemblyVersion>1.0.2.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.3.0</FileVersion>
|
<FileVersion>1.0.2.0</FileVersion>
|
||||||
<AssemblyName>Mirea.Api.Security</AssemblyName>
|
<AssemblyName>Mirea.Api.Security</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Company>Winsomnia</Company>
|
<Company>Winsomnia</Company>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0-rc0</Version>
|
||||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
<AssemblyVersion>1.0.2.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.3.0</FileVersion>
|
<FileVersion>1.0.2.0</FileVersion>
|
||||||
<AssemblyName>Mirea.Api.DataAccess.Application</AssemblyName>
|
<AssemblyName>Mirea.Api.DataAccess.Application</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
<ImplicitUsings>disable</ImplicitUsings>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Company>Winsomnia</Company>
|
<Company>Winsomnia</Company>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0-rc0</Version>
|
||||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
<AssemblyVersion>1.0.2.0</AssemblyVersion>
|
||||||
<FileVersion>1.0.3.0</FileVersion>
|
<FileVersion>1.0.2.0</FileVersion>
|
||||||
<AssemblyName>Mirea.Api.DataAccess.Persistence</AssemblyName>
|
<AssemblyName>Mirea.Api.DataAccess.Persistence</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user