add Authorization setting for next - subdomain
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
namespace ServiceHost.BaseControllers;
|
namespace ServiceHost.BaseControllers;
|
||||||
|
|
||||||
//[Authorize(Policy = "AdminArea")]
|
[Authorize(Policy = "AdminArea")]
|
||||||
[Area("Admin")]
|
[Area("Admin")]
|
||||||
[ApiExplorerSettings(GroupName = "Admin")]
|
[ApiExplorerSettings(GroupName = "Admin")]
|
||||||
[Route("api/[area]/[controller]")]
|
[Route("api/[area]/[controller]")]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using _0_Framework.Application.Sms;
|
using _0_Framework.Application.Sms;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
@@ -71,9 +71,19 @@ builder.Services.Configure<FormOptions>(options =>
|
|||||||
builder.Services.Configure<CookiePolicyOptions>(options =>
|
builder.Services.Configure<CookiePolicyOptions>(options =>
|
||||||
{
|
{
|
||||||
options.CheckConsentNeeded = context => true;
|
options.CheckConsentNeeded = context => true;
|
||||||
options.MinimumSameSitePolicy = SameSiteMode.Strict;
|
//options.MinimumSameSitePolicy = SameSiteMode.Strict;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
builder.Services.ConfigureApplicationCookie(options =>
|
||||||
|
{
|
||||||
|
//options.Cookie.Name = "GozarAuth";
|
||||||
|
options.Cookie.HttpOnly = true;
|
||||||
|
options.Cookie.SameSite = SameSiteMode.None; // مهم ✅
|
||||||
|
options.Cookie.SecurePolicy = CookieSecurePolicy.Always; // فقط روی HTTPS کار میکنه ✅
|
||||||
|
options.Cookie.Domain = ".dad-mehr.ir"; // دامنه مشترک بین پدر و سابدامینها ✅
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||||
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o =>
|
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, o =>
|
||||||
{
|
{
|
||||||
@@ -148,6 +158,25 @@ builder.Services.AddSignalR();
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
builder.Services.AddCors(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("AllowSpecificOrigins", policy =>
|
||||||
|
{
|
||||||
|
policy.WithOrigins(
|
||||||
|
"http://localhost:3000",
|
||||||
|
"http://localhost:3001",
|
||||||
|
"https://gozareshgir.ir",
|
||||||
|
"https://dad-mehr.ir",
|
||||||
|
"https://admin.dad-mehr.ir",
|
||||||
|
"https://admin.gozareshgir.ir"
|
||||||
|
)
|
||||||
|
.AllowAnyHeader()
|
||||||
|
.AllowAnyMethod()
|
||||||
|
.AllowCredentials();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
#region PWA
|
#region PWA
|
||||||
|
|
||||||
//old
|
//old
|
||||||
@@ -198,6 +227,7 @@ app.UseStaticFiles();
|
|||||||
app.UseCookiePolicy();
|
app.UseCookiePolicy();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
app.UseCors("AllowSpecificOrigins");
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user