Compare commits
No commits in common. "fba842acc3cd7a9367d09ecef7658fa071a1b9b0" and "565252382c10020c6899aaece6437758757e1bdc" have entirely different histories.
fba842acc3
...
565252382c
@ -75,9 +75,9 @@ public partial class SetupController(
|
||||
{
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
HttpOnly = true,
|
||||
#if !DEBUG
|
||||
Secure = true
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
#endif
|
||||
});
|
||||
return Ok(true);
|
||||
|
@ -6,7 +6,6 @@ using Microsoft.Extensions.Options;
|
||||
using Mirea.Api.Dto.Common;
|
||||
using Mirea.Api.Dto.Requests;
|
||||
using Mirea.Api.Dto.Responses;
|
||||
using Mirea.Api.Endpoint.Common.Attributes;
|
||||
using Mirea.Api.Endpoint.Common.Services;
|
||||
using Mirea.Api.Endpoint.Common.Settings;
|
||||
using Mirea.Api.Security.Common.Dto.Requests;
|
||||
@ -32,38 +31,33 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
Expires = expires,
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
HttpOnly = true,
|
||||
#if !DEBUG
|
||||
Secure = true
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
#endif
|
||||
};
|
||||
|
||||
Response.Cookies.Append(name, value, cookieOptions);
|
||||
}
|
||||
|
||||
private void SetRefreshToken(string value, DateTimeOffset? expires = null)
|
||||
{
|
||||
private void SetRefreshToken(string value, DateTimeOffset? expires = null) =>
|
||||
SetCookie("refresh_token", value, expires);
|
||||
SetCookie("user_key", Fingerprint, expires);
|
||||
}
|
||||
|
||||
private void SetFirstToken(string value, DateTimeOffset? expires = null)
|
||||
{
|
||||
private void SetFirstToken(string value, DateTimeOffset? expires = null) =>
|
||||
SetCookie("authentication_token", value, expires);
|
||||
SetCookie("user_key", Fingerprint, expires);
|
||||
}
|
||||
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
public void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
Ip = HttpContext.Connection.RemoteIpAddress?.ToString()!;
|
||||
UserAgent = Request.Headers.UserAgent.ToString();
|
||||
Fingerprint = Request.Cookies["user_key"] ?? string.Empty;
|
||||
Ip = context.HttpContext.Connection.RemoteIpAddress?.ToString()!;
|
||||
UserAgent = context.HttpContext.Request.Headers.UserAgent.ToString();
|
||||
Fingerprint = context.HttpContext.Request.Cookies["user_key"] ?? string.Empty;
|
||||
RefreshToken = Request.Cookies["refresh_token"] ?? string.Empty;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Fingerprint)) return;
|
||||
|
||||
Fingerprint = Guid.NewGuid().ToString().Replace("-", "");
|
||||
SetCookie("user_key", Fingerprint);
|
||||
}
|
||||
|
||||
[ApiExplorerSettings(IgnoreApi = true)]
|
||||
@ -163,6 +157,5 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
[HttpGet("GetRole")]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[Authorize]
|
||||
[CacheMaxAge(0, 0, 1)]
|
||||
public ActionResult<AuthRoles> GetRole() => Ok(AuthRoles.Admin);
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class CampusController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class DisciplineController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class FacultyController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -13,7 +13,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class GroupController(IMediator mediator) : BaseController
|
||||
{
|
||||
private static int GetCourseNumber(string groupName)
|
||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class LectureHallController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,7 +12,6 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class ProfessorController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user