Skip to content

Authentication Middleware

goldy4719 edited this page Apr 10, 2026 · 1 revision

Overview

Validates incoming requests using JWT claims and attaches the user ID to the Lambda context.

Prerequisites

  • API Gateway JWT authorizer configured
  • JWT must include a sub claim

Implementation / Steps

  1. Extract authorizer data from the request context.
  2. Retrieve JWT claims.
  3. Extract the sub field as the user ID.
  4. Attach the user ID to the Lambda context.
  5. Continue request processing.

Key Takeaways

  • Supports multiple API Gateway authorizer formats.
  • Fails immediately if authentication data is missing.
  • Centralizes user identity handling.

Clone this wiki locally