Repository navigation
Add signed URLs - #23
Merged
Merged
Conversation
With SIGNING_SECRETS set, the avatar endpoints only answer URLs that end in a valid sig parameter, the HMAC-SHA256 of the path and options in front of it. URLs that carry their options in the path keep sig and exp in that segment, so signed URLs also work as a Gravatar default image. An optional exp parameter sets an expiry and caps Cache-Control at it. Every secret needs at least 32 characters. Closes #22
FlorianKoerner
force-pushed
the
feat/signed-urls
branch
from
November 16, 2026 19:39
7200585 to
28b7ad8
Compare
- Refuse a URL with a raw `#`. The router ends the URL there, so it read fewer options than the signature covered. - Refuse to start when SIGNING_SECRETS is set but holds no secret, instead of running without signatures. - Answer a query string next to path options with its own message instead of "Invalid signature." - Document that a secret cannot contain a comma or surrounding whitespace. - Clear SIGNING_SECRETS for the whole test run, so a value exported in the shell does not fail the other suites.
Refusing to start was too strict for setups that pass the variable through empty, such as a compose file with a default.
FlorianKoerner
added a commit
to dicebear/dicebear
that referenced
this pull request
Nov 21, 2026
Adds a section on signed URLs to the self-hosting page: SIGNING_SECRETS, signing examples in seven languages, the path variant for Gravatar, exp and key rotation. The feature was added in dicebear/api#23.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #22.
Self-hosted instances are usually public, so anyone who finds the URL can render avatars on them. With
SIGNING_SECRETSset, the avatar endpoints only answer URLs that the operator's own backend signed. Without the variable nothing changes.How it works:
sigis the HMAC-SHA256 of the path and options, hex encoded, and always the last parameter. Unsigned or wrongly signed requests get a403withCache-Control: no-store.sigandexplive in that path segment and the signature covers the decoded segment. It does not matter how a client encodes it.expis optional, a Unix timestamp in seconds. Expired URLs get a403, andmax-ageis capped at the time that remains. A malformed or repeatedexpgetsInvalid expiry.SIGNING_SECRETSaccepts several comma-separated secrets for key rotation. Each one needs at least 32 characters, or the API refuses to start.The docs are in dicebear/dicebear#574.