Bundle: redb-identity / src/redb.Identity.Soap (src.redb.Identity.Soap.txt), 14 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.Soap/Fault.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.Soap/Fault.cs ---- using redb.Identity.Contracts; using redb.Route.Soap; namespace redb.Identity.Soap; /// /// Refusals, in the vocabulary WS-Trust clients read. /// /// This is the third transport that must say what the identity core decided, and the plan flagged the /// risk of it becoming a third independent copy of the translation. It is not: the reading of the core's /// verdict lives once, in , and what remains here is the rendering of that /// verdict into WS-Trust's own fault codes. Nothing in this file decides whether a request is allowed. /// /// /// A fault is not an optional nicety. A client that receives a successful response carrying an error /// document has no reason to look inside it, and generated WS-Trust clients branch on the fault code: /// FailedAuthentication and InvalidRequest are different outcomes to them. /// /// /// What reaches the wire is one thing; what it means for the route is another, and this file says both. /// A is the STS doing its job — the request was malformed, the caller could /// not authenticate, the scope is not theirs, they are over the rate limit — and it leaves as the STS's /// answer, with the exchange successful. A from is /// our side breaking, and it leaves as a failure the route's error count and dead-letter channel see. /// /// internal static class Fault { private const string Wst = "wst:"; /// The caller could not be authenticated, or the grant was refused. public static WsTrustRefusal FailedAuthentication(string reason) => new(Wst + "FailedAuthentication", reason); /// The request is malformed or missing something WS-Trust requires. public static WsTrustRefusal InvalidRequest(string reason) => new(Wst + "InvalidRequest", reason); /// The scope asked for is not one this caller may have. public static WsTrustRefusal InvalidScope(string reason) => new(Wst + "InvalidScope", reason); /// /// The caller is over the rate limit. WS-Trust has no code for it, and soap:Server is the closer /// of the two available readings — the caller must wait, not rewrite the request. It is still an /// answer, not a failure: throttling is the limiter working, the same way the HTTP facade's 429 is. /// public static WsTrustRefusal Throttled(string reason) => new("soap:Server", reason); /// Our side failed. The reason stays plain: internals are not the caller's business. public static SoapFaultException Server(string reason) => new("soap:Server", reason); /// /// Renders the core's verdict as the fault WS-Trust has for it. /// /// WS-Trust names far fewer outcomes than HTTP does, so several verdicts land on one fault. Where /// they do, the reason text carries what the code cannot, which is why it is never dropped. /// /// public static Exception FromVerdict(IdentityVerdictKind kind, string reason) => kind switch { IdentityVerdictKind.Unauthenticated or IdentityVerdictKind.Forbidden => FailedAuthentication(reason), IdentityVerdictKind.InvalidScope => InvalidScope(reason), IdentityVerdictKind.RateLimited => Throttled(reason), IdentityVerdictKind.Unavailable or IdentityVerdictKind.Timeout or IdentityVerdictKind.ServerError => Server(reason), // Everything left describes a request that cannot be served as written. _ => InvalidRequest(reason), }; } /// /// A WS-Trust fault the STS means as its answer. Raised wherever a step finds the request cannot be /// served, and turned into the reply at the step's boundary — never allowed to fail the exchange. /// internal sealed class WsTrustRefusal : Exception { public WsTrustRefusal(string faultCode, string faultString) : base($"WS-Trust refusal: {faultCode} — {faultString}") { FaultCode = faultCode; FaultString = faultString; } /// The code the caller branches on, e.g. wst:InvalidRequest. public string FaultCode { get; } /// The reason, carrying whatever the code cannot. public string FaultString { get; } } Path: redb-identity/src/redb.Identity.Soap/IdentitySoapTransportOptions.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.Soap/IdentitySoapTransportOptions.cs ---- using redb.Identity.Contracts.Configuration; namespace redb.Identity.Soap; /// /// Configuration for the Identity WS-Trust facade. Mirrors the HTTP and gRPC transport options in shape /// so operators configure every facade the same way: transport-local settings here, cross-module state /// through direct-vm:// into Core. /// public class IdentitySoapTransportOptions { /// SOAP-specific transport settings (path, port, TLS). public SoapTransportOptions Soap { get; set; } = new(); /// /// Cross-module shared options (Issuer + Features). Same instance type as /// RedbIdentityOptions.Shared, so a value declared once in Identity:* is observed /// identically by Core and by every facade. /// public IdentitySharedOptions Shared { get; set; } = new(); /// Issuer URI of the identity server. Proxy onto . public Uri Issuer { get => Shared.Issuer; set => Shared.Issuer = value; } /// Cross-module feature toggles. Proxy onto . public IdentityFeatureFlags Features { get => Shared.Features; set => Shared.Features = value; } } /// WS-Trust listener settings. public class SoapTransportOptions { /// Bind address. Default 0.0.0.0. public string Host { get; set; } = "0.0.0.0"; /// /// Port of the security token service. Default 5021. /// /// Kept off the HTTP facade's port by default. SOAP is ordinary HTTP/1.1 and could technically share /// a host, unlike gRPC which needs HTTP/2; the separation here buys something else: WS-Trust can be /// closed off from the internet while plain OIDC stays open, and the two surfaces get their own /// limits and their own suspend switch. /// /// public int Port { get; set; } = 5021; /// Path the STS answers on. Default /sts. public string Path { get; set; } = "/sts"; /// /// TLS. Unlike the other facades this is not merely recommended: UsernameToken carries the /// client secret in clear text unless the digest form is used, so the facade refuses to start /// without TLS. See for the single escape hatch. /// public bool Ssl { get; set; } = true; /// Path to the PFX certificate used when is true. public string? SslCertPath { get; set; } /// Password for . public string? SslCertPassword { get; set; } /// /// Starts the facade without TLS. Off by default, and deliberately awkward to reach: it exists for /// a local run behind a terminating proxy, and it is the operator's statement that the wire is /// already protected. With Ssl = false and this flag unset the facade refuses to start rather /// than quietly serving credentials in clear text. /// public bool AllowPlaintext { get; set; } /// /// Client-certificate policy (mTLS): NoCertificate (default), AllowCertificate or /// RequireCertificate. Off by default so deployments without a client-certificate PKI are not /// blocked; the natural choice for an STS in a closed contour is to require one. /// public string ClientCertificateMode { get; set; } = "NoCertificate"; /// /// Comma-separated SHA-1 thumbprints of accepted client certificates. When set, a certificate whose /// thumbprint is not listed is rejected even if its chain validates. /// public string? AllowedClientThumbprints { get; set; } /// /// Serve the WSDL on GET. Default true: the audience for this facade builds its clients with /// generators, and a generator needs a document to read. /// public bool Wsdl { get; set; } = true; /// /// Mirror the resolved client address into redbHttp.RemoteAddress so the IP-keyed processors /// in Core (per-IP throttle, brute-force lockout, device metadata) work behind this facade unchanged. /// Default true: without it those protections silently do nothing rather than failing loudly. /// public bool EmitHttpCompatHeaders { get; set; } = true; } Path: redb-identity/src/redb.Identity.Soap/Module/IdentitySoapConfigBinder.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.Soap/Module/IdentitySoapConfigBinder.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration.Memory; using redb.Route.Abstractions; namespace redb.Identity.Soap.Module; /// /// Binds the Tsak-merged context configuration into a strongly typed /// for the WS-Trust facade. /// /// /// Mirrors redb.Identity.Http.Module.IdentityHttpConfigBinder and its gRPC twin: Tsak hands the merged 5-layer /// config to the module as a nested IDictionary<string, object?> on /// ; we flatten it into entries and /// let IConfiguration.Bind hydrate the POCO, which gives free / nested-object /// handling. /// /// Section name is "IdentityTransport" — the same root the HTTP facade reads, so one section in /// context.json carries every facade: IdentityTransport:Http:*, IdentityTransport:Grpc:* and /// IdentityTransport:Soap:*. /// /// internal static class IdentitySoapConfigBinder { /// Top-level config section consumed by the transport facades. public const string SectionName = "IdentityTransport"; /// /// Builds from the context's /// "IdentityTransport" property. Returns defaults when the property is missing, so the module /// runs in development without explicit configuration. /// public static IdentitySoapTransportOptions Bind(IRouteContext context) { ArgumentNullException.ThrowIfNull(context); var options = new IdentitySoapTransportOptions(); var raw = context.GetProperty>(SectionName); if (raw is not null && raw.Count > 0) { var flat = new Dictionary(StringComparer.OrdinalIgnoreCase); Flatten(raw, prefix: string.Empty, sink: flat); new ConfigurationBuilder() .Add(new MemoryConfigurationSource { InitialData = flat }) .Build() .Bind(options, opt => opt.BindNonPublicProperties = false); } BindSharedSection(context, options); return options; } /// /// Binds the shared Identity:* section (issuer + feature flags) on top of the module-local /// values. Same source Core and the HTTP facade read, so a toggle declared once is observed /// identically everywhere; a value set explicitly on IdentityTransport:* is overwritten when /// the shared section provides it, matching the HTTP binder's precedence. /// private static void BindSharedSection(IRouteContext context, IdentitySoapTransportOptions options) { var identitySection = context.GetProperty>("Identity"); if (identitySection is null || identitySection.Count == 0) return; var flat = new Dictionary(StringComparer.OrdinalIgnoreCase); Flatten(identitySection, prefix: string.Empty, sink: flat); var cfg = new ConfigurationBuilder() .Add(new MemoryConfigurationSource { InitialData = flat }) .Build(); // Bind onto the existing instances so keys the shared section omits keep the module-local value. var features = cfg.GetSection("Features"); if (features.Exists()) features.Bind(options.Features); var issuer = cfg["Issuer"]; if (!string.IsNullOrWhiteSpace(issuer) && Uri.TryCreate(issuer, UriKind.Absolute, out var parsed)) options.Issuer = parsed; } private static void Flatten(IDictionary source, string prefix, IDictionary sink) { foreach (var kvp in source) { // Metadata keys ("//" comment blocks) belong to Tsak, not to the options POCO. if (kvp.Key.StartsWith("//", StringComparison.Ordinal)) continue; var key = prefix.Length == 0 ? kvp.Key : $"{prefix}:{kvp.Key}"; switch (kvp.Value) { case null: sink[key] = null; break; case IDictionary nested: Flatten(nested, key, sink); break; case System.Collections.IEnumerable list when kvp.Value is not string: var idx = 0; foreach (var item in list) { var indexed = $"{key}:{idx}"; if (item is IDictionary nestedItem) Flatten(nestedItem, indexed, sink); else sink[indexed] = item?.ToString(); idx++; } break; default: sink[key] = kvp.Value.ToString(); break; } } } } Path: redb-identity/src/redb.Identity.Soap/Module/IdentitySoapModuleHost.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.Soap/Module/IdentitySoapModuleHost.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using redb.Route.Abstractions; namespace redb.Identity.Soap.Module; /// /// Builds a self-contained child for the identity.soap Tsak /// context. Mirrors redb.Identity.Http.Module.IdentityHttpModuleHost: the worker's root container /// is built before modules load, so facade-owned services are constructed lazily here from the /// Tsak-merged config. /// /// /// /// Deliberately much smaller than the HTTP host. The WS-Trust facade serves no browser flows, so it owns no /// cookies, no DataProtection key-ring and no page state — and therefore needs no bridged /// IRedbService. Everything stateful stays in Core and is reached over direct-vm://. /// /// /// Registered here: the host logger factory and clock, the host configuration root (when present), the /// bound , and the itself — the /// latter is the only object able to resolve direct-vm endpoints through the shared registry, so /// brokered calls into Core take it rather than an . /// /// internal static class IdentitySoapModuleHost { public static ServiceProvider Build(IRouteContext routeContext, IdentitySoapTransportOptions options) { ArgumentNullException.ThrowIfNull(routeContext); ArgumentNullException.ThrowIfNull(options); var rootSp = routeContext.GetServiceProvider() ?? throw new InvalidOperationException( "IRouteContext is missing a backing IServiceProvider — cannot bridge host services."); var services = new ServiceCollection(); services.AddSingleton(rootSp.GetRequiredService()); services.AddLogging(); services.AddSingleton(rootSp.GetService() ?? TimeProvider.System); var hostConfiguration = rootSp.GetService(); if (hostConfiguration is not null) services.AddSingleton(hostConfiguration); services.AddSingleton(Options.Create(options)); services.AddOptions(); // Brokered calls into Core go through the route context, not through DI. services.AddSingleton(routeContext); // Captive-dependency detection at build time, same as the HTTP facade. return services.BuildServiceProvider(new ServiceProviderOptions { ValidateScopes = true, ValidateOnBuild = true, }); } } /// /// Disposes the WS-Trust facade child container when the surrounding route context stops. Without it the /// container would leak across Tsak hot-reloads. /// internal sealed class SoapChildHostDisposeListener : IRouteLifecycleListener { private readonly ServiceProvider _childSp; public SoapChildHostDisposeListener(ServiceProvider childSp) => _childSp = childSp; public Task OnContextStopped(IRouteContext context, CancellationToken ct) { _childSp.Dispose(); return Task.CompletedTask; } } Path: redb-identity/src/redb.Identity.Soap/Module/InitRoute.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.Soap/Module/InitRoute.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using redb.Identity.Soap.Module; using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Soap; // Tsak resolves the {Module}.config.json file by InitRoute's namespace // (TsakModuleRegistry.DiscoverModulesInAssembly). Keep this namespace aligned with the shipped config // filename `redb.Identity.Soap.config.json`. // // This module owns ContextName "identity.soap" — its own RouteContext, separate from Core ("identity"), // the HTTP facade ("identity.http") and the gRPC facade ("identity.grpc"). They communicate exclusively // through `direct-vm://identity-*` brokered messages whose DTOs live in redb.Identity.Contracts; this // facade has zero project-reference on Core (Phase 8 invariant). namespace redb.Identity.Soap; /// /// Tsak module entry point for the WS-Trust facade. Discovered by convention: public class InitRoute with /// a static main(IRouteContext). /// public static class InitRoute { public static IRouteContext main(IRouteContext context) { // The SOAP component serves on the shared Kestrel host, the same one Http, As2 and Grpc use, so a // WS-Trust route and an HTTP route in one worker never fight over a port. if (!context.HasComponent("soap")) context.AddComponent(new SoapComponent()); // One boot path, in a Tsak worker and in a host of its own alike: the binder reads // "IdentityTransport" from the context's configuration and the module host builds a child // ServiceProvider for this facade. var hostSp = context.GetServiceProvider() ?? throw new InvalidOperationException( "IServiceProvider not available on IRouteContext. " + "Ensure the Identity SOAP module is loaded after DI is configured."); var bound = IdentitySoapConfigBinder.Bind(context); var childSp = IdentitySoapModuleHost.Build(context, bound); // Ensure the child container outlives the routes but dies with the context. context.AddLifecycleListener(new SoapChildHostDisposeListener(childSp)); IServiceProvider soapSp = childSp; var options = soapSp.GetRequiredService>(); var logger = (soapSp.GetService() ?? hostSp.GetService()) ?.CreateLogger("redb.Identity.Soap.InitRoute"); var soap = options.Value.Soap; logger?.LogInformation( "[Identity.Soap.InitRoute] Building WS-Trust facade routes on {Host}:{Port}{Path} (TLS: {Ssl}, WSDL: {Wsdl})", soap.Host, soap.Port, soap.Path, soap.Ssl, soap.Wsdl); var routeContext = (RouteContext)context; routeContext.AddRoutes(new SoapFacadeRouteBuilder(options)); // One route, by design: WS-Trust puts Issue, Validate, Cancel and Renew on a single address and // tells them apart by the WS-Addressing Action. The endpoint count in the worker log is therefore // 1 for this module, and that is what «loaded correctly» looks like here — unlike the gRPC facade, // where the same counter is what revealed a module registering half of itself. return context; } } Path: redb-identity/src/redb.Identity.Soap/Module/manifest.json 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.Soap/Module/manifest.json ---- { "Name": "redb.Identity.Soap", "Version": "1.0.0", "EntryPoints": ["redb.Identity.Soap.dll"], "Dependencies": ["redb.Identity.Core.Module"] } Path: redb-identity/src/redb.Identity.Soap/Processors/SoapIdentityProcessors.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.Soap/Processors/SoapIdentityProcessors.cs ---- using System.Diagnostics; using System.Xml; using System.Xml.Linq; using redb.Identity.Contracts; using redb.Identity.Contracts.Routes; using redb.Route.Abstractions; using redb.Route.Soap; namespace redb.Identity.Soap.Processors; /// /// The steps that bridge WS-Trust to what Core expects. Same shape as the gRPC facade's processors, and /// for the same reason: the facade names the operation, translates, calls Core, translates back. It /// decides nothing about the protocol itself. /// internal static class SoapIdentityProcessors { /// Exchange property holding the resolved WS-Trust request type for later steps. public const string RequestTypeProperty = "identity:wstrust-request-type"; /// Exchange property holding the core address this request is bound for. public const string EndpointProperty = "identity:wstrust-endpoint"; /// Exchange property holding the scope asked for, echoed back into the answer. public const string ScopeProperty = "identity:wstrust-scope"; // ── request ────────────────────────────────────────────── /// /// Parses the RST, names the operation, and turns it into the parameters Core takes. Every failure /// here is the caller's, so it leaves as a fault with a WS-Trust code rather than as a server error — /// and as the STS's answer, not as a failure of the route (). /// public static Task MapRequest(IExchange exchange, CancellationToken ct) => AnswerRefusals(exchange, () => ParseRequest(exchange)); private static void ParseRequest(IExchange exchange) { var bodyXml = exchange.In.Body as string ?? exchange.In.Body?.ToString(); if (string.IsNullOrWhiteSpace(bodyXml)) throw Fault.InvalidRequest("The request carried no SOAP body."); XElement body; try { body = XElement.Parse(bodyXml, LoadOptions.None); } catch (XmlException ex) { throw Fault.InvalidRequest($"The request body is not well-formed XML: {ex.Message}"); } var rst = WsTrust.FindRst(body) ?? throw Fault.InvalidRequest("No wst:RequestSecurityToken element in the body."); var action = exchange.In.GetHeader(SoapHeaders.Action); var requestType = WsTrust.ResolveRequestType(action, rst) ?? throw Fault.InvalidRequest( "Unknown request type. Expected Issue, Validate, Cancel or Renew, named by " + "the WS-Addressing Action or by wst:RequestType."); var parameters = BuildParameters(exchange, rst, requestType); exchange.Properties[RequestTypeProperty] = requestType; exchange.Properties[EndpointProperty] = EndpointFor(requestType); if (WsTrust.ReadScope(rst) is { } scope) exchange.Properties[ScopeProperty] = scope; exchange.In.Body = parameters; } /// /// Runs a step, and turns a WS-Trust refusal it raises into the STS's answer. /// /// A malformed RST, bad credentials, a scope the caller may not have, a caller over the rate limit: /// each is the service doing exactly what it is built to do, and the caller must receive a /// soap:Fault with the right code. Thrown, the same fault reached the wire just as well — and /// also failed the exchange, so every correct refusal counted as a route error, filled a dead-letter /// channel and showed the STS as a failing route to whoever supervises it. Instead the refusal is put /// on the reply (, ) and the /// route stops; the SOAP consumer sends the fault and the exchange stays successful. /// /// /// Only is caught. A soap:Server fault — Core gave no answer, is /// unavailable, timed out — is our side breaking, and it keeps propagating as a failure, because that /// is precisely what the error count and the dead-letter channel exist to catch. /// /// private static Task AnswerRefusals(IExchange exchange, Action step) { try { step(); } catch (WsTrustRefusal refusal) { // The same message the consumer reads the reply from. var reply = exchange.HasOut ? exchange.Out! : exchange.In; reply.Headers[SoapHeaders.FaultCode] = refusal.FaultCode; reply.Headers[SoapHeaders.FaultString] = refusal.FaultString; exchange.Stop(); } return Task.CompletedTask; } /// /// The whole of the WS-Trust to OAuth translation. Client credentials come from the WS-Security /// UsernameToken, which the transport has already read; the token a request operates on comes from /// the request's own target element. /// private static Dictionary BuildParameters( IExchange exchange, XElement rst, string requestType) { var parameters = new Dictionary(StringComparer.OrdinalIgnoreCase); // UsernameToken is how a WS-Trust caller presents itself, and it maps onto the client credentials // every other transport sends as fields. Core reads exactly these names, so no separate // authentication path appears here. if (exchange.In.GetHeader(SoapHeaders.Username) is { Length: > 0 } username) parameters["client_id"] = username; if (exchange.In.GetHeader(SoapHeaders.Password) is { Length: > 0 } password) parameters["client_secret"] = password; switch (requestType) { case WsTrust.Issue: parameters["grant_type"] = "client_credentials"; if (WsTrust.ReadScope(rst) is { } scope) parameters["scope"] = scope; break; case WsTrust.Renew: parameters["grant_type"] = "refresh_token"; parameters["refresh_token"] = RequireTarget(rst, requestType); break; case WsTrust.Validate: case WsTrust.Cancel: parameters["token"] = RequireTarget(rst, requestType); break; } return parameters; } private static string RequireTarget(XElement rst, string requestType) => WsTrust.ReadTargetToken(rst, requestType) ?? throw Fault.InvalidRequest($"{requestType} needs a token in its wst:{requestType}Target element."); private static string EndpointFor(string requestType) => requestType switch { WsTrust.Issue => IdentityEndpoints.Token, WsTrust.Renew => IdentityEndpoints.Token, WsTrust.Validate => IdentityEndpoints.Introspect, WsTrust.Cancel => IdentityEndpoints.Revoke, _ => throw Fault.InvalidRequest($"Unsupported request type '{requestType}'."), }; // ── the hop into Core ──────────────────────────────────── /// /// Merge strategy for the hop into Core, used with Enrich rather than To. /// /// To would hand Core the facade's own exchange, and several Core processors end their work /// with exchange.Stop() — the per-IP limiter and the granular guard among them. That flag /// lives on the exchange, so the facade's own pipeline would stop too and the reply would leave as a /// raw dictionary, never having been turned into a SOAP response. Precisely the security-relevant /// answers were the ones that would lose their shape. /// /// public static IExchange AdoptCoreAnswer(IExchange facade, IExchange core) { // A genuine fault Core did not handle stays a fault: rethrown here it reaches the consumer and // becomes a SOAP fault there. Swallowing it would answer success with the request still in place. if (core.Exception is not null && !core.ExceptionHandled) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(core.Exception).Throw(); var answer = core.HasOut ? core.Out! : core.In; facade.In.Body = answer.Body; foreach (var header in answer.Headers) facade.In.Headers[header.Key] = header.Value; return facade; } // ── response ───────────────────────────────────────────── /// /// Turns Core's answer into the RSTR the caller expects, or into a fault. Which of the two is /// decided by the answer itself, not by the transport. A refusal leaves as the STS's answer, a /// breakage on our side as a failure (). /// public static Task MapResponse(IExchange exchange, CancellationToken ct) => AnswerRefusals(exchange, () => RenderAnswer(exchange)); private static void RenderAnswer(IExchange exchange) { var answer = ReadAnswer(exchange); var requestType = exchange.Properties.TryGetValue(RequestTypeProperty, out var rt) ? rt as string ?? WsTrust.Issue : WsTrust.Issue; if (answer is null) throw Fault.Server("The identity core returned no answer."); // A refusal must leave as a fault: a WS-Trust client reads the fault, not the body of a // response it was told succeeded. // // The status Core stated is what decides, not the error string. Reading the string alone would // demote a rate-limited answer — whose error is `rate_limited` and appears in no RFC 6749 table — // to «malformed request», telling a caller to fix what is not broken instead of to wait. The gRPC // facade learned this the same way; the reading now lives once, in IdentityVerdict. var error = Read(answer, "error"); var verdict = IdentityVerdict.Resolve(ReadResponseCode(exchange), error); if (verdict.IsRefusal()) { var reason = Read(answer, "error_description") ?? error ?? $"The identity core refused the request ({verdict})."; // Validate asks a question about a token, so an answer about that token is not a refusal of // the request: the caller authenticated fine and got a truthful «no». Answering // FailedAuthentication here would tell them their own credentials are bad and send them to // debug the wrong thing — and this is the ordinary case, since a revoked or expired token is // exactly what a caller runs Validate to discover. // // A refusal that is about the caller rather than the token still leaves as a fault. if (requestType == WsTrust.Validate && IsAboutTheToken(error)) { Emit(exchange, WsTrust.BuildStatusResponse(valid: false, reason)); return; } throw Fault.FromVerdict(verdict, reason); } // Validate is the exception to the rule above: an inactive token is a legitimate answer, not an // error, and WS-Trust says it with a status code (RFC 7662 §2.2 for the introspection side). if (requestType == WsTrust.Validate) { var active = answer.TryGetValue("active", out var a) && a is true or "true" or "True"; Emit(exchange, WsTrust.BuildStatusResponse(active, active ? null : "The token is not active.")); return; } if (requestType == WsTrust.Cancel) { Emit(exchange, WsTrust.BuildCancelResponse()); return; } var accessToken = Read(answer, "access_token") ?? throw Fault.Server("The identity core issued no access token."); long? expiresIn = null; if (answer.TryGetValue("expires_in", out var raw) && raw is not null && long.TryParse(raw.ToString(), out var seconds)) { expiresIn = seconds; } var scope = Read(answer, "scope") ?? (exchange.Properties.TryGetValue(ScopeProperty, out var s) ? s as string : null); Emit(exchange, WsTrust.BuildIssueResponse(accessToken, expiresIn, scope)); } /// /// Names the operation for the steps in Core that key on it. Core composes its idempotency record /// from scope, operation, caller and the caller's key; without a name every call through this facade /// would share the bucket "default". /// public static Func TagOperation(string operation) => (exchange, _) => { exchange.In.Headers["operation"] = operation; return Task.CompletedTask; }; /// /// Carries the caller's correlation id, or invents one from the ambient trace. WS-Trust has no field /// for this, so it travels as a SOAP header the caller may send and always comes back in the answer. /// public static Task PropagateCorrelationId(IExchange exchange, CancellationToken ct) { // First step on the SOAP route: the WS-Trust listener is HTTP, so the caller's request headers // land in In.Headers verbatim and Core trusts the reserved names (audit attribution, // credentials, idempotency operation). Same list as the HTTP and gRPC facades. redb.Identity.Contracts.Routes.IdentityReservedInboundHeaders.Strip(exchange.In.Headers); var supplied = exchange.In.GetHeader("X-Correlation-Id") ?? exchange.In.GetHeader(SoapHeaders.HeaderPrefix + "CorrelationId"); var correlationId = string.IsNullOrWhiteSpace(supplied) ? Activity.Current?.TraceId.ToString() ?? Guid.NewGuid().ToString("N") : supplied!; exchange.Properties["identity:correlation-id"] = correlationId; exchange.In.Headers["X-Correlation-Id"] = correlationId; return Task.CompletedTask; } // ── helpers ────────────────────────────────────────────── /// /// Whether a refusal concerns the token that was asked about rather than the caller who asked. /// /// Only these two are the token's own: everything else Core can refuse with — a bad client secret, /// a rate limit, our own failure — is about the caller or about us, and stays a fault so they are /// not told «that token is dead» when the truth is «we would not answer you». /// /// private static bool IsAboutTheToken(string? error) => error is "invalid_token" or "invalid_grant"; private static IDictionary? ReadAnswer(IExchange exchange) { var body = exchange.HasOut ? exchange.Out!.Body : exchange.In.Body; return body as IDictionary; } private static string? Read(IDictionary answer, string key) => answer.TryGetValue(key, out var value) && value is not null ? value.ToString() : null; /// /// Core's own verdict, as a status code. It travels as a header rather than in the body, so it /// survives an answer whose body is an error document and one whose body is a token alike. /// private static int? ReadResponseCode(IExchange exchange) { var source = exchange.HasOut ? exchange.Out! : exchange.In; return source.Headers.TryGetValue(IdentityVerdict.ResponseCodeHeader, out var raw) ? IdentityVerdict.ParseResponseCode(raw) : null; } /// /// Writes the response body. The transport wraps it in an envelope, so what leaves here is the body /// payload and nothing more. /// private static void Emit(IExchange exchange, XElement payload) { exchange.Out ??= new redb.Route.Core.Message(); exchange.Out.Body = payload.ToString(SaveOptions.DisableFormatting); exchange.Out.ContentType = "text/xml"; } } Path: redb-identity/src/redb.Identity.Soap/README.md 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.Soap/README.md ---- # redb.Identity.Soap A WS-Trust facade for redb.Identity: `Issue`, `Validate`, `Cancel` and `Renew` over SOAP, for callers whose stack builds clients from a WSDL and speaks WS-Trust rather than OAuth. It is a transport, not a second implementation. Every request is translated and handed to the same `direct-vm://identity-*` routes the HTTP and gRPC facades use, so all three observe one issuer, one client registry, one token store, one set of feature flags and one audit trail. Nothing about who may have what is decided here. ``` WS-Trust client ──▶ redb.Identity.Soap ──direct-vm://identity-*──▶ redb.Identity.Core gRPC client ──▶ redb.Identity.Grpc ──direct-vm://identity-*──▶ ↑ the same routes HTTP client ──▶ redb.Identity.Http ──direct-vm://identity-*──▶ ``` ## One address, four operations Unlike the gRPC facade, this one mounts a single route. That is WS-Trust's own shape: every operation goes to one address and is told apart by the WS-Addressing `Action`, which is what generated clients emit. The endpoint counter in a worker log therefore reads **1** for this module, not 4. | Operation | Action suffix | Core route | RFC / spec | |---|---|---|---| | `Issue` | `/RST/Issue` | `identity-token` | WS-Trust 1.3 §4.1, RFC 6749 §4.4 | | `Validate` | `/RST/Validate` | `identity-introspect` | WS-Trust 1.3 §7, RFC 7662 | | `Cancel` | `/RST/Cancel` | `identity-revoke` | WS-Trust 1.3 §5, RFC 7009 | | `Renew` | `/RST/Renew` | `identity-token` | WS-Trust 1.3 §6, RFC 6749 §6 | A client that sends no `Action` is still served: `wst:RequestType` inside the body is read as the fallback, because clients omitting the addressing header are common enough that refusing them would mean refusing the audience this facade exists for. ### What is not here Browser flows (`authorize`, consent, login) stay on HTTP because they need a browser, redirects and a cookie session. DPoP stays on HTTP because RFC 9449 binds its proof to an HTTP method and URL. The administrative surface stays on HTTP and gRPC: someone arriving for WS-Trust wants tokens, and usually manages users somewhere else. WS-Federation is a separate protocol with its own plan. ## The token The `RequestSecurityTokenResponse` carries our ordinary JWT as a `wsse:BinarySecurityToken`, declared with the RFC 8693 JWT value type. No second token format enters the system, so introspection and revocation work on it without a single change — it is literally the same object every other transport issues. SAML assertions are deliberately not implemented; the reasoning, and the conditions under which that would be revisited, are in `doc/SOAP/OPEN_QUESTIONS.md`. ## Refusals are faults A refusal leaves as a `soap:Fault`, never as a successful response carrying an error document: a client that is told the call succeeded has no reason to look inside it, and generated WS-Trust clients branch on the fault code. | Core's verdict | Fault | |---|---| | Caller not authenticated, or refused | `wst:FailedAuthentication` | | Scope not granted | `wst:InvalidScope` | | Malformed or unsupported request | `wst:InvalidRequest` | | Rate limited, unavailable, our failure | `soap:Server` | Which verdict applies is decided by the core, not here. The status the core stated outranks the OAuth `error` string in the body — read from the string alone, a rate-limited answer would fall through to "malformed request" and tell a caller to fix what is not broken instead of to wait. That reading lives once, in `redb.Identity.Contracts/IdentityVerdict.cs`, shared with the gRPC facade. ## TLS is required The facade **refuses to start** without TLS. This is stricter than the other facades, for a specific reason rather than a cautious one: `UsernameToken` carries the client secret in clear text unless the digest form is used, so an STS on plain HTTP publishes credentials to anyone on the path. A warning in a log is read after they have already travelled. `AllowPlaintext: true` is the single way out, for a connection already terminated by a trusted proxy. It exists so an operator states that choice rather than stumbling into it. mTLS is available through `ClientCertificateMode` with `AllowedClientThumbprints` for pinning — the natural configuration for an STS in a closed contour, where callers are known partners. An unrecognised mode value is refused at start rather than read as "no certificate": a typo must not turn mTLS off on an endpoint whose operator believes it is on. ## Configuration Lives in the shared `context.json` under `IdentityTransport:Soap`, the same root the other facades read. Issuer and feature flags come from `Identity:*`, so a value declared once is observed identically by the core and by every facade. ```jsonc "identity.soap": { "IdentityTransport": { "Soap": { "Host": "0.0.0.0", "Port": 5021, "Path": "/sts", "Ssl": true, "SslCertPath": "/etc/certs/sts.pfx", // A secret. Supply through an L5 override rather than this file: // Tsak__Contexts__identity.soap__Override__IdentityTransport__Soap__SslCertPassword= "SslCertPassword": null, "AllowPlaintext": false, "ClientCertificateMode": "NoCertificate", "AllowedClientThumbprints": null, "Wsdl": true, "EmitHttpCompatHeaders": true } } } ``` `EmitHttpCompatHeaders` mirrors the caller's address into `redbHttp.RemoteAddress`, which is what the core's per-IP throttle and brute-force lockout key on. Leave it on: without it those protections do not fail, they see no address and quietly do nothing. ## The WSDL Served on `GET {Path}?wsdl`, with the `soap:address` rewritten to the URL it was fetched from, so a generated client points back at the endpoint it was generated from. This is not decoration: the audience for this facade builds clients with generators, and an STS that answers only POST is one a WCF or CXF developer cannot start from. ## Packaging Ships as a Tsak `.tpkg` with its own context, `identity.soap`, and zero compile-time references to `redb.Identity.Core` — the two meet only over `direct-vm://`. Build it with `scripts/pack-tpkg.ps1 -Module Soap`; the package drops into the worker's `modules\` folder alongside `context.json`. Path: redb-identity/src/redb.Identity.Soap/SoapFacadeRouteBuilder.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.Soap/SoapFacadeRouteBuilder.cs ---- using Microsoft.Extensions.Options; using redb.Identity.Soap.Processors; using redb.Route.Core; using redb.Route.Soap; using SoapDsl = redb.Route.Soap.Fluent.Soap; namespace redb.Identity.Soap; /// /// WS-Trust facade for redb.Identity. Maps Issue, Validate, Cancel and /// Renew onto the same direct-vm://identity-* routes HTTP and gRPC use. /// /// One route, not four. This is where the shape departs from the gRPC facade, and not by preference: /// WS-Trust puts all four operations on one address and distinguishes them by the WS-Addressing /// Action. Generated clients expect exactly that, so the operation is resolved by parsing rather /// than by routing. /// /// /// Scope is the service-to-service subset, as on gRPC. Browser flows stay on HTTP because they need a /// browser, redirects and a cookie session; DPoP stays on HTTP because RFC 9449 binds its proof to an /// HTTP method and URL. /// /// public class SoapFacadeRouteBuilder : RouteBuilder { private readonly IdentitySoapTransportOptions _options; public SoapFacadeRouteBuilder(IOptions options) { ArgumentNullException.ThrowIfNull(options); _options = options.Value; } /// Registry key for the TLS material, kept out of the endpoint URI on purpose. private const string TlsFactoryName = "identity-soap-tls"; protected override void Configure() { var soap = _options.Soap; RequireTransportSecurity(soap); From(BuildListener(soap)) .RouteId("soap-identity-sts") .Process(SoapIdentityProcessors.PropagateCorrelationId) .Process(SoapIdentityProcessors.MapRequest) // The operation is known only after the body is parsed, so it is named here rather than by // the address. Core's idempotency cache keys on it. .Process(TagResolvedOperation) // Enrich, not To: several Core processors end with exchange.Stop(), and that flag would stop // this pipeline too, sending the raw dictionary out instead of an RSTR. See AdoptCoreAnswer. .Enrich( e => e.Properties.TryGetValue(SoapIdentityProcessors.EndpointProperty, out var endpoint) ? endpoint as string ?? string.Empty : string.Empty, SoapIdentityProcessors.AdoptCoreAnswer) .Process(SoapIdentityProcessors.MapResponse); } /// /// Tags the operation once has resolved it. Without /// a name, every call through this facade shares Core's idempotency bucket "default", and two /// different operations carrying one key would collide. /// private static Task TagResolvedOperation(redb.Route.Abstractions.IExchange exchange, CancellationToken ct) { var requestType = exchange.Properties.TryGetValue( SoapIdentityProcessors.RequestTypeProperty, out var value) ? value as string : null; if (!string.IsNullOrEmpty(requestType)) exchange.In.Headers["operation"] = requestType!.ToLowerInvariant(); return Task.CompletedTask; } /// /// Refuses to start without transport security. /// /// This is stricter than the other facades, and the reason is specific rather than cautious: /// UsernameToken carries the client secret in clear text unless the digest form is used, so /// an STS on plain HTTP publishes credentials to anyone on the path. A warning in the log would be /// read after the fact; a refusal is read before. /// /// /// is the way out for a run behind a terminating /// proxy, and it exists so the operator states that choice rather than stumbling into it. /// /// private static void RequireTransportSecurity(SoapTransportOptions soap) { if (soap.Ssl || soap.AllowPlaintext) return; throw new InvalidOperationException( "redb.Identity.Soap refuses to start without TLS: WS-Security UsernameToken carries the " + "client secret in clear text. Set IdentityTransport:Soap:Ssl=true with a certificate, or " + "set AllowPlaintext=true if the connection is already terminated by a trusted proxy."); } /// /// Builds the listener. TLS material travels through a named connection factory rather than in the /// endpoint URI: the URI is the route key, handled as a plain string in plenty of places, and a /// value never put there cannot be disclosed by a path that forgets to redact it. /// private string BuildListener(SoapTransportOptions soap) { var mode = ParseClientCertificateMode(soap.ClientCertificateMode); Context!.AddToRegistry(TlsFactoryName, new SoapConnectionFactory { Ssl = soap.Ssl, SslCertPath = soap.SslCertPath, SslCertPassword = soap.SslCertPassword, ClientCertificateMode = mode, AllowedClientThumbprints = soap.AllowedClientThumbprints, // The contract, served on GET. The audience for this facade builds clients with generators, // and a generator needs a document to read. Wsdl = soap.Wsdl ? WsdlDocument.ReadContent() : null, }); var builder = SoapDsl.Listen(soap.Path) .Host(soap.Host) .Port(soap.Port) .ConnectionFactory(TlsFactoryName) // Core's IP-keyed processors — the per-IP throttle, the brute-force lockout, device metadata // — read redbHttp.RemoteAddress. Without this bridge they would see no address and quietly // do nothing, so the facade would be the one surface where those protections are absent. .HttpCompatHeaders(soap.EmitHttpCompatHeaders); // TLS and the client-certificate policy are stated on the factory, so the URI carries neither a // certificate path nor a password. The scheme still has to say TLS, because that is where the // component reads the decision from. if (soap.Ssl) builder = builder.Ssl(); return builder.Build(); } /// /// Reads the configured client-certificate mode. An unrecognised value is refused rather than /// silently treated as «no certificate»: a typo in this setting would turn mTLS off on an endpoint /// whose operator believes it is on. /// private static SoapClientCertificateMode ParseClientCertificateMode(string? configured) { if (string.IsNullOrWhiteSpace(configured)) return SoapClientCertificateMode.NoCertificate; if (Enum.TryParse(configured, ignoreCase: true, out var mode)) return mode; throw new InvalidOperationException( $"Unknown IdentityTransport:Soap:ClientCertificateMode value '{configured}'. " + $"Expected one of: {string.Join(", ", Enum.GetNames())}."); } } Path: redb-identity/src/redb.Identity.Soap/WsTrust.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.Soap/WsTrust.cs ---- using System.Xml.Linq; using redb.Identity.Contracts.Common; namespace redb.Identity.Soap; /// /// The WS-Trust vocabulary and the translation between it and what Core speaks. /// /// Core takes form-encoded parameters, the same set on every transport: grant_type, /// client_id, token and friends. WS-Trust says the same things in XML with different /// names. This type is the whole of that translation, and it deliberately holds no logic beyond it: the /// facade must not become a second authorization server. /// /// internal static class WsTrust { public static readonly XNamespace Wst = "http://docs.oasis-open.org/ws-sx/ws-trust/200512"; public static readonly XNamespace Wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; public static readonly XNamespace Wsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; public static readonly XNamespace Wsp = "http://schemas.xmlsoap.org/ws/2004/09/policy"; public static readonly XNamespace Wsa = "http://www.w3.org/2005/08/addressing"; /// The four request types this facade serves, by their WS-Trust URI suffix. public const string Issue = "Issue"; public const string Validate = "Validate"; public const string Cancel = "Cancel"; public const string Renew = "Renew"; /// Value type announcing that the carried token is a JWT, per RFC 8693's URN. public const string JwtValueType = "urn:ietf:params:oauth:token-type:jwt"; /// Encoding declared on a BinarySecurityToken whose content is base64. public const string Base64Encoding = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"; public const string StatusTokenType = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Status"; public const string StatusValid = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/status/valid"; public const string StatusInvalid = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/status/invalid"; /// /// Names the operation. The WS-Addressing Action is the primary source because that is what /// the specification routes on and what generators emit; wst:RequestType inside the body is /// the fallback, because clients that omit the addressing header are common enough that failing /// them would be failing the audience this facade exists for. /// public static string? ResolveRequestType(string? action, XElement? rst) { var fromAction = LastSegment(action); if (IsKnown(fromAction)) return fromAction; var fromBody = LastSegment(rst?.Element(Wst + "RequestType")?.Value); return IsKnown(fromBody) ? fromBody : null; static bool IsKnown(string? value) => value is Issue or Validate or Cancel or Renew; } /// Takes the trailing token of a slash-separated URI, which is where the verb lives. private static string? LastSegment(string? uri) { if (string.IsNullOrWhiteSpace(uri)) return null; var trimmed = uri!.TrimEnd('/'); var slash = trimmed.LastIndexOf('/'); return slash < 0 ? trimmed : trimmed[(slash + 1)..]; } /// Finds the RequestSecurityToken element, wherever the body put it. public static XElement? FindRst(XElement body) => body.Name == Wst + "RequestSecurityToken" ? body : body.Descendants(Wst + "RequestSecurityToken").FirstOrDefault(); /// /// Reads the token a request operates on. Validate, Cancel and Renew each name /// their target with a different element, and each wraps it in a security-token reference or carries /// it inline, so the search is for the first thing that looks like a token under the target. /// public static string? ReadTargetToken(XElement rst, string requestType) { var targetName = requestType switch { Validate => "ValidateTarget", Cancel => "CancelTarget", Renew => "RenewTarget", _ => null, }; if (targetName is null) return null; var target = rst.Element(Wst + targetName); if (target is null) return null; // Inline BinarySecurityToken is the shape we emit ourselves, so it is the shape we read first. var binary = target.Descendants(Wsse + "BinarySecurityToken").FirstOrDefault(); if (binary is not null) return Decode(binary); // Otherwise take the first non-empty text under the target: a bare token, or a reference whose // URI is the token itself. Anything more elaborate is a token store lookup we do not have. var text = target.DescendantsAndSelf() .Select(e => e.Value.Trim()) .FirstOrDefault(v => v.Length > 0); return string.IsNullOrEmpty(text) ? null : text; } /// /// The scope being asked for. WS-Trust says this with AppliesTo carrying an endpoint /// reference; some stacks send a plain wst:Scope. Both are read, and neither is required. /// public static string? ReadScope(XElement rst) { var appliesTo = rst.Element(Wsp + "AppliesTo"); var address = appliesTo?.Descendants(Wsa + "Address").FirstOrDefault()?.Value.Trim(); if (!string.IsNullOrEmpty(address)) return address; var scope = rst.Element(Wst + "Scope")?.Value.Trim(); return string.IsNullOrEmpty(scope) ? null : scope; } /// /// Content of a BinarySecurityToken: decoded when it declares the Base64Binary encoding, /// its raw text when it declares none. A declared base64 value must be an xs:base64Binary, /// whose lexical form allows whitespace between characters but only zero unused bits in the last /// one; a value that is not is the caller's error and faults with wst:InvalidRequest. /// private static string Decode(XElement binarySecurityToken) { var raw = binarySecurityToken.Value.Trim(); var encoding = (string?)binarySecurityToken.Attribute("EncodingType"); if (encoding is null || !encoding.EndsWith("Base64Binary", StringComparison.Ordinal)) return raw; var compact = string.Concat(raw.Where(c => c is not (' ' or '\t' or '\r' or '\n'))); if (!Base64Canonical.TryDecode(compact, out var bytes)) throw Fault.InvalidRequest("The BinarySecurityToken is declared Base64Binary but its content is not base64."); return System.Text.Encoding.UTF8.GetString(bytes); } // ── building the answer ────────────────────────────────── /// /// Builds the Issue and Renew answer: a response collection carrying the token. /// /// The token is a JWT, declared as such by its value type, and base64-wrapped because that is what /// BinarySecurityToken means. Lifetime is emitted when the answer carried one: a client that /// caches tokens needs to know when to stop. /// /// public static XElement BuildIssueResponse(string accessToken, long? expiresInSeconds, string? scope) { var token = new XElement(Wsse + "BinarySecurityToken", new XAttribute("ValueType", JwtValueType), new XAttribute("EncodingType", Base64Encoding), Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(accessToken))); var response = new XElement(Wst + "RequestSecurityTokenResponse", new XElement(Wst + "TokenType", JwtValueType), new XElement(Wst + "RequestedSecurityToken", token)); if (expiresInSeconds is > 0) { var created = DateTimeOffset.UtcNow; response.Add(new XElement(Wst + "Lifetime", new XElement(Wsu + "Created", created.ToString("o")), new XElement(Wsu + "Expires", created.AddSeconds(expiresInSeconds.Value).ToString("o")))); } if (!string.IsNullOrEmpty(scope)) response.Add(new XElement(Wst + "Scope", scope)); return new XElement(Wst + "RequestSecurityTokenResponseCollection", response); } /// /// Builds the Validate answer. WS-Trust answers validation with a status code, not with the /// introspection document: a client asks «is this token good», and the verdict is the answer. /// public static XElement BuildStatusResponse(bool valid, string? reason = null) { var status = new XElement(Wst + "Status", new XElement(Wst + "Code", valid ? StatusValid : StatusInvalid)); if (!valid && !string.IsNullOrEmpty(reason)) status.Add(new XElement(Wst + "Reason", reason)); return new XElement(Wst + "RequestSecurityTokenResponse", new XElement(Wst + "TokenType", StatusTokenType), status); } /// /// Builds the Cancel answer. RFC 7009 makes a well-formed revocation always successful, and /// WS-Trust says so with an empty element rather than a payload. /// public static XElement BuildCancelResponse() => new(Wst + "RequestSecurityTokenResponse", new XElement(Wst + "RequestedTokenCancelled")); } Path: redb-identity/src/redb.Identity.Soap/Wsdl/identity-sts.wsdl 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.Soap/Wsdl/identity-sts.wsdl ---- Path: redb-identity/src/redb.Identity.Soap/WsdlDocument.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.Soap/WsdlDocument.cs ---- using System.Reflection; namespace redb.Identity.Soap; /// /// Locates the WSDL shipped alongside this assembly. /// /// The file is content, not an embedded resource, on purpose: an operator can read it, and a client /// developer can hand it to a generator, without the service running. The consumer rewrites the /// soap:address to the caller's own URL when it serves the document, so a copy fetched from a /// live endpoint always points back at that endpoint. /// /// internal static class WsdlDocument { /// File name as shipped, next to the assembly and inside the .tpkg. public const string FileName = "identity-sts.wsdl"; /// Directory the file is copied into. public const string Directory = "Wsdl"; /// /// The WSDL itself, as XML. /// /// The embedded copy is read first, and in a Tsak worker it is the only one that exists: a module's /// assembly is loaded straight from its .tpkg with LoadFromStream, so it never lands /// on disk and is empty. Resolving a path next to the assembly /// therefore found nothing in production while working perfectly in every test, and the facade /// answered 405 to the GET that a client generator makes first. /// /// /// The file beside the assembly is still read when it is there, which covers a plain file /// deployment and anyone who replaced the contract without rebuilding. /// /// /// A missing document is not a reason to refuse service: the four operations answer exactly the /// same either way, so the consumer serves 404 for the document and keeps taking requests. /// /// public static string? ReadContent() { var assembly = Assembly.GetExecutingAssembly(); var resourceName = Array.Find( assembly.GetManifestResourceNames(), n => n.EndsWith(FileName, StringComparison.OrdinalIgnoreCase)); if (resourceName is not null) { using var stream = assembly.GetManifestResourceStream(resourceName); if (stream is not null) { using var reader = new StreamReader(stream); return reader.ReadToEnd(); } } var path = ResolvePath(); return path is null ? null : File.ReadAllText(path); } /// /// The path to the WSDL next to this assembly, when the assembly came from a file at all. Empty in /// a Tsak worker, for the reason given on . /// public static string? ResolvePath() { var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrEmpty(assemblyDir)) return null; var path = Path.Combine(assemblyDir, Directory, FileName); return File.Exists(path) ? path : null; } } Path: redb-identity/src/redb.Identity.Soap/redb.Identity.Soap.config.json 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.Soap/redb.Identity.Soap.config.json ---- { "//": [ "Tsak Layer 4 stub — module identity only.", "All business config lives in the EXTERNAL modules/context.json (Layer 3), alongside the .tpkg files.", "The WS-Trust facade reads IdentityTransport:Soap:* there; shared issuer and feature flags come from", "Identity:* — the same section Core, the HTTP facade and the gRPC facade read." ], "ContextName": "identity.soap", "AutoStart": true } Path: redb-identity/src/redb.Identity.Soap/redb.Identity.Soap.csproj 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.Soap/redb.Identity.Soap.csproj ---- redb.Identity.Soap redb.Identity.Soap WS-Trust facade for redb.Identity — Issue, Validate, Cancel and Renew over SOAP, on the same core routes as HTTP and gRPC. PreserveNewest PreserveNewest PreserveNewest