Soenneker.Extensions.HttpRequestDatas
4.0.152
Prefix Reserved
dotnet add package Soenneker.Extensions.HttpRequestDatas --version 4.0.152
NuGet\Install-Package Soenneker.Extensions.HttpRequestDatas -Version 4.0.152
<PackageReference Include="Soenneker.Extensions.HttpRequestDatas" Version="4.0.152" />
<PackageVersion Include="Soenneker.Extensions.HttpRequestDatas" Version="4.0.152" />
<PackageReference Include="Soenneker.Extensions.HttpRequestDatas" />
paket add Soenneker.Extensions.HttpRequestDatas --version 4.0.152
#r "nuget: Soenneker.Extensions.HttpRequestDatas, 4.0.152"
#:package Soenneker.Extensions.HttpRequestDatas@4.0.152
#addin nuget:?package=Soenneker.Extensions.HttpRequestDatas&version=4.0.152
#tool nuget:?package=Soenneker.Extensions.HttpRequestDatas&version=4.0.152
Soenneker.Extensions.HttpRequestDatas
Bearer-token parsing and unauthorized-response helpers for .NET isolated Azure Functions.
Installation
dotnet add package Soenneker.Extensions.HttpRequestDatas
Read a bearer token
using Soenneker.Extensions.HttpRequestDatas;
if (!request.TryGetBearer(out ReadOnlySpan<char> token, out string? authorizationHeader))
{
await request.WriteUnauthorized("A bearer token is required");
return;
}
bool valid = token.SequenceEqual(expectedToken);
TryGetBearer() reads the first nonblank Authorization header and accepts the Bearer scheme case-insensitively. Leading and trailing whitespace around the header and token are ignored. Empty tokens, tokens containing whitespace, other schemes, and headers larger than 8 KiB return false.
The returned token is a span over authorizationHeader; it does not allocate a second string. Keep the backing string in scope while using the span. If the token must survive an await or be stored, copy it first:
if (request.TryGetBearer(out ReadOnlySpan<char> token, out string? authorizationHeader))
{
string tokenText = token.ToString();
await ValidateToken(tokenText, cancellationToken);
}
The method extracts the credential but does not validate its signature, issuer, audience, expiry, or permissions.
Write an unauthorized result
await request.WriteUnauthorized("Invalid credentials");
return;
WriteUnauthorized() creates a 401 Unauthorized response, writes the supplied message as the body, and assigns the response to the current invocation result. A null message produces an empty body. It does not stop the function, so return immediately unless further processing is intentional.
| Product | Versions 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. |
-
net10.0
- Microsoft.Azure.Functions.Worker.Core (>= 2.52.0)
- Soenneker.Extensions.String (>= 4.0.770)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Extensions.HttpRequestDatas:
| Package | Downloads |
|---|---|
|
Soenneker.Entra.Middlewares.JwtAuth.Functions
Middleware for Azure Functions that validates Microsoft Entra JWTs |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.152 | 86 | 9/30/2026 |
| 4.0.151 | 123 | 9/25/2026 |
| 4.0.150 | 87 | 9/25/2026 |
| 4.0.149 | 86 | 9/24/2026 |
| 4.0.148 | 153 | 9/16/2026 |
| 4.0.147 | 104 | 9/16/2026 |
| 4.0.146 | 95 | 9/15/2026 |
| 4.0.145 | 126 | 9/13/2026 |
| 4.0.144 | 111 | 9/13/2026 |
| 4.0.143 | 108 | 9/13/2026 |
| 4.0.142 | 96 | 9/13/2026 |
| 4.0.141 | 130 | 9/12/2026 |
| 4.0.140 | 166 | 9/12/2026 |
| 4.0.139 | 137 | 9/9/2026 |
| 4.0.138 | 128 | 9/8/2026 |
| 4.0.137 | 129 | 9/8/2026 |
| 4.0.136 | 125 | 9/7/2026 |
| 4.0.135 | 129 | 9/7/2026 |
| 4.0.134 | 96 | 9/7/2026 |
| 4.0.133 | 152 | 9/5/2026 |
Updated Soenneker.Extensions.String to 4.0.770