Compare commits
4 Commits
565252382c
...
fba842acc3
Author | SHA1 | Date | |
---|---|---|---|
fba842acc3 | |||
31087a57c9 | |||
24c75e4306 | |||
dee89b278b |
@ -75,9 +75,9 @@ public partial class SetupController(
|
||||
{
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
HttpOnly = true,
|
||||
#if !DEBUG
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
Secure = true
|
||||
#endif
|
||||
});
|
||||
return Ok(true);
|
||||
|
@ -6,6 +6,7 @@ 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;
|
||||
@ -31,33 +32,38 @@ public class AuthController(IOptionsSnapshot<Admin> user, AuthService auth, Pass
|
||||
Expires = expires,
|
||||
Path = UrlHelper.GetSubPathWithoutFirstApiName + "api",
|
||||
Domain = HttpContext.GetCurrentDomain(),
|
||||
HttpOnly = true,
|
||||
#if !DEBUG
|
||||
Secure = true,
|
||||
HttpOnly = true
|
||||
Secure = 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 = context.HttpContext.Connection.RemoteIpAddress?.ToString()!;
|
||||
UserAgent = context.HttpContext.Request.Headers.UserAgent.ToString();
|
||||
Fingerprint = context.HttpContext.Request.Cookies["user_key"] ?? string.Empty;
|
||||
Ip = HttpContext.Connection.RemoteIpAddress?.ToString()!;
|
||||
UserAgent = Request.Headers.UserAgent.ToString();
|
||||
Fingerprint = 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)]
|
||||
@ -157,5 +163,6 @@ 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,6 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class CampusController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class DisciplineController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,6 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class FacultyController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -13,6 +13,7 @@ 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,6 +12,7 @@ using System.Threading.Tasks;
|
||||
namespace Mirea.Api.Endpoint.Controllers.V1;
|
||||
|
||||
[ApiVersion("1.0")]
|
||||
[CacheMaxAge(true)]
|
||||
public class LectureHallController(IMediator mediator) : BaseController
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,6 +12,7 @@ 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