Bundle: redb-identity / src/redb.Identity.Client (src.redb.Identity.Client.txt), 42 files
Snapshot: 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
Index: https://redbase.app/src/dev-2026-12-06/redb-identity/_index.txt
====
Path: redb-identity/src/redb.Identity.Client/ApiException.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.Client/ApiException.cs
----
using System.Net;
namespace redb.Identity.Client;
///
/// Thrown by Identity client methods when the server returns a non-success HTTP status.
/// Carries the status code, parsed RFC 7807 problem details (when available) and the raw body.
///
public sealed class ApiException : Exception
{
public HttpStatusCode StatusCode { get; }
public ProblemDetails? ProblemDetails { get; }
public string? RawBody { get; }
public ApiException(
HttpStatusCode statusCode,
string message,
ProblemDetails? problemDetails = null,
string? rawBody = null,
Exception? inner = null)
: base(message, inner)
{
StatusCode = statusCode;
ProblemDetails = problemDetails;
RawBody = rawBody;
}
}
/// RFC 7807 problem details (incl. ASP.NET ValidationProblemDetails.errors).
public sealed class ProblemDetails
{
public string? Type { get; set; }
public string? Title { get; set; }
public int? Status { get; set; }
public string? Detail { get; set; }
public string? Instance { get; set; }
/// Per-field validation errors (for ASP.NET ValidationProblemDetails).
public Dictionary? Errors { get; set; }
/// RFC 7807 extension members (e.g. trace_id, correlation_id).
public Dictionary? Extensions { get; set; }
}
Path: redb-identity/src/redb.Identity.Client/Auth/BearerTokenHandler.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.Client/Auth/BearerTokenHandler.cs
----
using System.Net.Http.Headers;
namespace redb.Identity.Client.Auth;
///
/// that adds Authorization: Bearer <token>
/// to outgoing requests. If the configured returns
/// null or an empty token, no header is added (anonymous flow allowed).
///
public sealed class BearerTokenHandler : DelegatingHandler
{
private readonly IAccessTokenProvider _tokenProvider;
public BearerTokenHandler(IAccessTokenProvider tokenProvider)
{
_tokenProvider = tokenProvider;
}
protected override async Task SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var token = await _tokenProvider.GetAccessTokenAsync(cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(token))
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/Auth/ClientCredentialsAccessTokenProvider.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.Client/Auth/ClientCredentialsAccessTokenProvider.cs
----
using System.Text.Json;
using Microsoft.Extensions.Options;
namespace redb.Identity.Client.Auth;
///
/// implementation using OAuth2 client_credentials grant.
/// Caches the access token until ~1 minute before expiry. Use for CLI / server-to-server
/// scenarios. Web should provide its own per-request HttpContext-based provider.
///
public sealed class ClientCredentialsAccessTokenProvider : IAccessTokenProvider, IDisposable
{
private readonly HttpClient _http;
private readonly IdentityClientOptions _opts;
private readonly AuthorityDiscovery _discovery;
private readonly SemaphoreSlim _lock = new(1, 1);
private string? _cachedToken;
private DateTimeOffset _expiresAt = DateTimeOffset.MinValue;
///
/// The token comes from the token_endpoint of the discovery document at
/// , not from .
///
public ClientCredentialsAccessTokenProvider(HttpClient http, IOptions opts)
{
_http = http;
_opts = opts.Value;
_discovery = new AuthorityDiscovery(http, _opts.Authority, ServiceCollectionExtensions.AuthorityOption);
}
public async Task GetAccessTokenAsync(CancellationToken ct = default)
{
if (_cachedToken is not null && DateTimeOffset.UtcNow < _expiresAt - TimeSpan.FromMinutes(1))
return _cachedToken;
await _lock.WaitAsync(ct).ConfigureAwait(false);
try
{
// Double-check after acquiring lock
if (_cachedToken is not null && DateTimeOffset.UtcNow < _expiresAt - TimeSpan.FromMinutes(1))
return _cachedToken;
if (string.IsNullOrEmpty(_opts.ClientId) || string.IsNullOrEmpty(_opts.ClientSecret))
throw new InvalidOperationException(
"ClientCredentialsAccessTokenProvider requires ClientId+ClientSecret in IdentityClientOptions.");
var form = new FormUrlEncodedContent(new[]
{
new KeyValuePair("grant_type", "client_credentials"),
new KeyValuePair("client_id", _opts.ClientId),
new KeyValuePair("client_secret", _opts.ClientSecret),
new KeyValuePair("scope", string.Join(' ', _opts.Scopes)),
});
var tokenEndpoint = await _discovery.GetEndpointAsync("token_endpoint", ct).ConfigureAwait(false);
using var resp = await _http.PostAsync(tokenEndpoint, form, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
using var doc = JsonDocument.Parse(json);
_cachedToken = doc.RootElement.GetProperty("access_token").GetString()!;
var expiresIn = doc.RootElement.TryGetProperty("expires_in", out var ei)
? ei.GetInt32() : 3600;
_expiresAt = DateTimeOffset.UtcNow.AddSeconds(expiresIn);
return _cachedToken;
}
finally
{
_lock.Release();
}
}
public void Dispose() => _lock.Dispose();
}
Path: redb-identity/src/redb.Identity.Client/Auth/IAccessTokenProvider.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.Client/Auth/IAccessTokenProvider.cs
----
namespace redb.Identity.Client.Auth;
///
/// Resolves a bearer access token for outgoing Identity API calls.
/// Implementations:
/// - HttpContextAccessTokenProvider (in redb.Identity.Web) — reads from cookie session
/// - — for CLI / server-to-server
///
public interface IAccessTokenProvider
{
Task GetAccessTokenAsync(CancellationToken ct = default);
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelBearerHandler.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.Client/Backchannel/BackchannelBearerHandler.cs
----
using System.Net.Http.Headers;
namespace redb.Identity.Client.Backchannel;
///
/// that attaches Authorization: Bearer <token>
/// using . Separate from
/// redb.Identity.Client.Auth.BearerTokenHandler so backchannel and user-context
/// clients can coexist in the same DI container.
///
internal sealed class BackchannelBearerHandler : DelegatingHandler
{
private readonly BackchannelTokenProvider _tokens;
public BackchannelBearerHandler(BackchannelTokenProvider tokens)
{
_tokens = tokens;
}
protected override async Task SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var token = await _tokens.GetAccessTokenAsync(cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(token))
{
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
}
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelIdentityClient.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.Client/Backchannel/BackchannelIdentityClient.cs
----
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.Extensions.Options;
using redb.Identity.Contracts.Sessions;
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client.Backchannel;
///
/// Default implementation. Owns a typed
/// registered via
/// .
///
public sealed class BackchannelIdentityClient : IBackchannelIdentityClient
{
private const string BasePath = "/api/v1/identity/revoked-sids";
private const string PasswordBasePath = "/api/v1/identity/password";
private const string AccountVerifyEmailBasePath = "/api/v1/identity/account/verify-email";
private const string AccountChangeEmailBasePath = "/api/v1/identity/account/change-email";
private const string AccountRegisterBasePath = "/api/v1/identity/account/register";
private readonly HttpClient _http;
private readonly JsonSerializerOptions _json;
public BackchannelIdentityClient(HttpClient http, IOptions opts)
{
_http = http;
var o = opts.Value;
_http.BaseAddress ??= o.BaseUrl;
_json = new JsonSerializerOptions(JsonSerializerDefaults.Web)
{
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter() }
};
}
public async Task AddRevokedSidAsync(
string? sid, string? sub, string? clientId,
DateTimeOffset? expiresAt = null,
CancellationToken ct = default)
{
var request = new RevokedSidsAddRequest
{
Sid = sid,
Sub = sub,
ClientId = clientId,
ExpiresAt = expiresAt
};
using var resp = await _http.PostAsJsonAsync(BasePath, request, _json, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))!;
}
public async Task GetRevokedSidsSinceAsync(
DateTimeOffset? cursor = null,
CancellationToken ct = default)
{
var url = cursor.HasValue
? $"{BasePath}/since?cursor={Uri.EscapeDataString(cursor.Value.ToString("O"))}"
: $"{BasePath}/since";
using var resp = await _http.GetAsync(url, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))!;
}
public async Task ForgotPasswordAsync(
PasswordForgotRequest request,
CancellationToken ct = default)
{
// Anonymous endpoint on the host — the management bearer the typed client carries
// is ignored by the anonymous-prefix bypass. Any non-2xx is treated as success at
// this layer to preserve the anti-enumeration contract end-to-end.
using var resp = await _http.PostAsJsonAsync($"{PasswordBasePath}/forgot", request, _json, ct).ConfigureAwait(false);
return new PasswordForgotResponse { Success = true };
}
public async Task ResetPasswordAsync(
PasswordResetRequest request,
CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{PasswordBasePath}/reset", request, _json, ct).ConfigureAwait(false);
if (!resp.IsSuccessStatusCode)
{
return new PasswordResetResponse
{
Success = false,
Error = "invalid_token",
ErrorDescription = "The reset token is invalid or has expired."
};
}
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))
?? new PasswordResetResponse { Success = false, Error = "empty_response" };
}
public async Task VerifyEmailConfirmAsync(
EmailVerifyConfirmRequest request,
CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{AccountVerifyEmailBasePath}/confirm", request, _json, ct).ConfigureAwait(false);
if (!resp.IsSuccessStatusCode)
{
return new EmailVerifyConfirmResponse
{
Success = false,
Error = "invalid_token",
ErrorDescription = "The verification token is invalid or has expired."
};
}
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))
?? new EmailVerifyConfirmResponse { Success = false, Error = "empty_response" };
}
public async Task ChangeEmailConfirmAsync(
ChangeEmailConfirmRequest request,
CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{AccountChangeEmailBasePath}/confirm", request, _json, ct).ConfigureAwait(false);
if (!resp.IsSuccessStatusCode)
{
return new ChangeEmailConfirmResponse
{
Success = false,
Error = "invalid_token",
ErrorDescription = "The confirmation token is invalid or has expired."
};
}
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))
?? new ChangeEmailConfirmResponse { Success = false, Error = "empty_response" };
}
public async Task RegisterAccountAsync(
RegisterAccountRequest request,
CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(AccountRegisterBasePath, request, _json, ct).ConfigureAwait(false);
if (resp.IsSuccessStatusCode)
{
return (await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false))
?? new RegisterAccountResponse { Success = false, Error = "empty_response" };
}
// Structured failure: the host always returns a typed body on rejections; surface
// the body verbatim so the BFF can render the actionable error to the user.
try
{
var body = await resp.Content.ReadFromJsonAsync(_json, ct).ConfigureAwait(false);
if (body is not null && !string.IsNullOrEmpty(body.Error))
return body;
}
catch
{
// Fall through to canonical fallback below.
}
var fallbackError = resp.StatusCode switch
{
System.Net.HttpStatusCode.NotFound or System.Net.HttpStatusCode.Forbidden => "registration_disabled",
System.Net.HttpStatusCode.Conflict => "duplicate",
System.Net.HttpStatusCode.BadRequest => "validation_error",
_ => "registration_failed",
};
return new RegisterAccountResponse
{
Success = false,
Error = fallbackError,
ErrorDescription = $"Account registration failed with HTTP status {(int)resp.StatusCode}.",
};
}
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelIdentityClientOptions.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.Client/Backchannel/BackchannelIdentityClientOptions.cs
----
namespace redb.Identity.Client.Backchannel;
///
/// Configuration for the service-to-service backchannel identity client
/// (W6-0). Holds client_credentials creds for the dedicated service
/// account that publishes/polls revoked-sids on behalf of a Web BFF.
///
public sealed class BackchannelIdentityClientOptions
{
///
/// Base URL of the Identity management API (/api/v1/identity/*). With
/// IdentityTransport:Http:ManagementPort set it is that port; the token does not come from here.
///
public Uri BaseUrl { get; set; } = new("https://localhost/");
///
/// Required. The issuer of the Identity server, for example https://id.example.org. The token is requested
/// from the token_endpoint that the discovery document at
/// {Authority}/.well-known/openid-configuration names, and from nowhere else. The document is read at the
/// first token request, not at start-up, and kept for the life of the client; when the server cannot be reached,
/// that request fails and the next one reads the document again.
///
public Uri? Authority { get; set; }
/// Client_id of the backchannel service account.
public string ClientId { get; set; } = string.Empty;
/// Client_secret of the backchannel service account.
public string ClientSecret { get; set; } = string.Empty;
/// Scopes requested via client_credentials. Defaults to identity:manage.
public string[] Scopes { get; set; } = ["identity:manage"];
/// Per-request timeout. Default 30s.
public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(30);
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelServiceCollectionExtensions.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.Client/Backchannel/BackchannelServiceCollectionExtensions.cs
----
using System.Net.Http.Headers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace redb.Identity.Client.Backchannel;
///
/// DI extensions for the W6-0 backchannel client. Registers
/// as a typed HttpClient backed by a
/// dedicated using client_credentials.
///
public static class BackchannelServiceCollectionExtensions
{
internal const string AuthorityOption = "BackchannelIdentityClientOptions.Authority";
///
/// Register the W6-0 backchannel client ().
/// Coexists with the regular user-context IIdentityClient registration; the
/// two clients use separate instances and separate
/// Authorization header pipelines.
///
public static IServiceCollection AddBackchannelIdentityClient(
this IServiceCollection services,
Action configure)
{
services.AddOptions()
.Configure(configure)
.Validate(o => o.Authority is { IsAbsoluteUri: true }, AuthorityDiscovery.MissingAuthorityMessage(AuthorityOption))
.ValidateOnStart();
// Token-acquisition HttpClient (no auth header): discovery and the token endpoint are absolute addresses
// taken from BackchannelIdentityClientOptions.Authority, not from BaseUrl.
services.AddHttpClient((sp, http) =>
{
var o = sp.GetRequiredService>().Value;
http.Timeout = o.Timeout;
});
services.AddTransient();
services.AddHttpClient((sp, http) =>
{
var o = sp.GetRequiredService>().Value;
http.BaseAddress = o.BaseUrl;
http.Timeout = o.Timeout;
http.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
})
.AddHttpMessageHandler();
return services;
}
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/BackchannelTokenProvider.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.Client/Backchannel/BackchannelTokenProvider.cs
----
using System.Text.Json;
using Microsoft.Extensions.Options;
using redb.Identity.Client.Internal;
namespace redb.Identity.Client.Backchannel;
///
/// Caches a client_credentials access token for the backchannel client.
/// Isolated from the global registration so a
/// Web BFF can keep its user-context provider while this one serves machine-context
/// requests. The token comes from the token_endpoint of the discovery document at
/// .
///
internal sealed class BackchannelTokenProvider : IDisposable
{
private readonly HttpClient _http;
private readonly IOptions _opts;
private readonly AuthorityDiscovery _discovery;
private readonly SemaphoreSlim _lock = new(1, 1);
private string? _cachedToken;
private DateTimeOffset _expiresAt = DateTimeOffset.MinValue;
public BackchannelTokenProvider(HttpClient http, IOptions opts)
{
_http = http;
_opts = opts;
_discovery = new AuthorityDiscovery(http, opts.Value.Authority, BackchannelServiceCollectionExtensions.AuthorityOption);
}
public async Task GetAccessTokenAsync(CancellationToken ct = default)
{
if (_cachedToken is not null && DateTimeOffset.UtcNow < _expiresAt - TimeSpan.FromMinutes(1))
return _cachedToken;
await _lock.WaitAsync(ct).ConfigureAwait(false);
try
{
if (_cachedToken is not null && DateTimeOffset.UtcNow < _expiresAt - TimeSpan.FromMinutes(1))
return _cachedToken;
var opts = _opts.Value;
if (string.IsNullOrEmpty(opts.ClientId) || string.IsNullOrEmpty(opts.ClientSecret))
throw new InvalidOperationException(
"BackchannelTokenProvider requires BackchannelIdentityClientOptions.ClientId and ClientSecret.");
var tokenEndpoint = await _discovery.GetEndpointAsync("token_endpoint", ct).ConfigureAwait(false);
var form = new FormUrlEncodedContent(new[]
{
new KeyValuePair("grant_type", "client_credentials"),
new KeyValuePair("client_id", opts.ClientId),
new KeyValuePair("client_secret", opts.ClientSecret),
new KeyValuePair("scope", string.Join(' ', opts.Scopes)),
});
using var resp = await _http.PostAsync(tokenEndpoint, form, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
using var doc = JsonDocument.Parse(json);
_cachedToken = doc.RootElement.GetProperty("access_token").GetString()!;
var expiresIn = doc.RootElement.TryGetProperty("expires_in", out var ei) ? ei.GetInt32() : 3600;
_expiresAt = DateTimeOffset.UtcNow.AddSeconds(expiresIn);
return _cachedToken;
}
finally
{
_lock.Release();
}
}
public void Dispose() => _lock.Dispose();
}
Path: redb-identity/src/redb.Identity.Client/Backchannel/IBackchannelIdentityClient.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.Client/Backchannel/IBackchannelIdentityClient.cs
----
using redb.Identity.Contracts.Sessions;
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client.Backchannel;
///
/// Narrow service-to-service client for the W6-0 backchannel revoked-sids API.
/// Authenticates via client_credentials using credentials supplied through
/// and is independent from the
/// user-context registration.
///
public interface IBackchannelIdentityClient
{
///
/// Publish a backchannel revocation entry. At least one of
/// / must be supplied.
///
Task AddRevokedSidAsync(
string? sid, string? sub, string? clientId,
DateTimeOffset? expiresAt = null,
CancellationToken ct = default);
///
/// Incremental poll. Omit for the first call (server
/// returns a baseline window of size RevokedSidsMaxRetention); on
/// subsequent calls pass .
///
Task GetRevokedSidsSinceAsync(
DateTimeOffset? cursor = null,
CancellationToken ct = default);
///
/// N-4 (Session C): proxy the anonymous password-recovery initiation to the Identity
/// host. Always succeeds from the caller's perspective per the anti-enumeration
/// contract — callers MUST NOT branch on the return value to leak account existence.
///
Task ForgotPasswordAsync(
PasswordForgotRequest request,
CancellationToken ct = default);
///
/// N-4 (Session C): proxy the anonymous password-reset consumption to the Identity
/// host. Returns the structured response so the BFF UI can distinguish
/// invalid_token / weak_password / success.
///
Task ResetPasswordAsync(
PasswordResetRequest request,
CancellationToken ct = default);
///
/// N4-6: proxy the anonymous e-mail-verification confirmation to the Identity host.
/// Returns the structured response collapsed to a generic invalid_token on
/// any non-2xx outcome — mirrors .
///
Task VerifyEmailConfirmAsync(
EmailVerifyConfirmRequest request,
CancellationToken ct = default);
///
/// N4-7: proxy the anonymous change-of-e-mail confirmation to the Identity host.
/// Returns the structured response collapsed to a generic invalid_token on any
/// non-2xx outcome — mirrors .
///
Task ChangeEmailConfirmAsync(
ChangeEmailConfirmRequest request,
CancellationToken ct = default);
///
/// N-3 (sub-step N3-7): proxy the anonymous self-service account registration to the
/// Identity host. Returns the structured response verbatim — unlike
/// the registration surface is NOT anti-enumeration,
/// so failure codes (duplicate / weak_password / validation_error /
/// registration_disabled) propagate to the caller so the UI can render actionable
/// messages.
///
Task RegisterAccountAsync(
RegisterAccountRequest request,
CancellationToken ct = default);
}
Path: redb-identity/src/redb.Identity.Client/GlobalUsings.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.Client/GlobalUsings.cs
----
global using System.Net.Http.Json;
global using redb.Identity.Client.Internal;
Path: redb-identity/src/redb.Identity.Client/IIdentityClient.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.Client/IIdentityClient.cs
----
namespace redb.Identity.Client;
///
/// Single facade for Identity HTTP API (admin / account / token / scim).
/// Methods are grouped by domain into partial interface files
/// (IIdentityClient.Users.cs, etc.) and implemented in matching
/// IdentityClient.<Domain>.cs partial classes.
///
public partial interface IIdentityClient
{
// Methods will be added by partial interfaces in W1-5..W1-7.
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Account.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.Client/IdentityClient.Account.cs
----
using System.Text.Json;
using redb.Identity.Contracts.Consents;
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// ── /me — profile ──
/// Get the caller's own profile.
Task GetMyProfileAsync(CancellationToken ct = default);
/// Update the caller's own profile (PUT).
Task UpdateMyProfileAsync(MeUpdateProfileRequest request, CancellationToken ct = default);
// ── /me/password ──
/// Change the caller's password. All sessions are revoked on success.
Task ChangeMyPasswordAsync(MeChangePasswordRequest request, CancellationToken ct = default);
// ── /me/sessions ──
/// List the caller's own active sessions.
Task ListMySessionsAsync(CancellationToken ct = default);
/// Revoke the session bound to the caller's current access token.
Task RevokeMyCurrentSessionAsync(CancellationToken ct = default);
/// Revoke one of the caller's own sessions by id.
Task RevokeMySessionAsync(long sessionId, CancellationToken ct = default);
/// Revoke all of the caller's sessions except the current one (identified by the sid claim).
Task RevokeMyOtherSessionsAsync(CancellationToken ct = default);
// ── /me/mfa ──
/// Get caller's MFA enrolment status.
Task GetMyMfaStatusAsync(CancellationToken ct = default);
/// Begin enrolment of an MFA method for the caller.
Task SetupMyMfaAsync(IDictionary body, CancellationToken ct = default);
/// Confirm a pending MFA enrolment with the OTP code.
Task ConfirmMyMfaAsync(IDictionary body, CancellationToken ct = default);
/// Disable a single MFA method registered to the caller.
Task DisableMyMfaMethodAsync(string method, CancellationToken ct = default);
/// Regenerate the caller's recovery codes (invalidates previous codes).
Task RegenerateMyRecoveryCodesAsync(CancellationToken ct = default);
/// Download the caller's recovery codes as text/plain (also regenerates).
Task DownloadMyRecoveryCodesAsync(CancellationToken ct = default);
// ── /me/webauthn ──
/// Get caller's WebAuthn enrolment status.
Task GetMyWebAuthnStatusAsync(CancellationToken ct = default);
/// Begin a WebAuthn registration ceremony.
Task BeginMyWebAuthnRegistrationAsync(IDictionary body, CancellationToken ct = default);
/// Complete WebAuthn registration with browser attestation.
Task CompleteMyWebAuthnRegistrationAsync(IDictionary body, CancellationToken ct = default);
/// List the caller's registered WebAuthn credentials.
Task ListMyWebAuthnCredentialsAsync(CancellationToken ct = default);
/// Rename a single WebAuthn credential.
Task RenameMyWebAuthnCredentialAsync(string key, IDictionary body, CancellationToken ct = default);
/// Delete a single WebAuthn credential.
Task DeleteMyWebAuthnCredentialAsync(string key, CancellationToken ct = default);
// ── /me/consents ──
/// List the caller's valid permanent consent grants.
Task ListMyConsentsAsync(CancellationToken ct = default);
/// Revoke the caller's permanent consent grant for a single client.
Task RevokeMyConsentAsync(string clientId, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string MeBase = "/api/v1/identity/me";
// ── Profile ──
public async Task GetMyProfileAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync(MeBase, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateMyProfileAsync(MeUpdateProfileRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync(MeBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
// ── Password ──
public async Task ChangeMyPasswordAsync(MeChangePasswordRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{MeBase}/password", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
// ── Sessions ──
public async Task ListMySessionsAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{MeBase}/sessions", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeMyCurrentSessionAsync(CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/sessions/current", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeMySessionAsync(long sessionId, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/sessions/{sessionId}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeMyOtherSessionsAsync(CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/sessions/others", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
// ── MFA (self) ──
public async Task GetMyMfaStatusAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{MeBase}/mfa", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task SetupMyMfaAsync(IDictionary body, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeBase}/mfa/setup", body, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task ConfirmMyMfaAsync(IDictionary body, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeBase}/mfa/confirm", body, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DisableMyMfaMethodAsync(string method, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/mfa/{Uri.EscapeDataString(method)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RegenerateMyRecoveryCodesAsync(CancellationToken ct = default)
{
using var resp = await _http.PostAsync($"{MeBase}/mfa/recovery-codes", content: null, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
///
/// Returns the raw so the caller can stream the
/// text/plain attachment to disk. Caller is responsible for disposal.
///
public async Task DownloadMyRecoveryCodesAsync(CancellationToken ct = default)
{
var resp = await _http.GetAsync($"{MeBase}/mfa/recovery-codes/download", HttpCompletionOption.ResponseHeadersRead, ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
return resp;
}
// ── WebAuthn (self) ──
public async Task GetMyWebAuthnStatusAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{MeBase}/webauthn", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task BeginMyWebAuthnRegistrationAsync(IDictionary body, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeBase}/webauthn/register/begin", body, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CompleteMyWebAuthnRegistrationAsync(IDictionary body, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeBase}/webauthn/register/complete", body, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task ListMyWebAuthnCredentialsAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{MeBase}/webauthn/credentials", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RenameMyWebAuthnCredentialAsync(string key, IDictionary body, CancellationToken ct = default)
{
var url = $"{MeBase}/webauthn/credentials/{Uri.EscapeDataString(key)}";
using var req = new HttpRequestMessage(HttpMethod.Patch, url) { Content = JsonContent.Create(body, options: _json) };
using var resp = await _http.SendAsync(req, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteMyWebAuthnCredentialAsync(string key, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/webauthn/credentials/{Uri.EscapeDataString(key)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
// ── Consents (self) ──
public async Task ListMyConsentsAsync(CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{MeBase}/consents", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeMyConsentAsync(string clientId, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{MeBase}/consents/{Uri.EscapeDataString(clientId)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
///
/// Grant the caller's permanent consent for an application. Used by native consent UIs
/// (e.g. the BFF Razor page) after the user approves a consent_required dialog.
/// The user id is taken from the access-token subject; the request body must not include one.
///
public async Task GrantMyConsentAsync(string clientId, IEnumerable scopes, CancellationToken ct = default)
{
var body = new GrantMyConsentRequest { ClientId = clientId, Scopes = scopes.ToArray() };
using var req = new HttpRequestMessage(HttpMethod.Post, $"{MeBase}/consents")
{
Content = JsonContent.Create(body, options: _json)
};
using var resp = await _http.SendAsync(req, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.AccountRegistration.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.Client/IdentityClient.AccountRegistration.cs
----
using System.Net;
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// \u2500\u2500 /account \u2014 N-3 self-service registration (anonymous) \u2500\u2500
///
/// Creates a new user account through the anonymous self-service registration
/// endpoint POST /api/v1/identity/account/register. Returns
/// { success = true, userId, login } on success. Distinct from the password-
/// recovery endpoints, this surface is NOT anti-enumeration: duplicate-login /
/// duplicate-email collisions and weak-password violations are returned as
/// structured error codes so the calling UI can render an actionable message.
/// Requires NO prior authentication.
///
Task RegisterAccountAsync(
RegisterAccountRequest request,
CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string AccountBase = "/api/v1/identity/account";
public async Task RegisterAccountAsync(
RegisterAccountRequest request,
CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{AccountBase}/register", request, _json, ct).ConfigureAwait(false);
// Success path \u2014 the server always returns a structured RegisterAccountResponse
// on 2xx, so deserialize directly.
if (resp.IsSuccessStatusCode)
{
return await resp.ReadJsonAsync(ct).ConfigureAwait(false)
?? new RegisterAccountResponse { Success = false, Error = "invalid_response" };
}
// Structured failure: the processor wraps every reject path in
// RegisterAccountResponse with a stable error code, so we forward it verbatim.
// If body deserialization fails (e.g. 404 because the route is gated off and no
// body is returned) fall back to a canonical "registration_disabled" envelope.
try
{
var body = await resp.ReadJsonAsync(ct).ConfigureAwait(false);
if (body is not null && !string.IsNullOrEmpty(body.Error))
return body;
}
catch
{
// Fall through to the canonical fallback below.
}
var fallbackError = resp.StatusCode switch
{
HttpStatusCode.NotFound or HttpStatusCode.Forbidden => "registration_disabled",
HttpStatusCode.Conflict => "duplicate",
HttpStatusCode.BadRequest => "validation_error",
_ => "registration_failed",
};
return new RegisterAccountResponse
{
Success = false,
Error = fallbackError,
ErrorDescription = $"Account registration failed with HTTP status {(int)resp.StatusCode}.",
};
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Applications.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.Client/IdentityClient.Applications.cs
----
using redb.Identity.Contracts.Applications;
using redb.Identity.Contracts.Common;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
Task> ListApplicationsAsync(int offset = 0, int count = 25, CancellationToken ct = default);
Task GetApplicationAsync(string id, CancellationToken ct = default);
Task CreateApplicationAsync(CreateApplicationRequest request, CancellationToken ct = default);
Task UpdateApplicationAsync(string id, UpdateApplicationRequest request, CancellationToken ct = default);
Task DeleteApplicationAsync(string id, CancellationToken ct = default);
///
/// Rotates the client_secret of a confidential application. The returned
/// field carries the freshly generated
/// plaintext secret — copy it immediately, subsequent calls will not expose it again
/// (server stores only the BCrypt hash). The previous secret stops working at the
/// token endpoint as soon as this call succeeds.
///
Task RotateApplicationSecretAsync(string id, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string ApplicationsBase = "/api/v1/identity/applications";
public async Task> ListApplicationsAsync(int offset = 0, int count = 25, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ApplicationsBase}?offset={offset}&count={count}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetApplicationAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ApplicationsBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateApplicationAsync(CreateApplicationRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(ApplicationsBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateApplicationAsync(string id, UpdateApplicationRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{ApplicationsBase}/{Uri.EscapeDataString(id)}", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteApplicationAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ApplicationsBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
public async Task RotateApplicationSecretAsync(string id, CancellationToken ct = default)
{
// Empty content body — server identifies the target purely from the route id.
using var resp = await _http.PostAsync(
$"{ApplicationsBase}/{Uri.EscapeDataString(id)}/rotate-secret",
content: null,
ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Audit.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.Client/IdentityClient.Audit.cs
----
using System.Globalization;
using redb.Identity.Contracts.Audit;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
/// Query the audit log with the given filters.
Task QueryAuditAsync(AuditQueryRequest filter, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string AuditBase = "/api/v1/identity/audit";
public async Task QueryAuditAsync(AuditQueryRequest filter, CancellationToken ct = default)
{
var qs = BuildAuditQuery(filter);
using var resp = await _http.GetAsync($"{AuditBase}{qs}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
private static string BuildAuditQuery(AuditQueryRequest f)
{
var parts = new List { $"offset={f.Offset}", $"count={f.Count}" };
if (!string.IsNullOrEmpty(f.EventType)) parts.Add($"eventType={Uri.EscapeDataString(f.EventType)}");
if (!string.IsNullOrEmpty(f.Category)) parts.Add($"category={Uri.EscapeDataString(f.Category)}");
if (!string.IsNullOrEmpty(f.UserId)) parts.Add($"userId={Uri.EscapeDataString(f.UserId)}");
if (!string.IsNullOrEmpty(f.Login)) parts.Add($"login={Uri.EscapeDataString(f.Login)}");
if (!string.IsNullOrEmpty(f.ClientId)) parts.Add($"clientId={Uri.EscapeDataString(f.ClientId)}");
if (f.From is { } from) parts.Add($"from={Uri.EscapeDataString(from.ToString("O", CultureInfo.InvariantCulture))}");
if (f.To is { } to) parts.Add($"to={Uri.EscapeDataString(to.ToString("O", CultureInfo.InvariantCulture))}");
return "?" + string.Join("&", parts);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.ChangeEmail.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.Client/IdentityClient.ChangeEmail.cs
----
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// \u2500\u2500 /me/change-email & /account/change-email \u2014 N4-7 strict change-of-e-mail \u2500\u2500
///
/// Initiates the verify-then-commit change-of-e-mail flow for the authenticated
/// caller. Issues a single-use confirmation token bound to the user's current
/// address AND the requested new address, and delivers the confirmation link via
/// the server's configured e-mail channel \u2014 to the NEW address. The current
/// address remains the canonical login until the link is clicked. Requires Bearer
/// auth (identity:manage or identity:account) and that the supplied
/// is whitelisted on the
/// client's ChangeEmailUris.
///
Task ChangeEmailRequestAsync(ChangeEmailRequestRequest request, CancellationToken ct = default);
///
/// Completes the change-of-e-mail flow by verifying + atomically consuming the
/// confirmation token issued earlier (via e-mail to the new address) and atomically
/// swapping the user's e-mail to the new value while flipping
/// UserProps.EmailVerified=true. The swap is only applied when the user's
/// current address still matches the snapshot captured at issue time. All failure
/// modes return a generic invalid_token response; granular reason is recorded
/// only in audit logs. This call does NOT require any prior authentication.
///
Task ChangeEmailConfirmAsync(ChangeEmailConfirmRequest request, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string MeChangeEmailBase = "/api/v1/identity/me/change-email";
private const string AccountChangeEmailBase = "/api/v1/identity/account/change-email";
public async Task ChangeEmailRequestAsync(ChangeEmailRequestRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeChangeEmailBase}/request", request, _json, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
return await resp.ReadJsonAsync(ct).ConfigureAwait(false)
?? new ChangeEmailRequestResponse { Success = false };
}
public async Task ChangeEmailConfirmAsync(ChangeEmailConfirmRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{AccountChangeEmailBase}/confirm", request, _json, ct).ConfigureAwait(false);
if (!resp.IsSuccessStatusCode)
{
return new ChangeEmailConfirmResponse
{
Success = false,
Error = "invalid_token",
ErrorDescription = "The confirmation token is invalid or has expired.",
};
}
return await resp.ReadJsonAsync(ct).ConfigureAwait(false)
?? new ChangeEmailConfirmResponse { Success = false, Error = "invalid_response" };
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.ClaimDefinitions.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.Client/IdentityClient.ClaimDefinitions.cs
----
using redb.Identity.Client.Internal;
using redb.Identity.Contracts.ClaimDefinitions;
using redb.Identity.Contracts.Common;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
Task> ListClaimDefinitionsAsync(int offset = 0, int count = 50, string? scope = null, long? applicationId = null, CancellationToken ct = default);
Task GetClaimDefinitionAsync(long id, CancellationToken ct = default);
Task CreateClaimDefinitionAsync(CreateClaimDefinitionRequest request, CancellationToken ct = default);
Task UpdateClaimDefinitionAsync(long id, UpdateClaimDefinitionRequest request, CancellationToken ct = default);
Task DeleteClaimDefinitionAsync(long id, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string ClaimDefinitionsBase = "/api/v1/identity/claim-definitions";
public async Task> ListClaimDefinitionsAsync(
int offset = 0, int count = 50, string? scope = null, long? applicationId = null,
CancellationToken ct = default)
{
var url = $"{ClaimDefinitionsBase}?offset={offset}&count={count}";
if (!string.IsNullOrEmpty(scope)) url += $"&scope={Uri.EscapeDataString(scope)}";
if (applicationId.HasValue) url += $"&applicationId={applicationId.Value}";
using var resp = await _http.GetAsync(url, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetClaimDefinitionAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ClaimDefinitionsBase}/{id}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateClaimDefinitionAsync(CreateClaimDefinitionRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(ClaimDefinitionsBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateClaimDefinitionAsync(long id, UpdateClaimDefinitionRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{ClaimDefinitionsBase}/{id}", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteClaimDefinitionAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ClaimDefinitionsBase}/{id}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.ClaimMappers.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.Client/IdentityClient.ClaimMappers.cs
----
using redb.Identity.Contracts.ClaimMappers;
using redb.Identity.Contracts.Common;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// ── Claim mappers ──
Task> ListClaimMappersAsync(string? owner = null, int offset = 0, int count = 25, CancellationToken ct = default);
Task GetClaimMapperAsync(string id, CancellationToken ct = default);
Task CreateClaimMapperAsync(CreateClaimMapperRequest request, CancellationToken ct = default);
Task UpdateClaimMapperAsync(string id, UpdateClaimMapperRequest request, CancellationToken ct = default);
Task DeleteClaimMapperAsync(string id, CancellationToken ct = default);
// ── Claim scopes (mapper bundles) ──
Task> ListClaimScopesAsync(int offset = 0, int count = 25, CancellationToken ct = default);
Task GetClaimScopeAsync(string id, CancellationToken ct = default);
Task CreateClaimScopeAsync(CreateClaimScopeRequest request, CancellationToken ct = default);
Task UpdateClaimScopeAsync(string id, UpdateClaimScopeRequest request, CancellationToken ct = default);
Task DeleteClaimScopeAsync(string id, CancellationToken ct = default);
// ── Application ↔ Scope assignments ──
Task ListClaimScopeAssignmentsAsync(string applicationId, CancellationToken ct = default);
Task AssignClaimScopeAsync(AssignClaimScopeRequest request, CancellationToken ct = default);
Task UnassignClaimScopeAsync(string applicationId, string scopeId, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string ClaimMappersBase = "/api/v1/identity/claim-mappers";
private const string ClaimScopesBase = "/api/v1/identity/claim-scopes";
public async Task> ListClaimMappersAsync(string? owner = null, int offset = 0, int count = 25, CancellationToken ct = default)
{
var url = $"{ClaimMappersBase}?offset={offset}&count={count}"
+ (owner is null ? "" : $"&owner={Uri.EscapeDataString(owner)}");
using var resp = await _http.GetAsync(url, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetClaimMapperAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ClaimMappersBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateClaimMapperAsync(CreateClaimMapperRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(ClaimMappersBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateClaimMapperAsync(string id, UpdateClaimMapperRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{ClaimMappersBase}/{Uri.EscapeDataString(id)}", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteClaimMapperAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ClaimMappersBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
// ── Claim scopes ──
public async Task> ListClaimScopesAsync(int offset = 0, int count = 25, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ClaimScopesBase}?offset={offset}&count={count}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetClaimScopeAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ClaimScopesBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateClaimScopeAsync(CreateClaimScopeRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(ClaimScopesBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateClaimScopeAsync(string id, UpdateClaimScopeRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{ClaimScopesBase}/{Uri.EscapeDataString(id)}", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteClaimScopeAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ClaimScopesBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
// ── Application ↔ Scope assignments ──
public async Task ListClaimScopeAssignmentsAsync(string applicationId, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ClaimScopesBase}/assignments?applicationId={Uri.EscapeDataString(applicationId)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task AssignClaimScopeAsync(AssignClaimScopeRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{ClaimScopesBase}/assignments", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UnassignClaimScopeAsync(string applicationId, string scopeId, CancellationToken ct = default)
{
var url = $"{ClaimScopesBase}/assignments?applicationId={Uri.EscapeDataString(applicationId)}&scopeId={Uri.EscapeDataString(scopeId)}";
using var resp = await _http.DeleteAsync(url, ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Consents.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.Client/IdentityClient.Consents.cs
----
using System.Text.Json;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
/// List consent grants for a user (admin).
Task ListUserConsentsAsync(long userId, CancellationToken ct = default);
/// Revoke a single consent grant (admin).
Task RevokeUserConsentAsync(long userId, long applicationId, CancellationToken ct = default);
/// Revoke all consent grants of a user (admin).
Task RevokeAllUserConsentsAsync(long userId, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string ConsentsAdminBase = "/api/v1/identity/consents";
public async Task ListUserConsentsAsync(long userId, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{ConsentsAdminBase}?userId={userId}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeUserConsentAsync(long userId, long applicationId, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ConsentsAdminBase}?userId={userId}&applicationId={applicationId}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task RevokeAllUserConsentsAsync(long userId, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{ConsentsAdminBase}/all?userId={userId}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.EmailVerification.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.Client/IdentityClient.EmailVerification.cs
----
using System.Text.Json;
using redb.Identity.Contracts.Users;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// ── /me/verify-email & /account/verify-email \u2014 N4-6 e-mail verification ──
///
/// Initiates the e-mail-verification flow for the authenticated caller. Issues a
/// single-use verification token bound to the caller's current e-mail address and
/// delivers it via the server's configured e-mail channel. Requires Bearer auth
/// (identity:manage or identity:account) and that the supplied
/// is whitelisted on the
/// client's EmailVerifyUris.
///
Task VerifyEmailSendAsync(EmailVerifySendRequest request, CancellationToken ct = default);
///
/// Completes the e-mail-verification flow by verifying + atomically consuming the
/// verification token issued earlier (via e-mail) and flipping
/// UserProps.EmailVerified to true when the bound e-mail still
/// matches the user's current address (double-change race protection). All failure
/// modes return a generic invalid_token response; granular reason is recorded
/// only in audit logs. This call does NOT require any prior authentication.
///
Task VerifyEmailConfirmAsync(EmailVerifyConfirmRequest request, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string MeVerifyEmailBase = "/api/v1/identity/me/verify-email";
private const string AccountVerifyEmailBase = "/api/v1/identity/account/verify-email";
public async Task VerifyEmailSendAsync(EmailVerifySendRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{MeVerifyEmailBase}/send", request, _json, ct).ConfigureAwait(false);
resp.EnsureSuccessStatusCode();
return await resp.ReadJsonAsync(ct).ConfigureAwait(false)
?? new EmailVerifySendResponse { Success = false };
}
public async Task VerifyEmailConfirmAsync(EmailVerifyConfirmRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{AccountVerifyEmailBase}/confirm", request, _json, ct).ConfigureAwait(false);
// Mirror ResetPasswordAsync: any non-2xx is collapsed into a generic invalid_token
// envelope so callers cannot distinguish "wrong jti" from "expired" from "consumed".
if (!resp.IsSuccessStatusCode)
{
return new EmailVerifyConfirmResponse
{
Success = false,
Error = "invalid_token",
ErrorDescription = "The verification token is invalid or has expired.",
};
}
return await resp.ReadJsonAsync(ct).ConfigureAwait(false)
?? new EmailVerifyConfirmResponse { Success = false, Error = "invalid_response" };
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Federation.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.Client/IdentityClient.Federation.cs
----
using redb.Identity.Contracts.Common;
using redb.Identity.Contracts.Federation;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
Task> ListFederationProvidersAsync(int offset = 0, int count = 25, CancellationToken ct = default);
Task GetFederationProviderAsync(string id, CancellationToken ct = default);
Task CreateFederationProviderAsync(CreateFederationProviderRequest request, CancellationToken ct = default);
Task UpdateFederationProviderAsync(string id, UpdateFederationProviderRequest request, CancellationToken ct = default);
Task DeleteFederationProviderAsync(string id, CancellationToken ct = default);
///
/// Returns the public projection of configured federation providers (anonymous —
/// safe for unauthenticated login pages). Strips ClientSecret, Authority,
/// scope list and other secret/configuration fields. Carries only ProviderId,
/// DisplayName, Kind and Priority — enough to render a sign-in button.
///
Task> ListPublicFederationProvidersAsync(CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string FederationBase = "/api/v1/identity/federation-providers";
public async Task> ListFederationProvidersAsync(int offset = 0, int count = 25, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{FederationBase}?offset={offset}&count={count}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetFederationProviderAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{FederationBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateFederationProviderAsync(CreateFederationProviderRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(FederationBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateFederationProviderAsync(string id, UpdateFederationProviderRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{FederationBase}/{Uri.EscapeDataString(id)}", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task DeleteFederationProviderAsync(string id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{FederationBase}/{Uri.EscapeDataString(id)}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
///
public async Task> ListPublicFederationProvidersAsync(CancellationToken ct = default)
{
// No Authorization header is sent for this call (uses _http baseline; the public
// endpoint is allow-anonymous). Callers that have a bearer token attached at the
// HttpClient level will still succeed — the endpoint simply ignores it.
using var resp = await _http.GetAsync($"{FederationBase}/public", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
var list = await resp.Content
.ReadFromJsonAsync>(_json, ct)
.ConfigureAwait(false);
return (IReadOnlyList?)list
?? Array.Empty();
}
}
Path: redb-identity/src/redb.Identity.Client/IdentityClient.Groups.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.Client/IdentityClient.Groups.cs
----
using System.Text.Json;
using redb.Identity.Client.Internal;
using redb.Identity.Contracts.Common;
using redb.Identity.Contracts.Groups;
namespace redb.Identity.Client;
public partial interface IIdentityClient
{
// ── Group CRUD ──
Task> ListRootGroupsAsync(int offset = 0, int count = 25, CancellationToken ct = default);
Task> SearchGroupsAsync(
string? query = null, string? groupType = null,
int offset = 0, int count = 25, CancellationToken ct = default);
Task GetGroupAsync(long id, CancellationToken ct = default);
Task CreateGroupAsync(CreateGroupRequest request, CancellationToken ct = default);
Task CreateChildGroupAsync(long parentId, CreateGroupRequest request, CancellationToken ct = default);
Task UpdateGroupAsync(long id, UpdateGroupRequest request, CancellationToken ct = default);
Task DeleteGroupAsync(long id, CancellationToken ct = default);
Task MoveGroupAsync(long id, MoveGroupRequest request, CancellationToken ct = default);
// ── Tree operations ──
Task GetGroupTreeAsync(long id, CancellationToken ct = default);
Task> GetGroupPathAsync(long id, CancellationToken ct = default);
Task> GetGroupChildrenAsync(long id, CancellationToken ct = default);
// ── Membership ──
Task> ListGroupMembersAsync(long id, CancellationToken ct = default);
Task AddGroupMemberAsync(long id, AddMemberRequest request, CancellationToken ct = default);
Task UpdateGroupMemberAsync(long id, long userId, UpdateMemberRequest request, CancellationToken ct = default);
Task RemoveGroupMemberAsync(long id, long userId, CancellationToken ct = default);
Task GetUserGroupsAsync(long userId, CancellationToken ct = default);
Task IsGroupMemberAsync(long id, long userId, CancellationToken ct = default);
}
public sealed partial class IdentityClient
{
private const string GroupsBase = "/api/v1/identity/groups";
public async Task> ListRootGroupsAsync(int offset = 0, int count = 25, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}?offset={offset}&count={count}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task> SearchGroupsAsync(
string? query = null, string? groupType = null,
int offset = 0, int count = 25, CancellationToken ct = default)
{
var url = $"{GroupsBase}/search?offset={offset}&count={count}";
if (!string.IsNullOrEmpty(query)) url += $"&query={Uri.EscapeDataString(query)}";
if (!string.IsNullOrEmpty(groupType)) url += $"&groupType={Uri.EscapeDataString(groupType)}";
using var resp = await _http.GetAsync(url, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task GetGroupAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}/{id}", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateGroupAsync(CreateGroupRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync(GroupsBase, request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task CreateChildGroupAsync(long parentId, CreateGroupRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{GroupsBase}/{parentId}/children", request, _json, ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task UpdateGroupAsync(long id, UpdateGroupRequest request, CancellationToken ct = default)
{
using var resp = await _http.PutAsJsonAsync($"{GroupsBase}/{id}", request, _json, ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
public async Task DeleteGroupAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.DeleteAsync($"{GroupsBase}/{id}", ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
public async Task MoveGroupAsync(long id, MoveGroupRequest request, CancellationToken ct = default)
{
using var resp = await _http.PostAsJsonAsync($"{GroupsBase}/{id}/move", request, _json, ct).ConfigureAwait(false);
await resp.EnsureSuccessOrThrowAsync(ct).ConfigureAwait(false);
}
// ── Tree operations ──
public async Task GetGroupTreeAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}/{id}/tree", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync(ct).ConfigureAwait(false);
}
public async Task> GetGroupPathAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}/{id}/path", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
public async Task> GetGroupChildrenAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}/{id}/children", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync>(ct).ConfigureAwait(false);
}
// ── Membership ──
public async Task> ListGroupMembersAsync(long id, CancellationToken ct = default)
{
using var resp = await _http.GetAsync($"{GroupsBase}/{id}/members", ct).ConfigureAwait(false);
return await resp.ReadJsonAsync