mirror of
https://github.com/azaion/admin.git
synced 2026-04-22 11:06:33 +00:00
secure getinstaller endpoint
This commit is contained in:
+18
-4
@@ -210,18 +210,32 @@ app.MapPost("/resources/get/{dataFolder?}", //Need to have POST method for secur
|
||||
}).RequireAuthorization()
|
||||
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Gets encrypted by users Password and HardwareHash resources. POST method for secure password"});
|
||||
|
||||
app.MapGet("/resources/get-installer/{dataFolder?}",
|
||||
async ([FromRoute]string? dataFolder, IAuthService authService, IResourcesService resourcesService, CancellationToken ct) =>
|
||||
app.MapGet("/resources/get-installer",
|
||||
async (IAuthService authService, IResourcesService resourcesService, CancellationToken ct) =>
|
||||
{
|
||||
var user = await authService.GetCurrentUser();
|
||||
if (user == null)
|
||||
throw new UnauthorizedAccessException();
|
||||
var (name, stream) = resourcesService.GetInstaller(dataFolder);
|
||||
var (name, stream) = resourcesService.GetInstaller(isStage: false);
|
||||
if (stream == null)
|
||||
throw new FileNotFoundException("Installer file was not found!");
|
||||
return Results.File(stream, "application/octet-stream", name);
|
||||
}).RequireAuthorization()
|
||||
.WithOpenApi(op => new OpenApiOperation(op){ Summary = "Gets latest installer"});
|
||||
.WithOpenApi(op => new OpenApiOperation(op) { Summary = "Gets latest installer" });
|
||||
|
||||
app.MapGet("/resources/get-installer/stage",
|
||||
async (IAuthService authService, IResourcesService resourcesService, CancellationToken ct) =>
|
||||
{
|
||||
var user = await authService.GetCurrentUser();
|
||||
if (user == null)
|
||||
throw new UnauthorizedAccessException();
|
||||
var (name, stream) = resourcesService.GetInstaller(isStage: true);
|
||||
if (stream == null)
|
||||
throw new FileNotFoundException("Installer file was not found!");
|
||||
return Results.File(stream, "application/octet-stream", name);
|
||||
}).RequireAuthorization()
|
||||
.WithOpenApi(op => new OpenApiOperation(op) { Summary = "Gets latest installer" });
|
||||
|
||||
|
||||
app.MapPost("/resources/check",
|
||||
async (CheckResourceRequest request, IAuthService authService, IUserService userService) =>
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"AllowedHosts": "*",
|
||||
"ResourcesConfig": {
|
||||
"ResourcesFolder": "Content",
|
||||
"SuiteInstallerFolder": "suite"
|
||||
"SuiteInstallerFolder": "suite",
|
||||
"SuiteStageInstallerFolder": "suite-stage"
|
||||
},
|
||||
"JwtConfig": {
|
||||
"Issuer": "AzaionApi",
|
||||
|
||||
Reference in New Issue
Block a user