2024-07-13 16:27:45 +02:00
|
|
|
using System.Security.Claims;
|
2024-07-07 17:41:54 +02:00
|
|
|
using DotBased.Logging;
|
|
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
|
|
|
|
|
|
namespace DotBased.ASP.Auth;
|
|
|
|
|
2024-07-13 16:27:45 +02:00
|
|
|
// RevalidatingServerAuthenticationStateProvider
|
2024-07-07 17:41:54 +02:00
|
|
|
public class BasedAuthenticationStateProvider : AuthenticationStateProvider
|
|
|
|
{
|
2024-07-13 16:27:45 +02:00
|
|
|
public BasedAuthenticationStateProvider(BasedAuthConfiguration configuration)
|
2024-07-07 17:41:54 +02:00
|
|
|
{
|
2024-07-13 16:27:45 +02:00
|
|
|
_config = configuration;
|
2024-07-07 17:41:54 +02:00
|
|
|
_logger = LogService.RegisterLogger(typeof(BasedAuthenticationStateProvider));
|
|
|
|
}
|
|
|
|
|
2024-07-13 16:27:45 +02:00
|
|
|
private BasedAuthConfiguration _config;
|
2024-07-07 17:41:54 +02:00
|
|
|
private ILogger _logger;
|
2024-07-13 16:27:45 +02:00
|
|
|
private AuthenticationState _anonState = new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>() {new Claim(ClaimTypes.Role, "test")})));
|
2024-07-07 17:41:54 +02:00
|
|
|
|
|
|
|
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
|
|
|
{
|
2024-07-13 16:27:45 +02:00
|
|
|
return Task.FromResult(_anonState);
|
2024-07-07 17:41:54 +02:00
|
|
|
}
|
|
|
|
}
|