refactoring
This commit is contained in:
@ -6,6 +6,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.13" />
|
||||
<ProjectReference Include="../Yavsc/Yavsc.csproj" />
|
||||
<ProjectReference Include="../Yavsc.Server/Yavsc.Server.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -9,11 +9,11 @@ namespace Yavsc.ApiControllers
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Exceptions;
|
||||
using Yavsc.Models.FileSystem;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using System.IO;
|
||||
using Yavsc.Exceptions;
|
||||
|
||||
[Authorize,Route("api/fs")]
|
||||
public partial class FileSystemApiController : Controller
|
||||
|
@ -12,9 +12,9 @@ namespace Yavsc.ApiControllers
|
||||
using Services;
|
||||
|
||||
using Models.Messaging;
|
||||
using ViewModels.Auth;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.ViewModels.Auth;
|
||||
|
||||
[Route("api/bill"), Authorize]
|
||||
public class BillingController : Controller
|
||||
|
@ -10,7 +10,10 @@
|
||||
copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Models;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
@ -55,7 +58,16 @@ internal class Program
|
||||
options.TokenValidationParameters =
|
||||
new() { ValidateAudience = false };
|
||||
});
|
||||
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
||||
services.AddScoped<UserManager<ApplicationUser>>();
|
||||
|
||||
builder.Services.AddSession();
|
||||
|
||||
/*services.AddTransient<ITrueEmailSender, MailSender>()
|
||||
.AddTransient<IYavscMessageSender, YavscMessageSender>()
|
||||
.AddTransient<IBillingService, BillingService>()
|
||||
.AddTransient<ICalendarManager, CalendarManager>();*/
|
||||
using (var app = builder.Build())
|
||||
{
|
||||
if (app.Environment.IsDevelopment())
|
||||
@ -66,20 +78,21 @@ internal class Program
|
||||
.UseAuthentication()
|
||||
.UseAuthorization().UseCors("default")
|
||||
.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute()
|
||||
.RequireAuthorization();
|
||||
});
|
||||
|
||||
{
|
||||
endpoints.MapDefaultControllerRoute()
|
||||
.RequireAuthorization();
|
||||
});
|
||||
|
||||
app.MapGet("/identity", (HttpContext context) =>
|
||||
new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value }))
|
||||
).RequireAuthorization("ApiScope");
|
||||
|
||||
|
||||
app.UseSession();
|
||||
await app.RunAsync();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
1
src/Api/tempkey.jwk
Normal file
1
src/Api/tempkey.jwk
Normal file
@ -0,0 +1 @@
|
||||
{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"V1qxZgyKyWNi8FbeueGjfOae22fnDa0dU8YpTohrjn89bk9B8kvIzFJP9IPYThTLMaKCTFN09A3aVy_zhL5Cv2ebEqkZIpXkPmtvRavAYxoSQWUfN2czMok216KI7csVVk79csLnnO6i3pf0B9OgGwsuEsLR40_X4MTy5iTejZfwEVobN7H6_uylw5dEUjcJlR-RtuXAZz48stOLt8-y9it7rvowv8eHEsAFSaiV-g92rKZdvMdxVqW5dvHkqF4-h1gdp9VvStZYsqfnR8hrObSxom5yWFnpmxZKmaFaFxbF-k9T8YX1izuPzESPyKCUb-GX5_4sLB6vOiUO4drHiQ","DP":"7Vz77Jz00YuT87QDAEHuBl-GInvI2VT1Fg0HsUEUhBN_o1ZwqlgX6U_3yGUgYYvoWQZZQeLTxRiQSzymPxXiikKnmGt97zMypIllEOar284Ddypa4fraXSJwgKR-1UPYGZg1adjN3KDruLok3ahyUcD9375tCXmQ3Cs0QC1_ATs","DQ":"B5qgaCcQGleo-zZqWIjMCtyEyB4JBbPFtKk3uZ5KAV8lO-TQPJkohraRxInOUHoSS1O2hj1bUO1r-C29XJqrkhi2APGs2hu6V11cmAtwwhj5XPTnL_TNx314dK5ECEQ231gxidfod-6PknG20Qim7sacsj5OrJHfp9RnMZ2p4fk","E":"AQAB","K":null,"KeyId":"E7139A7A77AEA502B0482C026DCE5C59","KeyOps":[],"Kid":"E7139A7A77AEA502B0482C026DCE5C59","Kty":"RSA","N":"tL1q9Mon5IGTGYvBg_FmDoxy0HWQ0ceo6iZmDMzAkjYZ06KKdWoR7Up2ZJ7NrBnGpyrb1uR9qAJAAJm19SLKDKSrEUn5QcnTDMqVQLBurtXYw-eY2DL4cO0bbetc5_z8hyKUzikf6jJRRGfDSR2nEfXwUf3riYfYXtNgSmr_CsBwPUcH12JGad0bwsqJy7z9Tg2_pWvNR36Ba5qd_6VmkLQRGQuDTcHzwbagd3bl4Ma1bzxPULBiBENfj6srAxV-6gQhCJr3mIr1ZsJcZsrYuUnnBNgzYCZvkOkmyB68PlrV9C9xQO8aQfla2s42Uc12-UhBbreI0uBP_k8PXXXjXw","Oth":[],"P":"_jaZkNClDqxS8nddu2t6pgP596qJdzMAq11JVWAoDJV_9JRUZH2Qbq2CrDRUjRF9nxR2bVTglfzZ-bho-Iy9PqcWeVekLObiyR30zmUzoWCdUhmi-BRd3FF3uSteNPc7ohtuX4SrbbCoUR4BpcBAgHas8KKj80sIPpoYo10xK-s","Q":"tgKedcJQilsxEzRRbs8_XD4MxnsmrxqvccfvzzHkqqZMNI0CMGA41ddHiWdNcYsyzqIc-vCf6OGabD6Z7mzZXPbYsr1o4rIQXveUy3Ty3fD9YCRKgWbS9gTbXNGBFAglu3iyNl1XUCGc_DF8PImgk99pu9byPoIr6rAPhciaDV0","QI":"2wtLbwL9kODL6HoF5R8CFmf0Fz3gqoEetrq_I7wuK1pL2vmpZlzmURjvERhi5T6lD2L8SC1vY4AJ7NGzAncwn5ozpnos2s0YIxHYUixj5RuTWQLPKqk5r1bEORuju8KwfW6Nzc4K6Rhk3Lb3TXDvKi6BSf1URjLtiI8DUB_enxw","Use":null,"X":null,"X5c":[],"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":16}}
|
@ -37,7 +37,7 @@ namespace Yavsc
|
||||
public const string FrontOfficeGroupName = "FrontOffice";
|
||||
public const string DefaultAvatar = "/images/Users/icon_user.png";
|
||||
public const string AnonAvatar = "/images/Users/icon_anon_user.png";
|
||||
public const string YavscConnectionStringEnvName = "YAVSC_DB_CONNECTION";
|
||||
public const string YavscConnectionStringEnvName = "DEFAULTCONNECTION_CONNECTIONSTRING";
|
||||
|
||||
// at the end, let 4*4 bytes in peace
|
||||
public const int WebSocketsMaxBufLen = 4096;
|
||||
|
@ -1 +0,0 @@
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
</packages>
|
@ -1,6 +1,8 @@
|
||||
|
||||
using IdentityServer8;
|
||||
using IdentityServer8.Models;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Yavsc.Settings;
|
||||
|
||||
namespace Yavsc;
|
@ -3,18 +3,27 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Yavsc.Exceptions;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.FileSystem;
|
||||
using Yavsc.Models.Streaming;
|
||||
using Yavsc.ViewModels;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Yavsc.Exceptions;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
public static class FileSystemHelpers
|
||||
{
|
||||
public static async Task SaveAsAsync(this IFormFile formFile, string path)
|
||||
{
|
||||
if (formFile.Length > 0) {
|
||||
using (Stream fileStream = new FileStream(path, FileMode.Create)) {
|
||||
await formFile.CopyToAsync(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static FileRecievedInfo ReceiveProSignature(this ClaimsPrincipal user, string billingCode, long estimateId, IFormFile formFile, string signtype)
|
||||
{
|
||||
var item = new FileRecievedInfo
|
||||
@ -258,9 +267,5 @@ namespace Yavsc.Helpers
|
||||
return $"{basename}-{flow.SequenceNumber}{ext}";
|
||||
}
|
||||
|
||||
public static void SaveAs(this IFormFile file, string destFileName)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Html;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Yavsc.Models.Drawing;
|
||||
|
||||
namespace Yavsc.Helpers
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user