Skip to main content
Secure your ogis instance with HMAC-SHA256 signature validation. When enabled, all requests must include a valid signature parameter.

When to Use Authentication

  • Private instances — Prevent unauthorized usage of your self-hosted ogis
  • Rate limiting — Control who can generate images
  • Usage tracking — Identify requests by signature
The public hosted service at img.ogis.dev does not require authentication.

Enabling Authentication

Set the OGIS_HMAC_SECRET environment variable on your server:
Choose a strong, random secret (32+ characters recommended):

How It Works

  1. Client constructs query parameters (e.g., title=Hello&template=twilight)
  2. Parameters are sorted alphabetically and concatenated
  3. HMAC-SHA256 signature is computed using the secret
  4. Signature is appended to the URL as &signature=...
  5. Server verifies the signature before generating the image

Using the SDK

The SDK handles signing automatically when you provide hmacSecret:

Manual Signing

If you’re not using the SDK, compute the signature manually.

Algorithm

  1. Collect all query parameters except signature
  2. Sort parameters alphabetically by key
  3. URL-encode and concatenate as key=value&key=value
  4. Compute HMAC-SHA256 of the string using your secret
  5. Hex-encode the result

Implementation Examples

Error Responses

When authentication is enabled, invalid requests return:

Security Best Practices

Never expose your secret in client-side code or version control.
  1. Use environment variables — Store secrets in OGIS_SECRET or similar
  2. Rotate secrets periodically — Update your secret and redeploy
  3. Use HTTPS — Always serve your ogis instance over HTTPS to prevent signature interception

Server-Side Only

Generate signed URLs on your server, not in the browser: