auth-yes/Custom IAM Architecture Analysis.md

44 KiB

Architectural Blueprint and Hardening Analysis of a Decoupled, Zero-Trust Identity Provider Utilizing Deno, Valkey, and WebAuthn

1. The Paradigm Shift in Enterprise Identity Architectures

Historically, enterprise Identity and Access Management (IAM) has been dominated by massive, monolithic platforms designed to broker trust across disparate networks via heavy, standardized protocols. Solutions such as Keycloak, Authentik, and Okta rely primarily on OpenID Connect (OIDC), OAuth2 redirection flows, and stateless JSON Web Tokens (JWTs) to authenticate users and authorize applications1. While these frameworks provide broad interoperability, they impose immense configuration friction on software engineering teams. Integrating a new internal application typically requires registering client secrets, defining redirect URIs, configuring complex scopes, and implementing OAuth2 authorization code flows—a barrier to rapid iteration.
Simultaneously, global industry leaders have increasingly adopted Zero Trust security architectures, heavily influenced by frameworks like Google's BeyondCorp and Cloudflare Access, which assert that network locality is no longer a proxy for trust2. In these advanced models, every request must be cryptographically authenticated, authorized, and continuously validated, regardless of whether the traffic originates from the public internet or an internal Docker network.
The proposed custom Identity Provider (IdP) architecture represents a radical, highly efficient departure from traditional monolithic IdP patterns. By utilizing a centralized Deno-based API Gateway, a PostgreSQL identity store, and a high-throughput Valkey session cache, this system aims to deliver frictionless, zero-trust authentication tailored specifically for a high-velocity application ecosystem. The architecture explicitly rejects standard OIDC redirect flows and stateless JWTs. Instead, it relies on a logic-pure Deno Software Development Kit (SDK) imported directly by subsidiary applications, which validates stateful session tokens via internal network routes. Furthermore, the system mandates WebAuthn (passkeys) backed by strict hardware attestation, mathematically eliminating shared secrets and rendering traditional credential stuffing and phishing attacks obsolete.
This exhaustive analysis evaluates the proposed architecture against modern enterprise IAM standards, exploring the operational workflows, cryptographic validation mechanisms, inherent network vulnerabilities, and the advanced architectural hardening required to elevate this system into an infinitely scalable enterprise identity fabric.

2. Core Architectural Components and Perimeter Isolation

The structural foundation of the proposed IdP relies on a strict separation of concerns, decoupling the permanent identity data store from the subsidiary business applications while maintaining centralized, authoritative control over session states.

2.1. The API Gateway (Auth Hub)

The API Gateway functions as the singular authority for all cryptographic verifications, WebAuthn challenge generation, and central database transactions. Operating as an isolated microservice, it exposes REST and gRPC endpoints exclusively to the internal Docker network. By encapsulating all identity logic within this central service, subsidiary applications are entirely relieved of the burden of cryptographic parsing, database connection pooling, and credential lifecycle management. This establishes a robust zero-trust boundary; if a subsidiary application is compromised via remote code execution (RCE), the attacker cannot directly query the central PostgreSQL database or extract public key materials2.

2.2. The Deno Shared App SDK

Instead of forcing each new application to implement complex OIDC redirect callbacks, developers import a lightweight, logic-pure Deno client library. This SDK operates as middleware—often implemented via the "onion model" in frameworks like Oak or Fresh—intercepting incoming HTTP requests to the subsidiary app, extracting the session token, and transmitting it via a secure internal route to the Auth API4.
Because Deno is secure by default, the execution of this SDK operates within a strict permissions sandbox. Network access must be explicitly granted via flags such as --allow-net, meaning the SDK is structurally constrained and prevented from leaking session tokens to unauthorized external endpoints, even in the event of a supply chain compromise7. This drop-in SDK model virtually eliminates the barrier to implementation for new applications, allowing developers to secure endpoints with minimal configuration overhead9.

2.3. PostgreSQL Central Identity Store

Permanent identity storage, application metadata, and public passkey coordinates are maintained in a central PostgreSQL relational database. This schema design guarantees a unified user identity—represented universally by a central UUID—across the entire application ecosystem. Subsidiary applications maintain completely independent PostgreSQL databases mapped strictly to this UUID, preventing schema contamination and data bleeding. This localized mapping is highly advantageous; if a subsidiary application requires specialized user profile fields (e.g., localized user preferences or game states), it handles that mapping internally without requiring schema alterations to the central IdP11.

2.4. Valkey Session Cache and In-Memory Statefulness

The most critical architectural divergence from modern microservice standards is the reliance on Valkey—an open-source, high-performance key-value store based on Redis—for session state validation13. When a user successfully authenticates via WebAuthn, the Auth API issues an opaque session token and stores the corresponding active state in Valkey. Every subsequent request made to a subsidiary application forces the App SDK to validate this token against Valkey via the Auth API. This ensures microsecond-level stateful validation, combining the speed of in-memory caching with the security of instantaneous session revocation13.

Table 1: Core System Component Topology

Component Technology Stack Primary Function Security Posture
Auth API Gateway Deno (REST/gRPC) Cryptographic challenge generation, database writes, cache management. Isolated on internal network; sole component with central DB credentials.
App SDK Deno (TypeScript) Request interception, cookie extraction, RPC routing to Auth API. Sandboxed via Deno CLI flags (--allow-net=auth-api.internal).
Central Database PostgreSQL Persistent storage of UUIDs, public passkeys, audit logs, and RBAC tables. Protected behind the Auth API; rejects direct connections from subsidiary apps.
Session Cache Valkey Microsecond validation of opaque stateful session tokens. In-memory only; cleared upon manual revocation or automated TTL expiry.

3. Operational Use Case Flows and Identity Lifecycle

The provided operational flows illustrate a highly modular and automated identity lifecycle, demonstrating how the system handles user provisioning, credential administration, and session telemetry.

3.1. Provisioning, Invites, and the Authorization Coupling

The onboarding flows (Use Cases 1, 2, and 3) highlight the system's flexibility in managing user entry. In an open account application (Use Case 1), the App SDK requests a WebAuthn challenge, the device generates a unique key pair, and the Auth API creates a UUID, registering the public key and issuing a session.
More sophisticated is Use Case 2, which allows users to bypass legacy email verification via cryptographically secure signup tokens. When a user submits an invite code, the API provisions the UUID and instantly inserts an authorization record into the RBAC tables. This tightly couples authentication (verifying who the user is) with authorization (verifying what the user can do). Because an authenticated identity does not automatically inherit authorization for all networked applications, the system maintains the principle of least privilege. Furthermore, Use Case 3 introduces a manual state machine; the database can enforce a default "pending" status upon passkey creation, requiring an administrator to access the central Auth UI and manually toggle the user to "active" before a session token can be issued.

3.2. Credential Redundancy and Strict Account Recovery

Because the system strictly relies on WebAuthn and mathematically rejects shared secrets, traditional password resets are impossible. If an authenticator is lost, the user risks permanent account lockout. The architecture addresses this through redundancy and strict administrative oversight.
Use Case 4 highly recommends enrolling multiple passkeys (e.g., a platform authenticator like a MacBook TouchID and a roaming authenticator like a YubiKey). When a user with an active session initiates a "Register Device" action, a new challenge is issued and bound to the existing UUID. If a passkey is compromised or lost, Use Case 6 dictates that the user or administrator can select the device nickname for removal. The Auth API executes a SQL DELETE operation, wiping the public key and credential ID from PostgreSQL, permanently invalidating the authenticator.
If all devices are lost (Use Case 12), the architecture mandates strict out-of-band administrative intervention. Without static recovery codes, an administrator must manually execute a database override via the Auth UI to bind a newly generated WebAuthn challenge to the existing user UUID, ensuring that social engineering attacks against automated recovery flows are neutralized.

3.3. Multi-Tenant Accounts and Localized Data Mapping

Use Case 5 demonstrates the system's capability to support multi-tenant or multi-persona configurations. The system validates uniqueness based on the username string, not human identity. If a user registers an alternate username, the system triggers a new WebAuthn challenge, resulting in a completely distinct UUID and an independent passkey record. This segregation prevents privilege escalation bleed, allowing a single human employee to maintain a highly privileged "Admin" UUID and a restricted "Standard" UUID, fully separated at the database level.
Similarly, Use Case 8 outlines the handling of user profile metadata. A display_name exists centrally in the Auth database, modifiable via an Auth API PATCH endpoint. However, if a subsidiary application requires localized usernames or domain-specific avatars, it maintains a distinct column in its own localized PostgreSQL database, mapped back to the central UUID. This enforces the decoupled nature of the architecture11.

3.4. Infrastructure Topologies and Telemetry

The entire environment is orchestrated via Docker Compose (Use Case 9), running the Valkey, PostgreSQL, Auth API, and Auth UI services. Crucially, Use Case 10 specifies that all containers share an isolated internal Docker network. Subsidiary applications deployed on the same server environment attach to this internal network, allowing the App SDK to resolve the internal endpoint (auth-api.internal:8000) without exposing the Auth API ports to the public internet.
To maintain security telemetry, Use Case 7 details the session review architecture. The App SDK can query the Auth API for records associated with a user's UUID. The API aggregates active session tokens directly from the Valkey cache alongside historical connection logs (timestamps and IP addresses) stored in the PostgreSQL audit tables, providing the user with a comprehensive, formatted list of account activity for proactive security monitoring.

4. Comparative Analysis: Decoupled API-Backed Sessions vs. Monolithic/Stateless Paradigms

To objectively evaluate the efficacy of the proposed SDK-to-API and Valkey architecture, it must be contrasted against the industry-standard deployments of monolithic IAM solutions and stateless JWT implementations.

4.1. The Friction of Monolithic IAMs (Keycloak, Authentik, Okta)

Standard enterprise solutions are immensely feature-rich but notoriously complex1. They require the extensive configuration of realms, client IDs, audiences, scopes, and OIDC mappers. Furthermore, integrating a new application requires application developers to build or import complex OAuth2 middleware to handle authorization code flows, token exchanges, and callback URIs.
The proposed decoupled architecture bypasses this friction entirely. By utilizing an internal App SDK that communicates directly with the Auth API over internal gRPC/REST routes, the system eliminates browser redirects. The authentication flow is hyper-streamlined: the user authenticates directly via the central UI, and the resulting opaque session cookie is automatically transmitted with subsequent requests and processed by the SDK. This drastically reduces the cognitive load on subsidiary application developers, who simply wrap their routes in the Deno SDK middleware4.

4.2. Stateful Valkey Sessions vs. Stateless JWT OIDC

Modern microservices heavily favor stateless authentication via JSON Web Tokens (JWTs) because they scale infinitely. Since the JWT contains all necessary user claims, scopes, and expiration data, and is cryptographically signed by the IdP's private key, the receiving subsidiary application can validate the token locally without querying a central server6.
However, stateless JWTs suffer from two fatal operational flaws: token bloat and the inability to be revoked instantly. As RBAC roles and granular claims are added to a user's profile, the JWT payload increases, degrading HTTP request performance16. More critically, if a user's device is compromised, a valid JWT remains active until its expiration timestamp17. To mitigate this, standard implementations are forced to introduce "blacklists" or centralized revocation caches, which ironically destroys the stateless nature of the JWT and reintroduces stateful architectural complexity17.
The proposed architecture embraces statefulness via Valkey. Because every request is validated against the central cache by the SDK, an administrator can revoke a compromised session, and that revocation propagates globally in microseconds17. While stateful microservices typically suffer from scalability bottlenecks and require complex load-balancing configurations like "sticky sessions," the utilization of an external, high-throughput Valkey cache decouples the session state from the application instances18. This allows the Auth API to scale horizontally behind a load balancer; any Auth API instance can query Valkey to validate the opaque token, ensuring high fault tolerance18.

Table 2: Authentication Architecture Comparison

Feature Category Monolithic IAM (OIDC / OAuth2) Stateless JWT Microservices Proposed Deno + Valkey IdP
Integration Friction High (Requires redirect URIs, client scopes, token exchange logic). Medium (Requires local JWT library, public key distribution). Low (Import pure-logic Deno SDK, provide Application Secret).
Session Revocation Delayed (Relies on short-lived access tokens and refresh flows). Impossible / Highly Complex (Requires distributed blacklist caches). Instantaneous (Microsecond deletion from Valkey cache).
Token Payload Size Large (Bloated with claims, roles, and audience data). Large (Prone to header/payload token bloat). Minimal (Opaque string representing a key in Valkey).
Scalability Limiters Database read bottlenecks during token generation/refresh. Cryptographic CPU overhead for constant local signature verification. Network I/O latency between subsidiary SDK and Central Auth API.
Phishing Resistance Optional (Can support FIDO2, but often falls back to passwords). N/A (JWTs are post-authentication artifacts). Enforced (Strict hardware-bound WebAuthn requirements).

5. Deep Dive: Cryptographic Security and Advanced WebAuthn Mechanics

The proposed architecture achieves a zero-trust posture not merely through internal network isolation, but by strictly enforcing modern cryptographic authentication standards. By completely excising passwords and SMS-based multi-factor authentication, the system immunizes itself against the vast majority of identity-based attacks.

5.1. Phishing Resistance and Asymmetric Cryptography

Traditional authentication relies on shared secrets. If an attacker breaches a server, hashed secrets can be cracked offline. If an attacker hosts a replica phishing website, the user unwittingly transmits the secret. The proposed architecture eliminates this via WebAuthn passkeys19.
During registration, the user's authenticator device (e.g., a YubiKey or a TPM module) generates an asymmetric key pair using an elliptic curve algorithm (e.g., ES256). The private key never leaves the secure hardware boundary of the device. The Auth API receives and stores only the public key. During authentication, the API issues a random cryptographic challenge, and the device signs this challenge using the private key20. Because there is no secret transmitted over the wire, credential stuffing, password spraying, and database leak exploitation are mathematically impossible20.

5.2. Cryptographic Origin Binding and Cross-Domain Passkeys

Passkeys are structurally bound to the Relying Party ID (the domain string). If a user registers a passkey on auth.internal.corp, the browser will cryptographically refuse to assert that passkey on a lookalike phishing site like auth-internal.corp19. The signature changes with the origin, ensuring the credential cannot be hijacked.
However, enterprise architectures frequently utilize multiple domains and subdomains. A company with app1.corp and app2.corp ideally wants a single passkey to authenticate across both, without requiring the user to register a new credential for every subsidiary application. Under the original WebAuthn specification, this was impossible19.
To solve this, the architecture must implement **Related Origin Requests (ROR)**21. ROR allows a Relying Party to specify a list of authorized origins that can utilize its passkeys21. The Auth API must host a JSON document at the WebAuthn well-known path (/.well-known/webauthn) on the primary domain21.
For example, if the central IDP is auth.corp, the document hosted at https://auth.corp/.well-known/webauthn would contain:

JSON
{
"origins": [
"https://app1.corp",
"https://app2.corp"
]
}

During a WebAuthn ceremony on app1.corp, if the Relying Party ID is declared as auth.corp, the browser will query the central well-known URL. The browser processes the origin list and re-evaluates the binding, permitting the passkey assertion to proceed21. The App SDK facilitates this parameter negotiation, ensuring a seamless Single Sign-On (SSO) experience across the enterprise ecosystem without breaking strict cryptographic origin binding21.

5.3. Hardware Attestation Strictness and FIDO MDS3 Verification

A pivotal feature of this architecture is the configuration toggle to forcefully reject software-based passkeys (e.g., Bitwarden, iCloud Keychain, Windows Hello) in favor of certified hardware credentials (e.g., YubiKey 5 Series). Software passkeys can be copied, synced across devices, and exfiltrated, breaking the non-repudiation guarantees required by high-security environments24. Restricting authentication to device-bound hardware is achieved through Authenticator Attestation25.
During the WebAuthn registration ceremony, an authenticator can provide an attestation statement containing an Authenticator Attestation GUID (AAGUID). The AAGUID is a 128-bit UUID (e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) that uniquely designates the specific hardware model, manufacturer, and firmware version26. Furthermore, the attestation object includes an x5c certificate chain generated by an intermediate certificate authority (CA) and imported by the manufacturer during production25.
To enforce strict hardware compliance, the Auth API Gateway must integrate deeply with the **FIDO Alliance Metadata Service (MDS3)**29. The MDS3 BLOB is a cryptographically signed JSON web token (JWT) containing a catalog of trusted AAGUIDs, biometric status reports, and their corresponding root certificates29.
The API Gateway must perform the following cryptographic sequence during user onboarding:

  1. Extract the AAGUID: Parse the CBOR-encoded attestationObject from the user's registration payload to extract the 16-byte AAGUID26.
  2. Verify the MDS3 BLOB Signature: Ensure the locally cached FIDO MDS3 BLOB has a valid signature chaining to the FIDO root trust anchor29.
  3. Build the Certificate Chain: Extract the x5c leaf certificate from the user's attestation response, append the intermediate certificates, and terminate the chain at the specific root certificate mapped to the AAGUID inside the MDS3 BLOB33.
  4. Check Revocation: Verify that the AAGUID is not listed in the statusReports as compromised, revoked, or possessing outdated firmware31.

If the device self-attests (as software passkeys do, providing no x5c chain), if the signature fails to verify, or if the AAGUID is not present on the enterprise allow-list, the API immediately aborts the registration and returns a 403 Forbidden24.

Table 3: Hardware Attestation Cryptographic Verification Flow

Component Cryptographic Function Security Implication
AAGUID 128-bit identifier embedded in the WebAuthn authData. Probability of collision is . Maps the credential to a specific hardware model, allowing policies to block unapproved or vulnerable devices26.
x5c Chain Digital certificate chain appended to the attestation object during registration. Proves the provenance of the hardware; mathematically prevents attackers from spoofing AAGUIDs using custom software authenticators25.
FIDO MDS3 BLOB Signed repository of trusted authenticator metadata statements published by the FIDO Alliance. Provides the trust anchors (Root CAs) required to cryptographically validate the x5c chain during user onboarding29.

6. Vulnerability Assessment and Scaling Limitations

While the architecture brilliantly resolves the severe flaws of monolithic IAMs and stateless JWTs, funneling hundreds of internal applications through a central API utilizing stateful session validation introduces unique attack vectors and structural vulnerabilities that must be addressed.

6.1. Network Bottlenecks and Chatty Architecture Latency

The most critical structural vulnerability of this system is network latency induced by a "chatty" architecture. If 100 subsidiary applications each receive 1,000 HTTP requests per second, the App SDK must fire 100,000 synchronous internal API requests per second to the API Gateway to validate the stateful session cookies18. Even though the Valkey database operates in microseconds, the sheer volume of TCP connection handshakes, HTTP overhead, and payload parsing traversing the internal Docker network will eventually saturate the network interface, resulting in cascading timeout failures18. Without mitigation, this creates a massive internal distributed denial-of-service (DDoS) risk under normal high-load operating conditions.

6.2. Internal Network Sniffing and Lateral Movement

The documentation outlines that all containers share an isolated internal Docker network, effectively creating a perimeter (Use Case 10). While this prevents ingress from the public internet, it relies on a perimeter defense model, assuming a zero-trust fallacy inside the network. If a single subsidiary application is compromised via a vulnerability, the attacker gains a foothold inside the Docker network. If the SDK-to-API communication occurs over unencrypted HTTP, the attacker can use packet sniffing tools (e.g., tcpdump) to intercept active, stateful session cookies traversing the network. Because the cookies are opaque bearer tokens, the attacker can replay them to impersonate administrators across other internal applications, enabling devastating lateral movement.

6.3. Cache Exhaustion and Valkey Denial of Service (DoS)

Valkey, functioning as an in-memory datastore, is fundamentally constrained by available RAM13. If an attacker discovers an unprotected endpoint on a subsidiary application that generates a new session token (e.g., rapidly calling the login or invite provision endpoint), they can flood the Auth API with fraudulent authentication requests. The API will continually write new session records into Valkey. Once the host machine's RAM is exhausted, Valkey will crash or begin aggressively evicting active user sessions, leading to an Out-Of-Memory (OOM) failure and a system-wide catastrophic outage for all authenticated users.

6.4. SDK Subversion and Supply Chain Risks

Because the SDK is distributed to subsidiary applications, a malicious developer or a compromised third-party dependency in a subsidiary app could theoretically subvert the SDK's execution environment. In a standard Node.js environment, third-party dependencies have unfettered access to the file system, network, and environment variables. If a malicious NPM package is imported alongside the SDK, it could extract the Application Secret used to authenticate the SDK to the API, allowing the attacker to spoof validation requests or exfiltrate session data to an external server.

7. Architectural Improvements and Enterprise Hardening

To transform this system into a highly resilient, enterprise-grade IAM fabric capable of rivaling global tech leaders, specific architectural mechanisms must be implemented to harden the network and mitigate the identified vulnerabilities.

7.1. Valkey Client-Side Caching with RESP3 Invalidation

To solve the "chatty architecture" bottleneck, the system must abandon the paradigm of querying the central Auth API on every single HTTP request. Instead, the Auth API and the Deno SDK should implement Valkey Client-Side Caching utilizing the RESP3 protocol and Pub/Sub mechanics14.
When the Deno App SDK requests session validation from the API Gateway, the SDK should cache the valid result (including RBAC scopes) in its local, in-memory heap for a short duration15. Simultaneously, the Auth API utilizes Valkey's CLIENT TRACKING feature with the OPTIN configuration15. If an administrator revokes a user's session, the Auth API deletes the key in Valkey. Valkey immediately broadcasts an invalidation message over a Pub/Sub channel to the Auth API14. The API Gateway then pushes a gRPC stream update to the connected App SDKs, instructing them to instantly drop the specific local cache entry14.
This architecture yields a monumental performance gain: 99% of requests are validated in nanoseconds locally within the SDK (rivaling the speed of stateless JWTs), while preserving the instantaneous, microsecond-revocation capability of a centralized stateful system.

7.2. gRPC with HTTP/2 Multiplexing

The SDK-to-API communication must strictly enforce the use of gRPC rather than REST. REST relies on HTTP/1.1, which traditionally requires establishing a new TCP connection for requests or dealing with head-of-line blocking. gRPC utilizes HTTP/2, which supports multiplexing—allowing hundreds of concurrent session validation requests to be streamed asynchronously over a single persistent TCP connection35. Furthermore, gRPC uses Protocol Buffers (Protobuf) for binary serialization, drastically reducing the payload size compared to standard JSON text transmission35. This will effectively eliminate the internal network congestion caused by high-throughput subsidiary applications.

7.3. Strict Deno Sandboxing and Execution Constraints

The decision to utilize Deno provides a massive security advantage over Node.js, provided its security sandbox is strictly enforced. The subsidiary applications running the SDK must never be executed with the -A or --allow-all flag, which completely disables the sandbox7.
The execution environment must be tightly constrained using granular CLI flags:

  • --allow-net=auth-api.internal:8000: This explicitly restricts the SDK to only communicate with the central Auth API8. Even if the application is compromised by malware, the malware cannot exfiltrate the Application Secret or session tokens to an external command-and-control server, because the Deno runtime will intercept and block the outbound connection at the system level38.
  • --deny-read and --deny-env: These flags explicitly restrict file system and environment access. By denying access to /etc/ or .env files, the system ensures that only explicitly defined variables (like the SDK configuration) can be loaded into memory, neutralizing supply chain attacks attempting to scrape disk credentials39.
  • --allow-ffi: Must be strictly avoided or heavily audited, as loading dynamic C/C++ libraries bypasses the JavaScript sandbox entirely, allowing native code to issue system calls directly to the OS7.
Deno CLI Flag Operational Purpose Threat Mitigation
--allow-net=auth-api.internal Permits communication exclusively to the Auth API gateway39. Prevents malware from exfiltrating session tokens to public internet endpoints8.
--deny-read=/app/secrets Blocks read access to specific directories or files7. Prevents third-party dependencies from scraping disk for application configuration secrets.
--allow-env=AUTH_URL Restricts access to a whitelist of required environment variables37. Blocks malware from dumping the entire environment tree containing DB passwords or API keys.
--allow-all / -A Strictly Prohibited. Disables the sandbox entirely7. Ensures the runtime retains its security advantages over traditional Node.js environments8.

7.4. Internal mTLS via SPIFFE/SPIRE for Zero-Trust Networking

To neutralize the threat of internal network sniffing and lateral movement, Docker network isolation is insufficient. The architecture must implement mutual Transport Layer Security (mTLS) for all communications between the Deno SDK and the API Gateway3.
By deploying a framework like SPIFFE/SPIRE, localized cryptographic certificates are distributed to the subsidiary containers. When the SDK initiates a gRPC connection, the API Gateway cryptographically verifies the identity of the calling application before processing the request, and the traffic is heavily encrypted3. This achieves true zero-trust; an attacker sitting on the internal Docker network capturing packets will only intercept unintelligible ciphertext, rendering session hijacking and API spoofing impossible.

7.5. Network Rate Limiting and Edge Protection

To prevent Valkey cache exhaustion and Out-Of-Memory failures, the Auth API must implement rigorous, multi-layered rate limiting. Valkey itself should be utilized to track authentication attempts and issue exponential backoffs13. Rate limits must be applied dynamically at the IP level, the user UUID level, and the App SDK level. By establishing a maximum threshold of session generation requests per minute, the system mathematically bounds the maximum RAM footprint that can be consumed in a given window, protecting the in-memory cache from intentional exhaustion.

8. Conclusion

The proposed decoupled Identity Provider architecture represents a highly sophisticated, developer-friendly approach to enterprise authentication. By fundamentally rejecting the legacy complexities of OpenID Connect and the critical security flaws of stateless JWTs, the system achieves a rare equilibrium between high usability and stringent security. The strict enforcement of WebAuthn and AAGUID hardware attestation ensures a cryptographically pristine, phishing-proof boundary against external threats, mathematically eliminating the vulnerabilities associated with shared secrets.
However, the architectural transition to a centralized, stateful session model shifts the burden of performance directly onto the internal network and the Valkey cache. To realize the ambitious goal of an authentication system that scales beyond current industry gold standards with a fraction of the complexity, the architecture must implement advanced network optimizations. By adopting Valkey RESP3 client-side caching to eliminate repetitive network I/O, enforcing gRPC multiplexing for high-throughput communication, deploying strict Deno runtime permissions to neutralize supply chain attacks, and blanketing the internal network in mTLS, this architecture will transcend its theoretical potential. It will yield a system that offers the infinite horizontal scalability of a stateless architecture, the instantaneous revocation capabilities of a stateful monolith, and an impenetrable zero-trust security posture.

Works cited

  1. Authentik vs Keycloak: where identity providers stop short, https://nhimg.org/community/nhi-best-practices/authentik-vs-keycloak-where-identity-providers-stop-short/
  2. Zero Trust Security | What's a Zero Trust Network? - Cloudflare, https://www.cloudflare.com/learning/security/glossary/what-is-zero-trust/
  3. Modernizing Database Authentication: CockroachDB Embraces Zero Trust with SPIFFE and SPIRE Support, https://www.cockroachlabs.com/blog/zero-trust-database-authentication-spiffe-spire/
  4. How to Implement Middleware in Deno - OneUptime, https://oneuptime.com/blog/post/2026-01-31-deno-middleware/view
  5. How to Setup Auth with Fresh | Deno, https://deno.com/blog/setup-auth-with-fresh
  6. How to Implement JWT Authentication for CRUD APIs in Deno - LoginRadius, https://www.loginradius.com/blog/engineering/guest-post/how-to-implement-jwt-authentication-in-deno
  7. Security and permissions | Deno Docs, https://docs.deno.com/runtime/fundamentals/security/
  8. How Deno protects against npm exploits, https://deno.com/blog/deno-protects-npm-exploits
  9. Custom Oak middleware in Deno | Tech Tonic - Medium, https://medium.com/deno-the-complete-reference/custom-oak-middleware-in-deno-8b2b3289b40e
  10. How to Implement JWT Authentication in Deno - OneUptime, https://oneuptime.com/blog/post/2026-01-31-deno-jwt-authentication/view
  11. Stateless vs. Stateful Architecture: A Comprehensive Comparison | AutoMQ Blog, https://www.automq.com/blog/stateless-vs-stateful-architecture-a-comprehensive-comparison
  12. Securing Web Applications: Stateful vs. Stateless Systems, Authentication, and Authorization in Node.js - DEV Community, https://dev.to/imsushant12/securing-web-applications-stateful-vs-stateless-systems-authentication-and-authorization-in-nodejs-b1m
  13. From caching to real-time analytics: Essential use cases for Amazon ElastiCache for Valkey, https://aws.amazon.com/blogs/database/from-caching-to-real-time-analytics-essential-use-cases-for-amazon-elasticache-for-valkey/
  14. Spring Boot Caching With Valkey or Redis: A Complete @Cacheable Guide, https://redisson.pro/blog/spring-boot-caching-with-valkey-redis-a-complete-cacheable-guide.html
  15. Documentation: Client-side caching - Valkey, https://valkey.io/topics/client-side-caching/
  16. Stateless Authentication: Understanding Token-Based Auth - Descope, https://www.descope.com/learn/post/stateless-authentication
  17. Stateful vs Stateless Authentication Explained Clearly - Medium, https://medium.com/@captain-uchiha/stateful-vs-stateless-authentication-explained-clearly-7c9fd647c3a7
  18. Stateful vs. stateless architecture for scalable systems explained - Aerospike, https://aerospike.com/blog/stateful-vs-stateless-architecture-guide/
  19. Cryptographic origin binding: How passkeys make phishing structurally impossible, https://workos.com/blog/cryptographic-origin-binding
  20. Web Authentication API - MDN Web Docs - Mozilla, https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API
  21. Related Origin Requests - passkeys.dev, https://passkeys.dev/docs/advanced/related-origins/
  22. Allow passkey reuse across your sites with Related Origin Requests - web.dev, https://web.dev/articles/webauthn-related-origin-requests
  23. Deep Dive: Relying Party ID & origin (Passkeys) - Duende Software, https://duendesoftware.com/blog/20251014-deep-dive-into-relying-party-id-and-origin-with-passkeys
  24. FIDO Metadata Service - Identity Provider Plugins - Confluence, https://shibboleth.atlassian.net/wiki/spaces/IDPPLUGINS/pages/3878944780
  25. WebAuthn Attestation: How a Site Knows What Made Your Passkey | Haven Blog, https://havenmessenger.com/blog/posts/webauthn-fido2-attestation-explained/
  26. AAGUID (Authenticator Attestation GUID) | Definition - CardLogix, https://www.cardlogix.com/glossary/aaguid-authenticator-attestation-guid-fido2-passkey-webauthn/
  27. FIDO Metadata Statement, https://fidoalliance.org/specs/mds/fido-metadata-statement-v3.1-ps-20250521.html
  28. WebAuthn Attestation and Authenticator Metadata - Yubico Developers, https://developers.yubico.com/Developer_Program/WebAuthn_Starter_Kit/Attestation.html
  29. FIDO Metadata Service, http://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html
  30. FIDO Metadata Service (MDS) Overview - FIDO Alliance, https://fidoalliance.org/metadata/
  31. FIDO Metadata Service, https://fidoalliance.org/specs/mds/fido-metadata-service-v3.1-ps-20250521.html
  32. FIDO Metadata Service (MDS) - Yubico Developers, https://developers.yubico.com/WebAuthn/Concepts/FIDO_Metadata_Service_(MDS).html
  33. WebAuthn/FIDO2: Verifying TPM Attestation | by Ackermann Yuriy - Medium, https://medium.com/webauthnworks/verifying-fido-tpm2-0-attestation-fc7243847498
  34. Web Authentication: An API for accessing Public Key Credentials - Level 2 - W3C, https://www.w3.org/TR/webauthn-2/
  35. gRPC vs. REST - Postman Blog, https://blog.postman.com/grpc-vs-rest/
  36. CLIENT CACHING - Valkey Command, https://valkey.io/commands/client-caching/
  37. Deno allow all permissions - Stack Overflow, https://stackoverflow.com/questions/61878523/deno-allow-all-permissions
  38. How can I enforce a security sandbox with any process?, https://security.stackexchange.com/questions/257801/how-can-i-enforce-a-security-sandbox-with-any-process
  39. Permissions - Deno Docs, https://docs.deno.com/runtime/reference/permissions/
  40. Introducing Deno Sandbox, https://deno.com/blog/introducing-deno-sandbox
  41. Deno's Networking and File Permissions Model | Reflect, https://reflect.run/articles/deno-networking-and-file-permissions-model/