Soenneker.Swashbuckle.Authentication
11.0.3066
Prefix Reserved
dotnet add package Soenneker.Swashbuckle.Authentication --version 11.0.3066
NuGet\Install-Package Soenneker.Swashbuckle.Authentication -Version 11.0.3066
<PackageReference Include="Soenneker.Swashbuckle.Authentication" Version="11.0.3066" />
<PackageVersion Include="Soenneker.Swashbuckle.Authentication" Version="11.0.3066" />
<PackageReference Include="Soenneker.Swashbuckle.Authentication" />
paket add Soenneker.Swashbuckle.Authentication --version 11.0.3066
#r "nuget: Soenneker.Swashbuckle.Authentication, 11.0.3066"
#:package Soenneker.Swashbuckle.Authentication@11.0.3066
#addin nuget:?package=Soenneker.Swashbuckle.Authentication&version=11.0.3066
#tool nuget:?package=Soenneker.Swashbuckle.Authentication&version=11.0.3066
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.
Access-key links
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Configuration (>= 11.0.917)
- Soenneker.Extensions.Enumerable (>= 11.0.702)
- Soenneker.Extensions.HttpContext (>= 11.0.790)
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 |
|---|---|---|
| 11.0.3066 | 52 | 11/11/2026 |
| 11.0.3065 | 69 | 11/11/2026 |
| 11.0.3063 | 70 | 11/11/2026 |
| 11.0.3062 | 73 | 11/11/2026 |
| 11.0.3061 | 66 | 11/11/2026 |
| 11.0.3060 | 76 | 11/11/2026 |
| 11.0.3058 | 71 | 11/11/2026 |
| 11.0.3057 | 78 | 11/11/2026 |
| 11.0.3056 | 93 | 11/3/2026 |
| 11.0.3055 | 89 | 11/3/2026 |
| 11.0.3054 | 88 | 11/3/2026 |
| 11.0.3053 | 90 | 11/2/2026 |
| 11.0.3052 | 113 | 10/27/2026 |
| 11.0.3051 | 100 | 10/27/2026 |
| 11.0.3050 | 105 | 10/26/2026 |
| 11.0.3049 | 96 | 10/26/2026 |
| 11.0.3048 | 99 | 10/26/2026 |
| 11.0.3047 | 90 | 10/26/2026 |
| 11.0.3045 | 95 | 10/26/2026 |
| 4.0.3044 | 99 | 10/25/2026 |
Update dependency Soenneker.Extensions.HttpContext to 11.0.789 (#3961)