Proxima.SelfEdu.Scaffolding.BasicAuth 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Proxima.SelfEdu.Scaffolding.BasicAuth --version 1.0.2                
NuGet\Install-Package Proxima.SelfEdu.Scaffolding.BasicAuth -Version 1.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Proxima.SelfEdu.Scaffolding.BasicAuth" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Proxima.SelfEdu.Scaffolding.BasicAuth --version 1.0.2                
#r "nuget: Proxima.SelfEdu.Scaffolding.BasicAuth, 1.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Proxima.SelfEdu.Scaffolding.BasicAuth as a Cake Addin
#addin nuget:?package=Proxima.SelfEdu.Scaffolding.BasicAuth&version=1.0.2

// Install Proxima.SelfEdu.Scaffolding.BasicAuth as a Cake Tool
#tool nuget:?package=Proxima.SelfEdu.Scaffolding.BasicAuth&version=1.0.2                

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.

At the moment, there is no way to override used auth schema name (BasicAuthScheme).

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last updated
1.1.0 293 1/25/2023
1.0.2 280 1/22/2023
1.0.0 290 1/8/2023
1.0.0-rc3 139 1/8/2023