Proxima.SelfEdu.Scaffolding.BasicAuth
1.1.0
dotnet add package Proxima.SelfEdu.Scaffolding.BasicAuth --version 1.1.0
NuGet\Install-Package Proxima.SelfEdu.Scaffolding.BasicAuth -Version 1.1.0
<PackageReference Include="Proxima.SelfEdu.Scaffolding.BasicAuth" Version="1.1.0" />
paket add Proxima.SelfEdu.Scaffolding.BasicAuth --version 1.1.0
#r "nuget: Proxima.SelfEdu.Scaffolding.BasicAuth, 1.1.0"
// Install Proxima.SelfEdu.Scaffolding.BasicAuth as a Cake Addin #addin nuget:?package=Proxima.SelfEdu.Scaffolding.BasicAuth&version=1.1.0 // Install Proxima.SelfEdu.Scaffolding.BasicAuth as a Cake Tool #tool nuget:?package=Proxima.SelfEdu.Scaffolding.BasicAuth&version=1.1.0
Proxima.SelfEdu.Scaffolding.BasicAuth
Handy project for quickly adding HTTP Basic Authentication to Asp.Net Core projects. Used for self-education purposes and experiments. Available on Nuget.
Usage
Simplest way to enable basic authentication is to have configuration section in your appsettings.json
"BasicAuthentication": {
"Realm": "localhost",
"Username": "admin",
"Password": "your secret password here"
}
Of course, you could use alternative configuration sources, such as environment variables, which is especially convenient for docker compose scenarios.
After that, you can add necessary services:
builder.Services.AddBasicAuthFromOptions<BasicAuthenticationOptions>("BasicAuthentication");
Note that you remain in control of config section path (provided as a string parameter), as well as actual *Options object structure, as long as you can inherit from BasicAuthenticationOptions.
For more flexibility, you can use .AddBasicAuth()
extension:
builder.Services.AddBasicAuth(options =>
{
options.Realm = "localhost";
options.Username = "admin";
options.Password = "your secret password here";
});
If you want to modify created AuthenticationTicket
, for example to add custom claims into ClaimsPrincipal
,
override AuthenticationTicketFactory
delegate.
By default, auth scheme is created named BasicAuthScheme
. If this by chance conflicts with your auth setup,
you can provide alternative scheme name as a parameter in existing overrides for .AddBasicAuth
and
.AddBasicAuthFromOptions
extensions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.