Skip to content

Commit

Permalink
clean up startup
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha committed Mar 19, 2024
1 parent 5776067 commit 953edf4
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions KratosSelfService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ public void ConfigureServices(IServiceCollection services)
options.DefaultChallengeScheme = "DefaultScheme"; // 401 Unauthorized
options.DefaultForbidScheme = "DefaultScheme"; // 403 Forbid
});
services.AddAuthorization(options =>
{
options.AddPolicy("LoggedIn", policyBuilder => { policyBuilder.RequireClaim(ClaimTypes.NameIdentifier); });
// The fallback authorization policy requires all users to be authenticated, except for controllers or action
// methods with an authorization attribute. For example, controllers or action methods with [AllowAnonymous] or
// [Authorize(PolicyName="MyPolicy")] use the applied authorization attribute rather than the fallback
// authorization policy.
// The fallback authorization policy is applied to all requests that don't explicitly specify an authorization
// policy.
options.FallbackPolicy = new AuthorizationPolicyBuilder()

// The fallback authorization policy requires all users to be authenticated, except for controllers or action
// methods with an authorization attribute. For example, controllers or action methods with [AllowAnonymous] or
// [Authorize(PolicyName="MyPolicy")] use the applied authorization attribute rather than the fallback
// authorization policy.
// The fallback authorization policy is applied to all requests that don't explicitly specify an authorization
// policy.
services.AddAuthorizationBuilder()
.SetFallbackPolicy(new AuthorizationPolicyBuilder()
.RequireAuthenticatedUser()
.Build();
});
.Build());

// localisation
services.AddLocalization(options => options.ResourcesPath = "Resources");
Expand Down

0 comments on commit 953edf4

Please sign in to comment.