DynAuth 1.0.0

dotnet add package DynAuth --version 1.0.0
                    
NuGet\Install-Package DynAuth -Version 1.0.0
                    
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="DynAuth" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DynAuth" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DynAuth" />
                    
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 DynAuth --version 1.0.0
                    
#r "nuget: DynAuth, 1.0.0"
                    
#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 DynAuth@1.0.0
                    
#: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=DynAuth&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DynAuth&version=1.0.0
                    
Install as a Cake Tool

๐Ÿ” Dynamic authentication with OpenIDConnect & SAML Schemes in ASP.NET Core

DynAuth is a flexible authentication library for .NET applications, providing support for multiple authentication protocols including SAML2 and OpenID Connect. This is useful for multi-tenant apps or when your identity provider setup is not static.

Features

  • ๐Ÿ” Multi-protocol support
    • SAML2 authentication
    • OpenID Connect integration
  • ๐ŸŽฏ Built for .NET 8.0
  • โšก Easy integration with ASP.NET Core applications
  • ๐Ÿ› ๏ธ Customizable authentication flows

๐Ÿงฉ Adding a Schemes at Runtime

1. IOidcSchemeManager

Call this from anywhere (e.g., an admin panel or per-tenant middleware):

  • Adds new oidc client on the fly
public class SchemeService
{
    public Task AddScheme()
    {
        var options = new OpenIdConnectOptions
        {
            SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme,
            Authority = "https://accounts.google.com",
            ClientId = "*",
            ClientSecret = "*",
            ResponseType = "code",
            SaveTokens = true,
            CallbackPath = $"/signin-google-test",
        };
        
        _oidcSchemeManager.AddScheme("google-test", options);
    }
}

2. ISamlSchemeManager

Call this from anywhere (e.g., an admin panel or per-tenant middleware):

  • Adds new saml client on the fly
public class SchemeService
{
    public Task AddScheme()
    {
        var options = new Saml2Options
        {
            SPOptions =
            {
                EntityId = new EntityId("https://localhost:7119"),
                ModulePath = "/signin-azure-saml2"
            }
        };
        
        var idp = new IdentityProvider(new EntityId("https://sts.windows.net/16e2eac8-c69c-4976-919b-test/"),
            options.SPOptions)
        {
            Binding = Saml2BindingType.HttpPost,
            LoadMetadata = true,
            MetadataLocation = "https://login.microsoftonline.com/16e2eac8-c69c-4976-919b-4c3a48c2c0f7/federationmetadata/2007-06/federationmetadata.xml?appid=b88b09ee-52b4-4454-8c1f-test"
        };

        options.IdentityProviders.Add(idp);
        
        _samlSchemeManager.AddScheme("azure", options);
    }
}

๐Ÿ› ๏ธ Service Registration

In Program.cs:

builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddDynAuthOpenIdConnect()
    .AddDynAuthSaml();

๐Ÿงช Testing the Setup

Check out the samples directory for example implementations and usage.


๐Ÿงฉ Want to Contribute?

Feel free to fork and enhance this with:

  • Admin UI for managing schemes
  • Database persistence
  • Caching / refreshing tokens

๐Ÿ“ฌ Questions / Help?

Open an issue or discussion if you need help wiring this up in your own project.

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

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on DynAuth:

Package Downloads
DynAuth.Saml2

DynAuth is a flexible authentication library for .NET applications, providing support for multiple authentication protocols including SAML2 and OpenID Connect. This is useful for multi-tenant apps or when your identity provider setup is not static.

DynAuth.OpenIdConnect

DynAuth is a flexible authentication library for .NET applications, providing support for multiple authentication protocols including SAML2 and OpenID Connect. This is useful for multi-tenant apps or when your identity provider setup is not static.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 198 4/21/2025