Security and auth flows
Authentication
- JWT bearer from the company identity provider (
Authentication__Schemes__Bearer__Authority). Outside Development and Testing the authority must be anhttpsURL (the service refuses to start otherwise) and only asymmetric signatures are accepted. Claims keep their token names (sub,azp,scp), not the WS-Federation URIs. - Each endpoint requires one scope (
tax:estimate,tax:write,tax:commit, ...).integrations:adminimplies all of them. The full table is on the API page. - Entity access: callers act only on the entities listed in their
entityclaims unless they holdentities:all.integrations:admindoes not grant entity access. - Demo key: the public demo accepts
X-Api-Key(Auth__DemoKey). The service refuses to start with a demo key unless the simulated tax engine is configured, so a demo key can never reach real AvaTax. The OpenAPI document only advertises the key where one is configured.
Who is the caller
Every piece of work runs as someone, and EntityGuard applies the same entity rules to all of them
(ADR 0009):
| Work | Caller | Recorded as | Entities |
|---|---|---|---|
| HTTP request | the token's client | azp / client_id / cid / appid / sub | entity claims or entities:all |
| Consumed message | the broker user that published it | bus:<user> | Messaging:Publishers:<user>:Entities (all, when no publishers are configured) |
| Scheduled job | the service | system:<job> | all |
| Anything else | nobody | unknown | none |
Message trust. With Messaging:Publishers configured, a message's publisher is its AMQP user_id property, which
RabbitMQ refuses unless it matches the connection's user. Give each publishing service its own broker user, allowed
to write only to its own exchanges, and have it set user_id on what it sends. A message from an unlisted user, without
user_id, or for an entity its publisher may not touch, goes to the _error queue. This service stamps its own broker
user on everything it sends; redeliveries carry the original publisher in a header that is trusted only on messages
from that user.
Audit
created_by/modified_byon entities, tax documents, mappings, parties, certificate requests and reconciliation issues: the caller, stamped as rows are saved.admin_audit: append-only, one row per commit, void, credit, entity change, mapping change, resolved discrepancy and cancelled certificate request, written in the same transaction as the change.provider_call_audit: every AvaTax and Bank of Canada call with its caller and entity, and a hash of the request, never the payload.
HTTP hardening
- Rate limits (fixed one-minute windows): per calling client on
/api(RateLimiting__PermitsPerMinute, default 1200) and per client IP for anything not signed in, failed sign-ins included (RateLimiting__AnonymousPermitsPerMinute, default 300).429carriesRetry-After. Health probes are not limited. - Behind a proxy set
Http__ForwardedHeaders=trueso the client IP and scheme come from the one proxy in front. - Headers:
X-Content-Type-Options: nosniff,X-Frame-Options: DENY,Referrer-Policy, HSTS outside Development, and a Content-Security-Policy:default-src 'none'on API responses, and on pages only their own files, inline scripts and styles, and the jsDelivr and Scalar font CDNs. An end-to-end test opens every page and fails on any CSP violation. - Limits: request bodies up to 4 MB (
Http__MaxRequestBodyBytes,413 payload_too_large), requests up to 60 s (Http__RequestTimeout), route values up to 100 characters, bounded lists (lines, regions, GL accounts). - CSV exports: text cells that a spreadsheet would run as a formula (
=,+,-,@) get a leading'. Amounts stay numbers. - Provider errors reach callers with a fixed title; the provider's message goes to the log.
- Docs:
Docs__Public=false(production Kubernetes) stops serving the handbook (runbook, SQL, schema), the .NET reference and the API reference; the OpenAPI document then needs a signed-in caller.
Data protection
- Customer and vendor data goes to Avalara only when the entity enables
partySync(gated on the NDA), and only code, name, address and email. - Logs never contain payloads.
- Secrets (database, AvaTax license key, broker password) come from Kubernetes Secrets or Render environment variables, never from the repository.
- The container runs as the image's non-root user.