/t/* is public: anyone who knows a URL can request any transformation of it. Signed URLs close that off. Your backend signs the exact URL it wants to allow, and the server refuses anything else.
API_SECRET, truncated to 16 hex characters. On every request the server recomputes it and compares in constant time. A signature that does not verify gets 401. One that is missing or the wrong length gets 400, before any comparison happens.
Sign {transformations}/{file-path} when there are transformations, {file-path} alone when there are none. Change either part of the URL and the signature stops matching, which is what stops a visitor editing w_200 into w_5000.
Setup
1. Set API_SECRET
Add API_SECRET to your environment. It must be at least 16 characters long.
Scaffolded with the Openinary CLI? A 64-character API_SECRET is already in your .env, so skip to step 2.
2. Generate signatures in your backend
Usecrypto.createHmac (Node.js) or an equivalent library in your language. Never generate signatures client-side.
- TypeScript / Node.js
- Python
- PHP
Security considerations
Signatures are tied to exact transformations and paths
Signatures are tied to exact transformations and paths
Changing any character in the transformation string or file path invalidates the signature. A signature for
w_800,h_600/photo.jpg cannot be reused for w_400,h_300/photo.jpg.Timing-safe comparison prevents timing attacks
Timing-safe comparison prevents timing attacks
The server uses
crypto.timingSafeEqual to compare signatures. This prevents
attackers from deducing valid signatures by measuring response time
differences.The signature does not expire
The signature does not expire
Signed URLs do not have a built-in expiry. If you need time-limited URLs,
append an expiry timestamp to the file path or transformation string and
enforce it in a reverse proxy or middleware layer.
Rotate API_SECRET if compromised
Rotate API_SECRET if compromised
If
API_SECRET is leaked, immediately replace it with a new value and restart the server. All previously generated signed URLs will become invalid.Related
Image Transformations
Full reference for transformation parameters you can sign.
Server Configuration
How to set
API_SECRET and other server options.Sign Upload
A separate use of
API_SECRET: mint short-lived signatures for direct client-side uploads, rather than signing transformation URLs.