Skip to content

[Design]: Unified ResourceRequest API for UltimateAuth-Protected Resources #95

Description

@mckaragoz

Summary

Extend UltimateAuth's unified client transport to support requests to application-defined APIs protected by UltimateAuth.

Currently, UltimateAuth provides a unified client API for authentication, sessions, users, credentials, and authorization operations.

However, applications also need to call their own protected API endpoints using the same authentication context and transport infrastructure.

Introduce a ResourceRequest capability that makes these requests consistent across Blazor Server, Blazor WebAssembly, and other supported client environments.

Motivation

This is particularly important for Blazor Server.

Unlike browser-based HTTP requests, server-side HttpClient requests do not automatically carry the browser's HttpOnly authentication cookies or device context.

As a result, developers may need to implement separate JavaScript-based HTTP transports or manually handle authentication context when calling UltimateAuth-protected application APIs.

UltimateAuth should provide a unified solution without requiring application-specific transport implementations.

Proposed Design

Expose a resource request API through IUAuthClient, for example:

var response = await _uauthClient.Resource.GetRequestAsync<ProductDto>(
    "/api/products/123");

var result = await _uauthClient.Resource.PostRequestAsync<CreateProductRequest, ProductDto>(
    "/api/products",
    request);

The exact API shape and naming can be finalized during implementation.

Requirements

  • Support standard HTTP methods: GET, POST, PUT, PATCH, and DELETE.
  • Support typed JSON requests and responses.
  • Reuse UltimateAuth's existing client transport infrastructure.
  • Automatically use the appropriate authentication mechanism for the current runtime and authentication mode.
  • Support browser-based requests in Blazor Server, including HttpOnly session cookies and required device/client-profile context.
  • Support Blazor WebAssembly and other client environments through their appropriate transport implementations.
  • Preserve HTTP status codes, including 401 and 403.
  • Support cancellation tokens and predictable error handling.
  • Support configurable API base addresses for same-origin and external resource APIs.
  • Integrate with existing session validation and reauthentication behavior where applicable.
  • Respect the application's CSRF protections for cookie-authenticated requests.

Architectural Principles

ResourceRequest is a transport capability, not a new authentication flow.

It should reuse existing UltimateAuth mechanisms rather than introduce separate token storage, session management, or authentication logic.

The same public client API should work across supported runtimes, while the underlying transport remains platform-specific.

UltimateAuth should not need to know the business domain, endpoint definitions, or DTO types of the application consuming the API.

Authorization must continue to be enforced server-side by the protected resource API.

Scope

In scope

  • Unified authenticated resource requests
  • Runtime-aware transport selection
  • Authentication context propagation
  • Typed request/response handling
  • Consistent HTTP error behavior
  • Integration with existing UltimateAuth client services

Out of scope

  • Replacing application-specific API services
  • Automatically generating API clients
  • Introducing new authorization policies
  • Bypassing server-side authorization
  • Replacing UltimateAuth's existing authentication endpoints
  • Implementing automatic retries for non-idempotent requests without explicit safeguards

Acceptance Criteria

  • A Blazor Server application using PureOpaque mode can call its own protected API through IUAuthClient.ResourceRequest without implementing custom JavaScript transport.
  • The browser's session cookie and required device context are handled correctly without exposing HttpOnly credentials to .NET or JavaScript.
  • The same client-facing API works in Blazor WebAssembly.
  • Requests without valid authentication receive 401.
  • Authenticated requests without sufficient authorization receive 403.
  • Requests with valid authentication and authorization succeed.
  • Existing UltimateAuth authentication and session APIs remain compatible.
  • Integration tests cover Blazor Server, Blazor WebAssembly, and relevant authentication modes.

Initial Use Case: Identity Lab

Identity Lab currently requires a dedicated browser transport to access endpoints such as:

GET /api/lab/admin/sandboxes
GET /api/lab/admin/statistics

These endpoints are protected using UltimateAuth authentication and the LabAdmin role.

With ResourceRequest, Identity Lab should be able to call them directly through the unified client API without maintaining a separate lab-api.js transport.

Target Release

v0.2.0 — Enhancement

This feature should be designed after the v0.1.0 release without introducing breaking changes to existing client authentication flows.

Activity

  1. added this to the v0.2.0 milestone on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions