Skip to content

event-ledger returns 403 instead of 401 for requests with no Authorization header #1967

Description

@shelleyshen-0

Problem

Write endpoints (/v1/ledger/.../instances/{id}, /v2/ledger/.../instances/{id},
/v3/ledger/cloudevents) return 403 when a request has no Authorization header,
instead of 401.

newPolicyMiddleware (internal/middleware/policy.go, ~line 217) forwards the
request to the policy evaluator with an empty API key even when no header was
sent. The evaluator denies it and returns 403, which gets relayed as-is.

No credentials at all should be 401, not 403. This also wastes a network call
to the evaluator on every unauthenticated request.

Fix

Return 401 immediately when Authorization is missing, unless JWT claims are
already in request context (managed-mode JWT-then-policy chain clears the
header after local verification, so that path must not be affected).

Read endpoints may rely on PDP-decided anonymous access; don't remove that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions