Path: redb-identity/src/redb.Identity.Core/OpenIddict/Handlers/ApplyPushedAuthorizationResponseHandler.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/src/redb.Identity.Core/OpenIddict/Handlers/ApplyPushedAuthorizationResponseHandler.cs
----
using OpenIddict.Server;
using static OpenIddict.Server.OpenIddictServerEvents;
namespace redb.Identity.Core.OpenIddict.Handlers;
///
/// Writes the Pushed Authorization Response (RFC 9126 §2.2 — request_uri/expires_in,
/// or error) to with HTTP 201 Created on success.
///
internal sealed class ApplyPushedAuthorizationResponseHandler
: IOpenIddictServerHandler
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
= OpenIddictServerHandlerDescriptor.CreateBuilder()
.UseSingletonHandler()
.SetOrder(int.MaxValue - 50_000)
.Build();
public ValueTask HandleAsync(ApplyPushedAuthorizationResponseContext context)
{
var exchange = context.Transaction.GetRouteExchange();
if (exchange is null)
return default;
RedbRouteOpenIddictServerHelpers.WriteResponseToExchange(exchange, context.Response);
// RFC 9126 §2.2: 201 Created on success. On error, fall through to the
// OAuth-error → HTTP-status mapper applied by the HTTP facade.
if (string.IsNullOrEmpty(context.Response.Error) && exchange.HasOut && exchange.Out is not null)
{
exchange.Out.Headers["redbHttp.ResponseCode"] = 201;
}
context.HandleRequest();
return default;
}
}