DioRed.Dais.AspNetCore 1.0.0-preview.4

Suggested Alternatives

DioRed.Aith.AspNetCore

Additional Details

DAIS has been completely renamed to Aith

This is a prerelease version of DioRed.Dais.AspNetCore.
dotnet add package DioRed.Dais.AspNetCore --version 1.0.0-preview.4
                    
NuGet\Install-Package DioRed.Dais.AspNetCore -Version 1.0.0-preview.4
                    
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="DioRed.Dais.AspNetCore" Version="1.0.0-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DioRed.Dais.AspNetCore" Version="1.0.0-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="DioRed.Dais.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DioRed.Dais.AspNetCore --version 1.0.0-preview.4
                    
#r "nuget: DioRed.Dais.AspNetCore, 1.0.0-preview.4"
                    
#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.
#:package DioRed.Dais.AspNetCore@1.0.0-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DioRed.Dais.AspNetCore&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=DioRed.Dais.AspNetCore&version=1.0.0-preview.4&prerelease
                    
Install as a Cake Tool

DioRed.Dais.AspNetCore

DioRed.Dais.AspNetCore provides seamless integration between ASP.NET Core applications and the DAIS (DioRed Authentication & Identity Server) OAuth2/OpenID-Connect–style authentication system.

It offers:

  • Simple cookie-based login via DAIS Authorization Code + PKCE
  • Automatic UserInfo β†’ Claims mapping
  • High-level and advanced configuration models
  • Built-in login/logout endpoint helpers
  • Support for multiple authentication schemes
  • Full extensibility for custom OAuth options

πŸš€ Installation

dotnet add package DioRed.Dais.AspNetCore

✨ Quick Start

Register DAIS authentication in Program.cs:

builder.Services.AddDaisAuthentication(o =>
{
    o.ClientId     = "my-app";
    o.ClientSecret = "secret";
    o.Scopes       = new[] { "profile", "email" };
});

Add login/logout endpoints:

app.MapDaisAuthEndpoints();

Protect your pages:

app.MapGet("/profile", (ClaimsPrincipal user) =>
{
    return $"Hello, {user.Identity?.Name}";
}).RequireAuthorization();

πŸ”§ Advanced Configuration

If you need full control over cookie scheme names, the authentication pipeline, or the underlying OAuth handler:

builder.AddDais(o =>
{
    o.CookieScheme = "MyCookies";
    o.DaisScheme   = "MyDais";

    o.ConfigureDais = dais =>
    {
        dais.ClientId  = "my-app";
        dais.Scopes    = new[] { "profile", "email" };
    };

    o.ConfigureDaisOAuth = oauth =>
    {
        oauth.SignInScheme = "MyCookies";
        oauth.Scope.Add("custom-scope");
    };
});

πŸ“‘ UserInfo β†’ Claims Mapping

DAIS automatically fetches the UserInfo document and maps its fields to claims:

  • "name" β†’ ClaimTypes.Name
  • "sub" β†’ ClaimTypes.NameIdentifier
  • "preferred_username" β†’ "preferred_username"
  • All other JSON fields β†’ raw claim names via MapAll()

This ensures HttpContext.User.Identity.Name works as expected.

🧩 Login/Logout Endpoints Helper

Add standardized endpoints:

app.MapDaisAuthEndpoints();

Customize paths/schemes if needed:

app.MapDaisAuthEndpoints(
    loginPath: "/auth/login",
    logoutPath: "/auth/logout",
    cookieScheme: "MyCookies",
    challengeScheme: "MyDais"
);

πŸ“š Summary

DioRed.Dais.AspNetCore gives you a clean, production-ready, extensible way to plug DAIS authentication into any ASP.NET Core application, from minimal APIs to MVC to Razor Pages.

If you need programmatic DAIS access using client_credentials, check out the companion package:

πŸ‘‰ DioRed.Dais.Client

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

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.