Customer branding (#155), part 2: the registry derives colour and logo from the home page of the workspace's company domain. Builds on #156 (merged, 9685ec04). Replaces #157: same code, without the merge commit that failed commitlint.
Behaviour
Domain: the admin address's registrable domain (eTLD+1).
When that's empty or free mail, it's the most frequent company domain among the Keycloak members; a tie goes to the alphabetically first.
Free mail is a fixed list, including outlook., yahoo. and gmx.*.
No domain: derive_state failed, no_domain, and no branding.
Own http.Transport: no proxy, not the traced default (so no trace headers go to customer sites), no cookie jar.
https on port 443 only.
Public IPs only, checked in Dialer.Control, so after DNS and on every hop. Private, CGNAT, loopback, link-local, documentation and NAT64 ranges are refused.
At most 5 redirects, within the same registrable domain (public suffix list).
Limits: 10 s per request, HTML ≤ 2 MB, manifest and images ≤ 1 MB.
User-Agent: BreakpilotBranding/1.0, nothing about the customer.
Tries https://<domain>/, then https://www.<domain>/.
Colour, the first that is usable:
the first theme-color without media;
the manifest's theme_color;
the logo's dominant colour (64×64, the filters, 5-bit buckets, tie to the lowest packed value, rounded mean).
White, black and grey are skipped. Hex and rgb() are read; named colours are not.
Logo, the first candidate that downloads and decodes:
the manifest's largest PNG ≥ 128 px;
apple-touch-icon;
the largest PNG/ICO/JPEG rel=icon;
/favicon.ico.
It's stored as a 256×256 PNG; SVG-only sites get none.
Determinism: the same fetched bytes give the same result. The HTML and logo sha256 are stored as provenance.
POST /v1/tenants/{id}/branding/derive ("Neu ermitteln", tenants.write):
It is synchronous, bounded to about 25 s (under the 30 s write timeout).
It replaces a manual choice and counts as acknowledged, so no notice. A failure keeps what was shown and reports derive_state: failed with the reason.
It answers 503 derive_disabled while switched off, and 409 for demo workspaces.
Background:
Tenant creation and trial requests queue customer workspaces (only while switched on). Signup never waits.
RunBranding derives up to 5 per minute.
Network failures are retried twice, 6 h apart. A background derivation never overwrites a manual choice: the store checks manual in the same statement.
Audit: branding.derived (domain, colour source, logo yes/no, forced) and branding.failed (domain, reason). Logs carry the tenant id only, not the domain.
Switches (both off by default)
BRANDING_DERIVE=on: the endpoint, the queueing and the worker.
Proposal: on for stage; on prod only once the privacy notice names the fetch (still open on #155).
BRANDING_BACKFILL=on: queues every customer workspace without branding once at start.
This is the one-off backfill. On prod it's Sharang's call: their admins will see the notice.
Tests
internal/branding, against a TLS test server:
theme-color plus apple-touch-icon;
grey theme-color, then the manifest's colour and icon, with the www fallback;
colour from favicon.ico;
SVG only;
off-domain redirect;
redirect loop;
private address never dialled (the server sees 0 hits);
PublicIP table, PickDomain, colour parsing and the tie rule.
TestBrandingDerive on Memory and Postgres:
nothing happens while switched off;
queued at creation and derived in the background, with a notice;
Customer branding (#155), part 2: the registry derives colour and logo from the home page of the workspace's company domain. Builds on #156 (merged, 9685ec04). Replaces #157: same code, without the merge commit that failed commitlint.
## Behaviour
- **Domain**: the admin address's registrable domain (eTLD+1).
- When that's empty or free mail, it's the most frequent company domain among the Keycloak members; a tie goes to the alphabetically first.
- Free mail is a fixed list, including outlook.*, yahoo.* and gmx.*.
- No domain: `derive_state` failed, `no_domain`, and no branding.
- **Fetch** (`internal/branding`), per #155 step 2:
- Own `http.Transport`: no proxy, not the traced default (so no trace headers go to customer sites), no cookie jar.
- https on port 443 only.
- Public IPs only, checked in `Dialer.Control`, so after DNS and on every hop. Private, CGNAT, loopback, link-local, documentation and NAT64 ranges are refused.
- At most 5 redirects, within the same registrable domain (public suffix list).
- Limits: 10 s per request, HTML ≤ 2 MB, manifest and images ≤ 1 MB.
- `User-Agent: BreakpilotBranding/1.0`, nothing about the customer.
- Tries `https://<domain>/`, then `https://www.<domain>/`.
- **Colour**, the first that is usable:
1. the first `theme-color` without `media`;
2. the manifest's `theme_color`;
3. the logo's dominant colour (64×64, the filters, 5-bit buckets, tie to the lowest packed value, rounded mean).
White, black and grey are skipped. Hex and `rgb()` are read; named colours are not.
- **Logo**, the first candidate that downloads and decodes:
1. the manifest's largest PNG ≥ 128 px;
2. `apple-touch-icon`;
3. the largest PNG/ICO/JPEG `rel=icon`;
4. `/favicon.ico`.
It's stored as a 256×256 PNG; SVG-only sites get none.
- **Determinism**: the same fetched bytes give the same result. The HTML and logo sha256 are stored as provenance.
- **`POST /v1/tenants/{id}/branding/derive`** ("Neu ermitteln", tenants.write):
- It is synchronous, bounded to about 25 s (under the 30 s write timeout).
- It replaces a manual choice and counts as acknowledged, so no notice. A failure keeps what was shown and reports `derive_state: failed` with the reason.
- It answers 503 `derive_disabled` while switched off, and 409 for demo workspaces.
- **Background**:
- Tenant creation and trial requests queue customer workspaces (only while switched on). Signup never waits.
- `RunBranding` derives up to 5 per minute.
- Network failures are retried twice, 6 h apart. A background derivation never overwrites a manual choice: the store checks `manual` in the same statement.
- **Audit**: `branding.derived` (domain, colour source, logo yes/no, forced) and `branding.failed` (domain, reason). Logs carry the tenant id only, not the domain.
## Switches (both off by default)
- `BRANDING_DERIVE=on`: the endpoint, the queueing and the worker.
- Proposal: on for stage; on prod only once the privacy notice names the fetch (still open on #155).
- `BRANDING_BACKFILL=on`: queues every customer workspace without branding once at start.
- This is the one-off backfill. On prod it's Sharang's call: their admins will see the notice.
## Tests
- `internal/branding`, against a TLS test server:
- theme-color plus apple-touch-icon;
- grey theme-color, then the manifest's colour and icon, with the www fallback;
- colour from favicon.ico;
- SVG only;
- off-domain redirect;
- redirect loop;
- **private address never dialled** (the server sees 0 hits);
- `PublicIP` table, `PickDomain`, colour parsing and the tie rule.
- `TestBrandingDerive` on Memory and Postgres:
- nothing happens while switched off;
- queued at creation and derived in the background, with a notice;
- forced over a manual choice;
- a failed run keeps the branding;
- background retry;
- member-domain fallback and `no_domain`.
- golangci-lint: 0 issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Customer branding (#155), steps 1–6: the registry reads the home page
of the workspace's company domain and stores its CI colour and logo.
- Domain: the admin's address, else the most frequent member domain
(tie: alphabetical); free mail never counts; no domain, no branding.
- Fetch (internal/branding): own transport (no proxy, no trace
headers, no cookies), https on 443 only, public IPs only, checked on
every dial after DNS, ≤ 5 redirects within the registrable domain,
10 s per request, HTML ≤ 2 MB, images ≤ 1 MB, User-Agent
BreakpilotBranding/1.0.
- Colour: theme-color without media, the manifest's theme_color, else
the logo's dominant colour; white, black and grey are skipped.
- Logo: manifest PNG ≥ 128 px, apple-touch-icon, PNG/ICO/JPEG icon,
/favicon.ico; stored as a 256×256 PNG, never SVG.
- POST /v1/tenants/{id}/branding/derive ("Neu ermitteln"): synchronous,
replaces a manual choice and counts as acknowledged.
- Background: tenant creation and trial requests queue the workspace;
RunBranding derives queued ones every minute, retries network
failures twice, 6 h apart. Audit branding.derived / branding.failed.
- Switches: BRANDING_DERIVE=on (off by default), BRANDING_BACKFILL=on
queues every customer workspace without branding once at start.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the 25 s budget was what failed, the attempt count was read with
the expired context; Postgres refused, and a retry was scheduled every
6 h without end. The failure is now recorded with a context that has
not ended. README: BRANDING_DERIVE, BRANDING_BACKFILL and the branding
route groups.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CODEOWNERS rules
requested review from Benjamin_Boenisch 2026-12-01 13:24:10 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Customer branding (#155), part 2: the registry derives colour and logo from the home page of the workspace's company domain. Builds on #156 (merged,
9685ec04). Replaces #157: same code, without the merge commit that failed commitlint.Behaviour
Domain: the admin address's registrable domain (eTLD+1).
derive_statefailed,no_domain, and no branding.Fetch (
internal/branding), per #155 step 2:http.Transport: no proxy, not the traced default (so no trace headers go to customer sites), no cookie jar.Dialer.Control, so after DNS and on every hop. Private, CGNAT, loopback, link-local, documentation and NAT64 ranges are refused.User-Agent: BreakpilotBranding/1.0, nothing about the customer.https://<domain>/, thenhttps://www.<domain>/.Colour, the first that is usable:
theme-colorwithoutmedia;theme_color;White, black and grey are skipped. Hex and
rgb()are read; named colours are not.Logo, the first candidate that downloads and decodes:
apple-touch-icon;rel=icon;/favicon.ico.It's stored as a 256×256 PNG; SVG-only sites get none.
Determinism: the same fetched bytes give the same result. The HTML and logo sha256 are stored as provenance.
POST /v1/tenants/{id}/branding/derive("Neu ermitteln", tenants.write):derive_state: failedwith the reason.derive_disabledwhile switched off, and 409 for demo workspaces.Background:
RunBrandingderives up to 5 per minute.manualin the same statement.Audit:
branding.derived(domain, colour source, logo yes/no, forced) andbranding.failed(domain, reason). Logs carry the tenant id only, not the domain.Switches (both off by default)
BRANDING_DERIVE=on: the endpoint, the queueing and the worker.BRANDING_BACKFILL=on: queues every customer workspace without branding once at start.Tests
internal/branding, against a TLS test server:PublicIPtable,PickDomain, colour parsing and the tie rule.TestBrandingDeriveon Memory and Postgres:no_domain.🤖 Generated with Claude Code