Skip to content

Commit 4d4d036

Browse files
committed
Readme updated
1 parent c59352c commit 4d4d036

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public class Startup
5252
services.AddControllers();
5353

5454
//// By default, authentication is not challenged for every request which is ASP.NET Core's default intended behaviour.
55-
//// So to challenge authentication for every requests please use below option instead of above services.AddControllers().
56-
//services.AddControllers(options =>
55+
//// So to challenge authentication for every requests please use below FallbackPolicy option.
56+
//services.AddAuthorization(options =>
5757
//{
58-
// options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
58+
// options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
5959
//});
6060
}
6161

@@ -153,6 +153,10 @@ Default value is false.
153153
When set to true, it will NOT return WWW-Authenticate response header when challenging un-authenticated requests.
154154
When set to false, it will return WWW-Authenticate response header when challenging un-authenticated requests.
155155

156+
#### IgnoreAuthenticationIfAllowAnonymous
157+
Default value is false.
158+
If set to true, it checks if AllowAnonymous filter on controller action or metadata on the endpoint which, if found, it does not try to authenticate the request.
159+
156160
#### Events
157161
The object provided by the application to process events raised by the basic authentication middleware.
158162
The application may implement the interface fully, or it may create an instance of BasicEvents and assign delegates only to the events it wants to process.
@@ -187,9 +191,9 @@ Please note that, by default, with ASP.NET Core, all the requests are not challe
187191
However, if you want all the requests to challenge authentication by default, depending on what you are using, you can add the below options line to *ConfigureServices* method on *Startup* class.
188192

189193
```C#
190-
services.AddControllers(options =>
191-
{
192-
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
194+
services.AddAuthorization(options =>
195+
{
196+
options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
193197
});
194198

195199
// OR

0 commit comments

Comments
 (0)