Skip to content

Implement authorizer override logic#1891

Merged
dherault merged 4 commits into
dherault:masterfrom
joshf:fix-authorizer-env
Jun 8, 2026
Merged

Implement authorizer override logic#1891
dherault merged 4 commits into
dherault:masterfrom
joshf:fix-authorizer-env

Conversation

@joshf

@joshf joshf commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Add support for authorizer override in HttpServer

Description

Restores the use of an environment variable AUTHORIZER that was broken in v13

Based off the closed PR #1883

Motivation and Context

Fixes #1826

How Has This Been Tested?

Screenshots (if appropriate):

Add support for authorizer override in HttpServer
@joshf joshf temporarily deployed to fork-pr-tests June 5, 2026 13:09 — with GitHub Actions Inactive
@joshf joshf deployed to fork-pr-tests June 5, 2026 13:09 — with GitHub Actions Active
@joshf joshf temporarily deployed to fork-pr-tests June 5, 2026 13:09 — with GitHub Actions Inactive
@dherault dherault requested a review from Copilot June 7, 2026 03:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores support for authorizer override when running serverless-offline, ensuring that a provided mock authorizer context (via AUTHORIZER env var or the sls-offline-authorizer-override header) is preserved even when no authorizer is configured (e.g., with noAuth: true). This aligns behavior with pre-v13 releases and addresses the regression described in issue #1826.

Changes:

  • Prevent deletion of event.requestContext.authorizer when an override is provided via request header or AUTHORIZER env var.
  • Update integration test cleanup to properly remove AUTHORIZER from the environment between tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/integration/override-authorizer/override-authorizer.test.js Ensures AUTHORIZER is removed via delete after each test to avoid leaking env state.
src/events/http/HttpServer.js Adds authorizer override detection so the authorizer payload isn’t deleted when overrides are in use.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +617 to +618
const hasAuthorizerOverride =
request.headers["sls-offline-authorizer-override"] || env.AUTHORIZER
@dherault

dherault commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Thanks, great job, let's merge it!

@dherault dherault merged commit d285b78 into dherault:master Jun 8, 2026
3 checks passed
@joshf joshf deleted the fix-authorizer-env branch June 8, 2026 08:22
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.

Mocking Remote Authorizers broken since v13.x

3 participants