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 theOGIS_HMAC_SECRET environment variable on your server:
- Docker
- CLI
- Generator
- CLI
How It Works
- Client constructs query parameters (e.g.,
title=Hello&template=twilight) - Parameters are sorted alphabetically and concatenated
- HMAC-SHA256 signature is computed using the secret
- Signature is appended to the URL as
&signature=... - Server verifies the signature before generating the image
Using the SDK
The SDK handles signing automatically when you providehmacSecret:
Manual Signing
If you’re not using the SDK, compute the signature manually.Algorithm
- Collect all query parameters except
signature - Sort parameters alphabetically by key
- URL-encode and concatenate as
key=value&key=value - Compute HMAC-SHA256 of the string using your secret
- Hex-encode the result
Implementation Examples
- Node.js
- Python
- Go
Error Responses
When authentication is enabled, invalid requests return:Security Best Practices
- Use environment variables — Store secrets in
OGIS_SECRETor similar - Rotate secrets periodically — Update your secret and redeploy
- 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:- Next.js API Route
- SvelteKit