mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-04-09 06:18:01 +02:00
CORS POS
This commit is contained in:
parent
b9f0c51d38
commit
b1f5ca88f8
@ -1,12 +1,10 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using VoidCat.Model;
|
||||
using VoidCat.Services.Abstractions;
|
||||
|
||||
namespace VoidCat.Controllers.Admin;
|
||||
|
||||
[EnableCors(CorsPolicy.Auth)]
|
||||
[Route("admin")]
|
||||
[Authorize(Policy = Policies.RequireAdmin)]
|
||||
public class AdminController : Controller
|
||||
|
@ -10,7 +10,6 @@ using VoidCat.Services.Abstractions;
|
||||
|
||||
namespace VoidCat.Controllers;
|
||||
|
||||
[EnableCors(CorsPolicy.Auth)]
|
||||
[Route("auth")]
|
||||
public class AuthController : Controller
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using Newtonsoft.Json;
|
||||
@ -9,7 +8,6 @@ using VoidCat.Services.Abstractions;
|
||||
|
||||
namespace VoidCat.Controllers
|
||||
{
|
||||
[EnableCors(CorsPolicy.Upload)]
|
||||
[Route("upload")]
|
||||
public class UploadController : Controller
|
||||
{
|
||||
|
@ -9,10 +9,4 @@ public static class Roles
|
||||
public static class Policies
|
||||
{
|
||||
public const string RequireAdmin = "RequireAdmin";
|
||||
}
|
||||
|
||||
public static class CorsPolicy
|
||||
{
|
||||
public const string Auth = "auth";
|
||||
public const string Upload = "upload";
|
||||
}
|
@ -41,22 +41,6 @@ services.AddCors(opt =>
|
||||
.AllowAnyHeader()
|
||||
.WithOrigins(voidSettings.CorsOrigins.Select(a => a.OriginalString).ToArray());
|
||||
});
|
||||
|
||||
opt.AddPolicy(CorsPolicy.Upload, p =>
|
||||
{
|
||||
p.AllowCredentials()
|
||||
.AllowAnyMethod()
|
||||
.WithHeaders("V-Content-Type", "V-Filename", "V-Digest", "V-EditSecret", "Content-Type", "Authorization")
|
||||
.WithOrigins(voidSettings.CorsOrigins.Select(a => a.OriginalString).ToArray());
|
||||
});
|
||||
|
||||
opt.AddPolicy(CorsPolicy.Auth, p =>
|
||||
{
|
||||
p.AllowCredentials()
|
||||
.AllowAnyMethod()
|
||||
.WithHeaders("Content-Type", "Authorization")
|
||||
.WithOrigins(voidSettings.CorsOrigins.Select(a => a.OriginalString).ToArray());
|
||||
});
|
||||
});
|
||||
|
||||
services.AddRouting();
|
||||
|
Loading…
x
Reference in New Issue
Block a user