Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Strange behavior of Blazor Authorization template

$
0
0

I can't get a component to be disabled using policy

  1. Create an empty BlazorServer project with the WindowsAuthenticate authorization template.
  2. Add a default policy that denies everything.
builder.Services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)   .AddNegotiate();builder.Services.AddAuthorization(options =>{    options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAssertion(x=>false).Build();});
  1. Add the AllowAnonumus attribute to the _host page. If you don’t add it, there will be no access to the site at all, it will return 403
@attribute [Microsoft.AspNetCore.Authorization.AllowAnonymous]
  1. Make sure that the template has one component that requires authorization.
<AuthorizeView><Authorized>    Hello, @context.User.Identity.Name!</Authorized></AuthorizeView>

Now run the project, and at first you won’t see the login.But if you quickly click on the NavBar you will see it. Explain how the code gets into <Authorized> tags


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>