Skip to content

bug: affiliate settle route allows requests when CRON_SECRET is unset #156

@morganschp

Description

@morganschp

Bug description

POST /api/affiliates/settle is documented as protected by CRON_SECRET, but the guard only rejects when CRON_SECRET is set and the bearer token does not match. If CRON_SECRET is missing or empty in an environment, the route continues and calls settleCommissions with the service client.

Other cron-style routes in this repo fail closed when the cron secret is not configured, so this route should do the same.

Steps to reproduce

  1. Run the app with CRON_SECRET unset or empty.
  2. Send POST /api/affiliates/settle without a valid bearer secret.
  3. The route proceeds into settlement instead of returning 401.

Expected behavior

The route should return 401 when CRON_SECRET is missing, and it should not create the service client or call settleCommissions unless the configured bearer secret is present.

Fix direction

Fail closed when CRON_SECRET is unset and add a route regression test covering both missing config and missing bearer auth.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions