Lower-case the image URL's host and require a signature for a port (closes #246)
check / check (push) Waiting to run
check / check (push) Waiting to run
With cdn.example.com allowlisted, CDN.Example.com and cdn.example.com:8443 passed the allowlist too, and each spelling had its own cache entries and its own connections under upstream_connections_per_host. The image URL parser now lower-cases the host and refuses one holding "@" with ErrInvalidHost (400). ValidateRequest counts a host followed by ":", with or without a port, as not allowlisted, so it needs a signature. That check is not in allowlist.IsAllowed, which also matches referer_blocklist. A URL is now signed over the lower-cased host; README.md says so. Model: opus-5-5
This commit is contained in:
@@ -411,7 +411,8 @@ HMAC-SHA256(secret, "host:path:query:width:height:format:expiration:quality:fit"
|
||||
|
||||
Where:
|
||||
|
||||
- `host` — source origin hostname (e.g. `cdn.example.com`)
|
||||
- `host` — source origin hostname in lower case, whatever its case in the URL,
|
||||
followed by `:` and the port when the URL has one (e.g. `cdn.example.com`)
|
||||
- `path` — source path (e.g. `/photos/cat.jpg`)
|
||||
- `query` — source query string, empty string if none
|
||||
- `width` — requested width in pixels, `0` for original
|
||||
@@ -463,6 +464,12 @@ entry that is neither a host name (letters, digits, hyphens, underscores and
|
||||
dots, with at most one leading dot) nor an IP address, such as one with a port
|
||||
or a `*.` wildcard, aborts startup.
|
||||
|
||||
pixa lower-cases the host of a `/v1/image/` URL before anything else uses it, so
|
||||
`CDN.Example.com` is matched, fetched, cached and counted against
|
||||
`upstream_connections_per_host` as `cdn.example.com`. Such a URL whose host has
|
||||
a port, as in `cdn.example.com:8443`, or a `:` with no port, needs a signature
|
||||
even when the host is allowlisted. A host holding `@` is refused with 400.
|
||||
|
||||
### Configuration
|
||||
|
||||
Every setting can be given as an environment variable, in a YAML config file
|
||||
|
||||
Reference in New Issue
Block a user