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
|
#endif
|
||||||
#if (OrganizationalAuth)
|
#if (OrganizationalAuth)
|
||||||
services.AddControllersWithViews(options =>
|
services.AddControllersWithViews();
|
||||||
|
|
||||||
|
services.AddAuthorization(options =>
|
||||||
{
|
{
|
||||||
var policy = new AuthorizationPolicyBuilder()
|
// By default, all incoming requests will be authorized according to the default policy
|
||||||
.RequireAuthenticatedUser()
|
options.FallbackPolicy = options.DefaultPolicy;
|
||||||
.Build();
|
|
||||||
options.Filters.Add(new AuthorizeFilter(policy));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -108,13 +108,12 @@ namespace Company.WebApplication1
|
||||||
.AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
|
.AddAzureADB2C(options => Configuration.Bind("AzureAdB2C", options));
|
||||||
#endif
|
#endif
|
||||||
#if (OrganizationalAuth)
|
#if (OrganizationalAuth)
|
||||||
|
services.AddControllersWithViews();
|
||||||
|
|
||||||
services.AddControllersWithViews(options =>
|
services.AddAuthorization(options =>
|
||||||
{
|
{
|
||||||
var policy = new AuthorizationPolicyBuilder()
|
// By default, all incoming requests will be authorized according to the default policy
|
||||||
.RequireAuthenticatedUser()
|
options.FallbackPolicy = options.DefaultPolicy;
|
||||||
.Build();
|
|
||||||
options.Filters.Add(new AuthorizeFilter(policy));
|
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
services.AddControllersWithViews();
|
services.AddControllersWithViews();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue