Update how default auth policy is set in templates (#22884)
* Update how default auth policy is set in templates * Respond to feedback from peer review
This commit is contained in:
parent
af0a3ed83c
commit
b484680092
|
|
@ -116,12 +116,12 @@ namespace BlazorServerWeb_CSharp
|
|||
|
||||
#endif
|
||||
#if (OrganizationalAuth)
|
||||
services.AddControllersWithViews(options =>
|
||||
services.AddControllersWithViews();
|
||||
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder()
|
||||
.RequireAuthenticatedUser()
|
||||
.Build();
|
||||
options.Filters.Add(new AuthorizeFilter(policy));
|
||||
// By default, all incoming requests will be authorized according to the default policy
|
||||
options.FallbackPolicy = options.DefaultPolicy;
|
||||
});
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -108,13 +108,12 @@ namespace Company.WebApplication1
|
|||
.AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
|
||||
#endif
|
||||
#if (OrganizationalAuth)
|
||||
services.AddControllersWithViews();
|
||||
|
||||
services.AddControllersWithViews(options =>
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
var policy = new AuthorizationPolicyBuilder()
|
||||
.RequireAuthenticatedUser()
|
||||
.Build();
|
||||
options.Filters.Add(new AuthorizeFilter(policy));
|
||||
// By default, all incoming requests will be authorized according to the default policy
|
||||
options.FallbackPolicy = options.DefaultPolicy;
|
||||
});
|
||||
#else
|
||||
services.AddControllersWithViews();
|
||||
|
|
|
|||
Loading…
Reference in New Issue