Totallytech.BranchAuth.AspNetCore 1.1.0
Totallytech.BranchAuth
Helpers for calling and receiving branch-scoped internal APIs through the token broker. Built for .NET 8 and .NET 10.
Totallytech.BranchAuth.Client:
IBranchTokenClient.GetAsync(companyId, branchId, scope)gets a short-lived access token from the broker. The service proves its identity with its own identity server client (BranchTokenClient:CallerAuth = ClientCredentials, secret from its secret store) or, on Kubernetes, with the pod's projected service account token (ServiceAccountToken). Tokens are cached in memory until about 60 seconds before they expire.BranchNotEntitledException: the branch does not have the service or scope. This is a normal case and is not retried.- Broker 503, 429 and network errors are retried with backoff.
Totallytech.BranchAuth.AspNetCore for receiving services:
- Already validating tokens from the identity server:
builder.Services.AddBranchTenantAuthorization()(adds only the scope policies andITenantContext). - No token validation yet:
builder.AddBranchApiAuth("rcm")(JWT bearer validation againstBranchApiAuth:Authoritywith the given audience, plus the above). - A policy for every scope name:
[Authorize(Policy = "rcm.claims.write")]or.RequireAuthorization("rcm.claims.write"). ITenantContextreads thecompanyIdandbranchIdclaims from the validated token only.
- Already validating tokens from the identity server:
Totallytech.BranchAuth.EntityFrameworkCore:
modelBuilder.ApplyBranchTenantFilters(this)adds a global query filter onCompanyIdandBranchIdto everyITenantScopedentity.Totallytech.BranchAuth.Diagnostics: step-by-step HTTP tracing, no ASP.NET Core dependency (console apps and workers too).
services.AddHttpTracing(configuration)logs every outgoing call of everyHttpClient; in a web serviceapp.UseHttpTracing()(Totallytech.BranchAuth.AspNetCore) logs every incoming request; with headers and bodies; secrets become[redacted]and tokens a fingerprint plus their claims. Off unlessHttpTrace:Enabledis true.
See the token-broker repository README for configuration.
No packages depend on Totallytech.BranchAuth.AspNetCore.
.NET 10.0
- Totallytech.BranchAuth.Diagnostics (>= 1.1.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.15)
.NET 8.0
- Totallytech.BranchAuth.Diagnostics (>= 1.1.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.12)