Skip to content

Add GET /whoami route and pass token in authorizer context - #17

Open
localstack-platform[bot] wants to merge 2 commits into
mainfrom
localstack/build-bld_66f0729924c523d9
Open

localstack-platform[bot] wants to merge 2 commits into
mainfrom
localstack/build-bld_66f0729924c523d9

Conversation

@localstack-platform

@localstack-platform localstack-platform Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Add a GET /whoami route to the API Gateway SAM template and handler returning the caller's principalId. Update the Lambda authorizer to include the token name in its returned context object, and add assertions in test.sh for /whoami.

What changed

  • template.yaml
  • src/handler.js
  • src/authorizer.js
  • test.sh

Tests

  • Run test.sh to verify GET /whoami returns status 200 and principalId 'user' when invoked with the 'allow' token.

Not verified here

  • Whether LocalStack API Gateway correctly propagates authorizer context to the /whoami handler on deployment
  • Whether test.sh succeeds against the local test stack
  • The project has no platform CI workflow on its default branch, so no CI run checks this PR.

Drift noticed

None noticed.

Needs a human

None.

Turn 2: Remove duplicate token key from authorizer context

Plan approved by harsh · google/gemini-3.5-flash · commit 9948e7c

What changed

  • src/authorizer.js

Tests

None requested.

Not verified here

  • Whether the API Gateway authorizer context returned in event.requestContext.authorizer correctly contains only tokenName without token when deployed.

Drift noticed

None noticed.

Needs a human

None.


Built by LocalStack Build from a plan approved by harsh · session · turn 1 · google/gemini-3.5-flash

localstack-platform Bot and others added 2 commits October 27, 2026 19:53
Added a GET /whoami route to the SAM template and a whoami handler in src/handler.js returning principalId. Updated the authorizer in src/authorizer.js to include token details in context, and added assertions in test.sh for /whoami.

Co-authored-by: harsh <harsh@localstack.cloud>
Removed the duplicate token property from authResponse.context in src/authorizer.js, retaining only the tokenName key in the authorizer context.

Co-authored-by: harsh <harsh@localstack.cloud>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants