Visus.BasicLdapAuthentication
1.0.0
dotnet add package Visus.BasicLdapAuthentication --version 1.0.0
NuGet\Install-Package Visus.BasicLdapAuthentication -Version 1.0.0
<PackageReference Include="Visus.BasicLdapAuthentication" Version="1.0.0" />
<PackageVersion Include="Visus.BasicLdapAuthentication" Version="1.0.0" />
<PackageReference Include="Visus.BasicLdapAuthentication" />
paket add Visus.BasicLdapAuthentication --version 1.0.0
#r "nuget: Visus.BasicLdapAuthentication, 1.0.0"
#:package Visus.BasicLdapAuthentication@1.0.0
#addin nuget:?package=Visus.BasicLdapAuthentication&version=1.0.0
#tool nuget:?package=Visus.BasicLdapAuthentication&version=1.0.0
Visus.BasicLdapAuthentication
Visus.BasicLdapAuthentication implements the basic (header-based) authentication scheme for ASP.NET Core application using Visus.DirectoryAuthentication or Visus.LdapAuthentication as backends.
Usage
Add the services
The authentication functionalityBasic is added in ConfigureServices in your Startup class or using the WebApplication builder in the minimal hosting model:
Or using the new "minimal hosting model":
using Visus.BasicLdapAuthentication;
using Visus.LdapAuthentication; // or Visus.DirectoryAuthentication;
// ...
var builder = WebApplication.CreateBuilder(args);
// ...
// Add basic authentication using LDAP.
builder.Services.AddAuthentication(BasicAuthenticationDefaults.AuthenticationScheme)
.AddBasicLdapAuthentication(o => {
builder.Configuration.GetSection(BasicAuthenticationOptions.Section).Bind(o);
// The following statement filters out group-based claims as an example.
o.ClaimFilter = (c, _) => (c != ClaimTypes.GroupSid) && (c != ClaimTypes.Role);
});
});
// Add Visus.LdapAuthentication or Visus.DirectoryAuthentication as the
// authentication backend. No further configuration is required as the basic
// authentication handler will pull the configuration from the DI container.
builder.Services.AddLdapAuthentication(o => {
builder.Configuration.GetSection(LdapOptions.Section).Bind(o);
});
// ...
app.UseAuthentication();
app.UseAuthorization();
/...
Interface with cookie authentication
As pulling the login data from the LDAP server for each request can be expensive, the handler has the ability to interface the cookie authentication middleware:
builder.Services.AddAuthentication(BasicAuthenticationDefaults.AuthenticationScheme)
.AddCookie(o => {
// The login cookie is essential in the sense of GDPR.
o.Cookie.IsEssential = true;
}).AddBasicLdapAuthentication(o => {
builder.Configuration.GetSection(BasicAuthenticationOptions.Section).Bind(o);
// Tell the basic authentication handler to sign in using the default
// cookie scheme.
o.CookieScheme = CookieAuthenticationDefaults.AuthenticationScheme;
// Allow the cookie to be refreshed.
o.AllowCookieRefresh = true;
// Set the lifetime of the cookie.
o.CookieLifetime = TimeSpan.FromMinutes(30);
// Allow the cookie to outlive the browser session.
o.PersistentCookie = true;
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.Authentication (>= 2.3.12)
- Visus.Ldap.Core (>= 2.1.0)
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.0.0 | 58 | 8/15/2026 |