2024-07-03 20:17:44 +02:00
|
|
|
using DotBased.Logging;
|
|
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
2024-07-06 00:02:02 +02:00
|
|
|
using Microsoft.AspNetCore.Http;
|
2024-07-03 20:17:44 +02:00
|
|
|
using SharpRSS.Business.Services;
|
|
|
|
|
2024-07-06 00:02:02 +02:00
|
|
|
namespace SharpRSS.Business.Auth;
|
2024-07-03 20:17:44 +02:00
|
|
|
|
|
|
|
public class SRSSAuthenticationStateProvider : AuthenticationStateProvider
|
|
|
|
{
|
2024-07-06 00:02:02 +02:00
|
|
|
public SRSSAuthenticationStateProvider(IHttpContextAccessor contextAccessor, AuthService authService)
|
2024-07-03 20:17:44 +02:00
|
|
|
{
|
|
|
|
_logger = LogService.RegisterLogger(typeof(SRSSAuthenticationStateProvider));
|
|
|
|
if (contextAccessor.HttpContext != null)
|
|
|
|
_httpContext = contextAccessor.HttpContext;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var ex = new ApplicationException("HttpContext is null! Cannot setup authentication state provider!");
|
|
|
|
_logger.Fatal(ex, "Failed to initialize authentication state provider!");
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
_authService = authService;
|
|
|
|
}
|
2024-07-03 20:44:56 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Services
|
|
|
|
*/
|
2024-07-03 20:17:44 +02:00
|
|
|
private readonly ILogger _logger;
|
|
|
|
private readonly HttpContext _httpContext;
|
|
|
|
private readonly AuthService _authService;
|
2024-07-03 20:44:56 +02:00
|
|
|
/*
|
|
|
|
* Consts
|
|
|
|
*/
|
|
|
|
private const string AuthIdName = "srss_auth_id";
|
2024-07-03 20:17:44 +02:00
|
|
|
|
|
|
|
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
|
|
|
{
|
2024-07-06 00:02:02 +02:00
|
|
|
_logger.Debug("Getting authentication state...");
|
2024-07-03 20:17:44 +02:00
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
}
|