Skip to content

Commit 39feb3c

Browse files
committed
Samples updated with latest version
1 parent 4d4d036 commit 39feb3c

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

samples/SampleWebApi_2_0/SampleWebApi_2_0.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="AspNetCore.Authentication.Basic" Version="3.1.1" />
15+
<PackageReference Include="AspNetCore.Authentication.Basic" Version="5.0.0" />
1616
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
1717
</ItemGroup>
1818

samples/SampleWebApi_2_2/SampleWebApi_2_2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="AspNetCore.Authentication.Basic" Version="3.1.1" />
9+
<PackageReference Include="AspNetCore.Authentication.Basic" Version="5.0.0" />
1010
<PackageReference Include="Microsoft.AspNetCore.App" />
1111
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
1212
</ItemGroup>

samples/SampleWebApi_3_1/SampleWebApi_3_1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="..\SampleWebApi.Shared\SampleWebApi.Shared.projitems" Label="Shared" />
88

99
<ItemGroup>
10-
<PackageReference Include="AspNetCore.Authentication.Basic" Version="3.1.1" />
10+
<PackageReference Include="AspNetCore.Authentication.Basic" Version="5.0.0" />
1111
</ItemGroup>
1212

1313
<!--<ItemGroup>

samples/SampleWebApi_3_1/Startup.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public void ConfigureServices(IServiceCollection services)
4848
//// Optional option to suppress the browser login dialog for ajax calls.
4949
//options.SuppressWWWAuthenticateHeader = true;
5050

51+
//// Optional option to ignore authentication if AllowAnonumous metadata/filter attribute is added to an endpoint.
52+
//options.IgnoreAuthenticationIfAllowAnonymous = true;
53+
5154
//// Optional events to override the basic original logic with custom logic.
5255
//// Only use this if you know what you are doing at your own risk. Any of the events can be assigned.
5356
options.Events = new BasicEvents
@@ -149,13 +152,19 @@ public void ConfigureServices(IServiceCollection services)
149152

150153
services.AddControllers(options =>
151154
{
152-
// ALWAYS USE HTTPS (SSL) protocol in production when using Basic authentication.
155+
// ALWAYS USE HTTPS (SSL) protocol in production when using ApiKey authentication.
153156
//options.Filters.Add<RequireHttpsAttribute>();
154157

155-
// All the requests will need to be authorized.
156-
// Alternatively, add [Authorize] attribute to Controller or Action Method where necessary.
157-
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
158158
}); //.AddXmlSerializerFormatters() // To enable XML along with JSON;
159+
160+
// All the requests will need to be authorized.
161+
// Alternatively, add [Authorize] attribute to Controller or Action Method where necessary.
162+
services.AddAuthorization(options =>
163+
{
164+
options.FallbackPolicy = new AuthorizationPolicyBuilder()
165+
.RequireAuthenticatedUser()
166+
.Build();
167+
});
159168
}
160169

161170
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -170,7 +179,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
170179

171180
app.UseHttpsRedirection();
172181
app.UseRouting();
173-
182+
174183
app.UseAuthentication(); // NOTE: DEFAULT TEMPLATE DOES NOT HAVE THIS, THIS LINE IS REQUIRED AND HAS TO BE ADDED!!!
175184

176185
app.UseAuthorization();

0 commit comments

Comments
 (0)