Reworking auth
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Security.Claims;
|
||||
using DotBased.ASP.Auth.Scheme;
|
||||
using DotBased.Logging;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Server;
|
||||
@@ -8,6 +9,7 @@ namespace DotBased.ASP.Auth;
|
||||
|
||||
// RevalidatingServerAuthenticationStateProvider
|
||||
// AuthenticationStateProvider
|
||||
// Handles roles
|
||||
public class BasedServerAuthenticationStateProvider : ServerAuthenticationStateProvider
|
||||
{
|
||||
public BasedServerAuthenticationStateProvider(BasedAuthConfiguration configuration, ISessionStateProvider stateProvider)
|
||||
@@ -20,10 +22,12 @@ public class BasedServerAuthenticationStateProvider : ServerAuthenticationStateP
|
||||
private BasedAuthConfiguration _config;
|
||||
private ISessionStateProvider _stateProvider;
|
||||
private ILogger _logger;
|
||||
private readonly AuthenticationState _anonState = new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>() {new Claim(ClaimTypes.Role, "test")})));
|
||||
private readonly AuthenticationState _loggedInState = new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>() { new Claim(ClaimTypes.Role, "Admin"), new Claim(ClaimTypes.Name, "Anon") }, BasedAuthenticationHandler.AuthenticationScheme)));
|
||||
private readonly AuthenticationState _anonState = new AuthenticationState(new ClaimsPrincipal());
|
||||
|
||||
|
||||
public override Task<AuthenticationState> GetAuthenticationStateAsync()
|
||||
{
|
||||
return Task.FromResult(_anonState);
|
||||
return Task.FromResult(_loggedInState);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user