Skip to main content
HTTP basic authentication protects a load balancer with a username and password. Envoy checks the credentials on every request, at the edge, before the request reaches your origin. Requests without valid credentials get 401 Unauthorized. There are two ways to set it up:
  • datumctl alb auth is the quickest. One command sets the users, creates the Secret, and attaches the policy.
  • A SecurityPolicy manifest gives you full control, for example to keep the configuration in Git or to protect a single route.

Set up basic auth with datumctl alb

To protect a load balancer, pass one or more users, and give their password on standard input:
To admit several users with the same password, repeat --user, as in --user admin --user editor. To check a change without applying it, add --dry-run. To see which usernames are allowed, run the following command:
datumctl alb describe ALB_NAME also shows whether basic auth is on. To turn basic auth off, run the following command:
To confirm that it works, request the load balancer with and without credentials:

Set up basic auth with a SecurityPolicy

The rest of this page shows how to configure the same thing with Envoy Gateway resources, using datumctl apply.

How it works

At a high level, this setup:
  1. Generates credentials in htpasswd (SHA) format
  2. Stores credentials in a Kubernetes Secret
  3. Labels the Secret so it is synced to edge clusters
  4. Attaches a SecurityPolicy to an HTTPRoute
  5. Verifies authentication behavior

Prerequisites

  • datumctl installed and authenticated
  • A valid Project
  • Existing:
    • Gateway
    • HTTPRoute
  • Permission to create:
    • Secret
    • SecurityPolicy
Verify access:

Critical requirement: secret syncing

Secrets and ConfigMaps referenced by gateway configurations are not automatically synced to edge clusters. To make a Secret available to edge gateways, it must include the following label:

Why this matters

  • Without this label, the gateway receives the policy but not the Secret
  • Envoy fails to load the Basic Auth credentials
  • All requests return HTTP 500 instead of a login prompt
This requirement exists to prevent accidental replication of unrelated secrets.

Configuration steps

Step 1: Set variables


Step 2: Generate htpasswd entry (SHA)

Envoy Gateway currently supports SHA-based htpasswd entries only. Other formats (bcrypt, APR1) are not supported and will cause failures.

Step 3: Create the secret

The Secret must:
  • Use the key .htpasswd
  • Exist in the same namespace as the SecurityPolicy
  • Include the gateway-sync label

Step 4: Attach Basic Auth using a SecurityPolicy

Attach the policy to the HTTPRoute. This is the most reliable attachment point.

Verification

Unauthenticated request

Expected response:
Browsers will display a login prompt.

Authenticated request

Expected response:

Cleanup / disable Basic Auth


Troubleshooting

Common failure modes

Useful debug commands


Best practices

  • Use Basic Auth for development, demos, and staging environments
  • Rotate credentials regularly
  • Store credentials securely using CI secrets or a secret manager
  • Use JWT, OIDC, or SSO for production authentication

Summary

  • HTTP Basic Auth is configured using Envoy Gateway SecurityPolicy
  • Secrets must be explicitly synced to edge clusters using the gateway-sync label
  • {SHA} htpasswd format is required — bcrypt and APR1 are not supported
  • Attaching policies to HTTPRoute is the most reliable approach
Last modified on October 23, 2026