“Amostra Blazor Ujsing Cliam Policy” Respostas de código

Amostra Blazor Ujsing Cliam Policy

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthorization(config =>
    {
        config.AddPolicy("IsDeveloper", policy => policy.RequireClaim("IsDeveloper", "true"));
    });
}
Magnificent Markhor

Amostra Blazor Ujsing Cliam Policy

@page "/debug"
@attribute [Authorize(Policy = "IsDeveloper")]
Magnificent Markhor

Amostra Blazor Ujsing Cliam Policy

[Route("api/[controller]")]
[ApiController]
public class SystemController 
{
    [Authorize(Policy = “IsDeveloper”)]
    public IActionResult LoadDebugInfo()
    {
        // ...
    }
}
Magnificent Markhor

Amostra Blazor Ujsing Cliam Policy

<AuthorizeView Policy="IsDeveloper">
    <p>You can only see this if you satisfy the IsDeveloper policy.</p>
</AuthorizeView>
Magnificent Markhor

Respostas semelhantes a “Amostra Blazor Ujsing Cliam Policy”

Perguntas semelhantes a “Amostra Blazor Ujsing Cliam Policy”

Procure respostas de código populares por idioma

Procurar outros idiomas de código