Soenneker.Extensions.HttpRequestDatas
4.0.159
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Extensions.HttpRequestDatas --version 4.0.159
NuGet\Install-Package Soenneker.Extensions.HttpRequestDatas -Version 4.0.159
<PackageReference Include="Soenneker.Extensions.HttpRequestDatas" Version="4.0.159" />
<PackageVersion Include="Soenneker.Extensions.HttpRequestDatas" Version="4.0.159" />
<PackageReference Include="Soenneker.Extensions.HttpRequestDatas" />
paket add Soenneker.Extensions.HttpRequestDatas --version 4.0.159
#r "nuget: Soenneker.Extensions.HttpRequestDatas, 4.0.159"
#:package Soenneker.Extensions.HttpRequestDatas@4.0.159
#addin nuget:?package=Soenneker.Extensions.HttpRequestDatas&version=4.0.159
#tool nuget:?package=Soenneker.Extensions.HttpRequestDatas&version=4.0.159
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.779)
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.169 | 75 | 10/15/2026 |
| 4.0.168 | 60 | 10/14/2026 |
| 4.0.167 | 104 | 10/14/2026 |
| 4.0.166 | 82 | 10/14/2026 |
| 4.0.165 | 96 | 10/14/2026 |
| 4.0.159 | 99 | 10/13/2026 |
| 4.0.158 | 89 | 10/12/2026 |
| 4.0.156 | 131 | 10/12/2026 |
| 4.0.154 | 132 | 10/11/2026 |
| 4.0.153 | 95 | 10/11/2026 |
| 4.0.152 | 207 | 9/30/2026 |
| 4.0.151 | 132 | 9/25/2026 |
| 4.0.150 | 99 | 9/25/2026 |
| 4.0.149 | 94 | 9/24/2026 |
| 4.0.148 | 160 | 9/16/2026 |
| 4.0.147 | 116 | 9/16/2026 |
| 4.0.146 | 101 | 9/15/2026 |
| 4.0.145 | 133 | 9/13/2026 |
| 4.0.144 | 117 | 9/13/2026 |
| 4.0.143 | 115 | 9/13/2026 |
Update dependency Soenneker.Extensions.String to 4.0.779 (#377)