Soenneker.Validators.BasicAuth.Functions 4.0.215

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

Validates Azure Functions isolated-worker Basic Authentication credentials against a fixed-cost username comparison and PBKDF2 PHC password hash.

Install

dotnet add package Soenneker.Validators.BasicAuth.Functions

Registration

using Soenneker.Validators.BasicAuth.Functions.Registrars;
using Microsoft.Extensions.DependencyInjection;

services.AddBasicAuthValidatorAsSingleton();

The validator is stateless, so singleton registration is appropriate for most function apps. AddBasicAuthValidatorAsScoped() is also available.

Configure the expected credential pair:

{
  "BasicAuth": {
    "Username": "integration-client",
    "PasswordPhc": "<PBKDF2 PHC hash>"
  }
}

Store the PHC hash in the function app's secret-backed configuration, not the plaintext password.

Validate an HTTP trigger

using System.Net;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Soenneker.Validators.BasicAuth.Functions.Abstract;

public sealed class StatusFunction(IBasicAuthValidator validator)
{
    [Function("Status")]
    public HttpResponseData Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData request)
    {
        if (!validator.ValidateSafe(request))
            return request.CreateResponse(HttpStatusCode.Unauthorized);

        return request.CreateResponse(HttpStatusCode.OK);
    }
}

ValidateSafe returns false when the request lacks parseable Basic credentials or the username/password does not match. Required-configuration failures and invalid PHC data still throw; “safe” applies to request authentication failures, not application misconfiguration.

Validate performs the same checks but throws UnauthorizedAccessException("Invalid credentials") for request credential failures. Both methods return true on success.

Per-call overrides

bool valid = validator.ValidateSafe(
    request,
    configuredUsername: expectedUsername,
    configuredPasswordPhc: expectedPasswordPhc);

Overrides take precedence independently. A null argument falls back to BasicAuth:Username or BasicAuth:PasswordPhc; it does not disable that check.

Security boundaries

The HTTP trigger is anonymous at the Functions host level in the example because this validator performs the credential check. Ensure every applicable path invokes it before protected work. Require TLS, rate-limit guessable endpoints, and never log the authorization header or plaintext password.

The parser's temporary credential buffer is cleared after every attempt. Usernames use fixed-cost UTF-8 comparison and passwords are verified against PBKDF2 PHC data. The validator does not create a ClaimsPrincipal, issue a Basic challenge response, rotate secrets, or replace a full authentication/authorization system.

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.215 63 9/1/2026
4.0.213 67 8/31/2026
4.0.212 75 8/31/2026
4.0.211 72 8/31/2026
4.0.210 74 8/30/2026
4.0.209 73 8/30/2026
4.0.208 71 8/30/2026
4.0.207 71 8/30/2026
4.0.206 71 8/30/2026
4.0.205 78 8/30/2026
4.0.204 78 8/29/2026
4.0.203 86 8/29/2026
4.0.201 72 8/29/2026
4.0.200 79 8/26/2026
4.0.199 77 8/26/2026
4.0.198 90 8/25/2026
4.0.197 95 8/22/2026
4.0.196 107 8/18/2026
4.0.195 98 8/12/2026
4.0.194 89 8/12/2026
Loading failed

Updated NuGet packages