You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 24ed307
Browse filesBrowse the repository at this point in the historyBrowse files
feat(github): support GitHub Enterprise Server via GH_HOST / GITHUB_HOST
Adds an env-var-only host override so the `github_*` fetcher family (and
`git_repo_name`'s github-remote detection) can target a GitHub Enterprise
Server instance instead of github.com. Reads `GH_HOST` (matches the `gh`
CLI), then `GITHUB_HOST` (mirrors splashboard's `GITHUB_TOKEN` /
`GITHUB_USER` env-var family), defaulting to `github.com`.
URL composition defaults to `api.<host>` for REST and `api.<host>/graphql`
for GraphQL — same shape as github.com, matching what the API returns in
`url` / `repository_url` payload fields so the strip-prefix code works
identically for both. Resolved ONCE per process via OnceLock-cached
statics so URL composition has zero per-request env reads.
Older `<host>/api/v3` path-based GHE deployments can override the API
URLs explicitly via `GH_API_URL` / `GITHUB_API_URL` and `GH_GRAPHQL_URL`
/ `GITHUB_GRAPHQL_URL` — the `GITHUB_*` names match the standard env
vars GitHub Actions exposes (`GITHUB_API_URL`, `GITHUB_GRAPHQL_URL`):
GH_HOST=ghe.example.com
GH_API_URL=https://ghe.example.com/api/v3
GH_GRAPHQL_URL=https://ghe.example.com/api/graphql
Avatar handling: github.com keeps the unchanged `<host>/<user>.png`
public shortcut. GHE indirects through `/users/<login>` to get the
server-signed `avatar_url` (the public shortcut redirects to `/login`).
`slug_from_url` now accepts any non-empty SCP-style user — some GHE
deployments configure a non-`git` SSH user (e.g. `<orgname>@<ghe-host>:
owner/name`), so restricting to `git@` would drop those remotes. When
`GH_HOST` is set, the configured host is tried first; github.com is a
fallback so a user with a GHE-set shell can still parse github.com
remotes.
Safety::Safe is preserved. The override is env-var-only — a malicious
`.splashboard.toml` cannot redirect a user's token to an attacker-chosen
origin, only the user's shell can. This is the same property that the
existing `GH_TOKEN` / `GITHUB_TOKEN` env vars already rely on.
Minimal-diff approach: no public-API signature changes. For github.com
(GH_HOST unset), every fetcher hits the same URLs as upstream with the
same number of HTTP roundtrips and the same response handling — the
only structural change is that `avatar.rs::download_avatar` gains an
unreachable GHE branch in its compiled async state machine.
Live-verified against a GitHub Enterprise instance (REST + GraphQL
contributions calendar + notifications + avatar) and api.github.com
(regression).
Copy file name to clipboardExpand all lines: src/fetcher/github/avatar.rs
+26-7Lines changed: 26 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,11 @@
1
-
//! `github_avatar` — download a github.com avatar PNG and expose it as `Body::Image`.
1
+
//! `github_avatar` — download an avatar PNG and expose it as `Body::Image`.
2
2
//!
3
-
//! Safety::Safe: the host is hardcoded (`github.com/<user>.png`), so config can't redirect
4
-
//! traffic to a different origin. No auth is needed — the endpoint is public — so we do not
5
-
//! attach `GH_TOKEN`, avoiding accidental token exposure along the redirect chain.
3
+
//! - github.com: keeps the original public shortcut (`https://github.com/<user>.png`).
4
+
//! - GHE: the public shortcut redirects to `/login`, so we indirect through
5
+
//! `/users/<login>` to get the server-signed `avatar_url`.
6
+
//!
7
+
//! Safety::Safe: the host is resolved via `client::host()` (env-var-only), so a malicious
8
+
//! `.splashboard.toml` cannot redirect traffic to an attacker-chosen origin.
6
9
//!
7
10
//! Caching: the PNG is written to `$SPLASHBOARD_HOME/cache/avatars/<user>-<size>.png`. The
8
11
//! fetcher framework already gates re-downloads via `refresh_interval`; we default to one day
@@ -19,10 +22,9 @@ use crate::payload::{Body, ImageData, Payload};
0 commit comments