Soenneker.Swashbuckle.Authentication 4.0.2995

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Swashbuckle.Authentication --version 4.0.2995
                    
NuGet\Install-Package Soenneker.Swashbuckle.Authentication -Version 4.0.2995
                    
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="Soenneker.Swashbuckle.Authentication" Version="4.0.2995" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Swashbuckle.Authentication" Version="4.0.2995" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Swashbuckle.Authentication" />
                    
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 Soenneker.Swashbuckle.Authentication --version 4.0.2995
                    
#r "nuget: Soenneker.Swashbuckle.Authentication, 4.0.2995"
                    
#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 Soenneker.Swashbuckle.Authentication@4.0.2995
                    
#: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=Soenneker.Swashbuckle.Authentication&version=4.0.2995
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Swashbuckle.Authentication&version=4.0.2995
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Swashbuckle.Authentication

Protects a Swagger path with HTTP Basic credentials, optional role-bearing access keys, or an explicit local-request bypass.

Installation

dotnet add package Soenneker.Swashbuckle.Authentication

Configuration

{
  "Swagger": {
    "Uri": "/swagger",
    "Username": "docs-admin",
    "Password": "replace-with-a-secret",
    "LocalAuthenticationBypassEnabled": false,
    "AccessKeys": [
      "support:replace-with-a-random-key",
      "developer:replace-with-another-random-key"
    ]
  }
}

Username and Password are required. Uri defaults to /swagger. Each optional access-key entry uses role:key; a successful key creates an authenticated principal named accesskey with that role. Basic credentials create an admin principal.

Keep credentials and access keys in a secret provider or environment variables rather than a committed settings file.

Middleware order

Register authentication before the Swagger middleware so requests cannot reach the UI or JSON document first:

using Soenneker.Swashbuckle.Authentication.Registrars;

app.UseSwashbuckleAuth();
app.UseSwagger();
app.UseSwaggerUI();

Requests outside the configured Swagger path pass through unchanged. Unauthorized requests under that path receive 401 with a Basic authentication challenge.

An access key can be supplied as ?accesskey=.... A valid key is persisted in an HTTP-only, same-site session cookie restricted to the Swagger path; the cookie is marked secure when the request uses HTTPS.

Query strings commonly appear in browser history, proxy logs, monitoring tools, and copied URLs. Use random, revocable keys, send access-key links only over HTTPS, and remove the key from the address bar after the first authenticated request. Opening the Swagger landing page without an access-key query clears the existing access-key cookie.

Local bypass

Leave LocalAuthenticationBypassEnabled disabled unless the deployment's connection-address handling is fully trusted. The bypass relies on HttpContext.Connection addresses; forwarded-header middleware, proxies, or test middleware that rewrites those addresses can affect what counts as local.

This middleware protects Swagger endpoints but is not a replacement for application-wide authentication, authorization, TLS, rate limiting, or secret rotation.

Product Compatible and additional computed target framework versions.
.NET 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.

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
4.0.3006 47 9/16/2026
4.0.3005 64 9/16/2026
4.0.3004 62 9/16/2026
4.0.3002 65 9/16/2026
4.0.3000 77 9/15/2026
4.0.2997 85 9/13/2026
4.0.2995 83 9/13/2026
4.0.2993 78 9/13/2026
4.0.2992 86 9/13/2026
4.0.2990 89 9/13/2026
4.0.2989 93 9/12/2026
4.0.2988 87 9/12/2026
4.0.2987 82 9/12/2026
4.0.2980 108 9/9/2026
4.0.2979 99 9/9/2026
4.0.2978 97 9/9/2026
4.0.2977 100 9/9/2026
4.0.2975 103 9/8/2026
4.0.2974 96 9/8/2026
4.0.2973 107 9/8/2026
Loading failed

Update dependency Soenneker.Extensions.HttpContext to 4.0.747 (#3847)