Profile pictures from Gravatar or the identity provider, fetched and kept by the server

Both sources are off until switched on under Settings, Sign-in. The server asks only
gravatar.com (by a hash of the email) and the identity provider's own host, accepts only
small PNG/JPEG/WebP/GIF, keeps each picture for a day and serves it from /api/avatars/<id>,
so browsers never contact either. Shown in the user menu and on the Users page, with initials
as the fallback; the Privacy page says when it is on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 23:47:50 +02:00
1 parent 9782bd3252
commit c05c847d17
26 files changed
+4361 -21

No files matched your search

+11
View File
@@ -6,6 +6,8 @@ export interface CurrentUser {
email?: string;
name?: string;
role: UserRole;
/** Where this person's picture is, on this app (the server fetches it); null when no picture source is switched on for them. */
avatarUrl?: string | null;
/** Pages this person pinned to the top of their menu, by path — a page alone, or with filters ("/servers?status=offline"). */
favorites?: string[];
/** How this person arranged the dashboard cards. */
@@ -134,6 +136,13 @@ export interface UserRecord {
lastLoginAt: string | null;
/** The groups the identity provider reported at their last sign-in; null until they have signed in with groups available. */
groups: string[] | null;
avatarUrl: string | null;
}
/** Where profile pictures may come from. Both off until an administrator allows them. */
export interface ProfilePictureSettings {
gravatar: boolean;
identityProvider: boolean;
}
/** How roles are decided at sign-in: by hand on the Users page, or from the groups the identity provider reports. */
@@ -533,6 +542,7 @@ export interface AppSettings {
healthChecks: HealthCheckSettings;
digest: DigestSettings;
signIn: SignInSettings;
profilePictures: ProfilePictureSettings;
}
export type AppSettingsPatch = { [K in keyof AppSettings]?: Partial<AppSettings[K]> };
@@ -1483,6 +1493,7 @@ export interface PrivacyOverview {
tlsCertificateChecks: number;
servers: number;
serversWithAgent: number;
profilePictures: ProfilePictureSettings & { identityProviderHost: string | null };
channels: Record<"gotify" | "ntfy" | "smtp" | "webhook" | "webPush", { enabled: boolean; host: string | null }>;
};
}
+22
View File
@@ -0,0 +1,22 @@
import { useEffect, useState } from "react";
/** Up to two initials, for when a person has no picture. */
export function initialsOf(name: string): string {
const words = name.replace(/@.*$/, "").split(/[\s._-]+/).filter(Boolean);
return (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? "?").slice(0, 2)).toUpperCase();
}
/**
* A person's picture where there is one, their initials where there is not (no picture set up, the setting is off, or it could not be fetched).
* The picture comes from this app's own address — the server fetches it — so the browser never contacts Gravatar or the identity provider.
*/
export default function Avatar({ name, src, size = "sm" }: { name: string; src?: string | null; size?: "sm" | "md" }) {
const [failed, setFailed] = useState(false);
// A different picture (or a person) gets its own chance.
useEffect(() => setFailed(false), [src]);
return (
<span className={`avatar avatar-${size}`} aria-hidden="true">
{src && !failed ? <img className="avatar-img" src={src} alt="" loading="lazy" onError={() => setFailed(true)} /> : initialsOf(name)}
</span>
);
}
+2 -7
View File
@@ -16,6 +16,7 @@ import { useStackedTables } from "../hooks/useStackedTables";
import { useShortcuts } from "../hooks/useShortcuts";
import { useFormLabels } from "../hooks/useFormLabels";
import ShortcutHelp from "../components/ShortcutHelp";
import Avatar from "../components/Avatar";
import { useBreadcrumbTailValue } from "../utils/breadcrumb";
const RAIL_KEY = "hlm-sidebar-rail";
@@ -33,12 +34,6 @@ function useMediaQuery(query: string): boolean {
return matches;
}
/** Up to two initials for the little avatar in the user menu. */
function initialsOf(name: string): string {
const words = name.replace(/@.*$/, "").split(/[\s._-]+/).filter(Boolean);
return (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? "?").slice(0, 2)).toUpperCase();
}
const OPEN_GROUPS_KEY = "hlm-nav-open-groups";
function loadOpenGroups(): Set<string> {
@@ -326,7 +321,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
title={user.email ?? undefined}
onClick={() => setMenuOpen((open) => !open)}
>
<span className="avatar avatar-sm">{initialsOf(user.name ?? user.email ?? user.sub)}</span>
<Avatar name={user.name ?? user.email ?? user.sub} src={user.avatarUrl} />
<span className="user-menu-who">
<span className="d-block text-truncate">{user.name ?? user.email ?? user.sub}</span>
<span className="d-block small opacity-75">{user.role}</span>
+14
View File
@@ -260,6 +260,20 @@ export default function Privacy() {
<strong>Certificate checks</strong> — for {outbound?.tlsCertificateChecks ?? 0} secret{outbound?.tlsCertificateChecks === 1 ? "" : "s"} with
a host to check, the app connects to that host to read its certificate — never to this server itself, a loopback or link-local address, or a cloud metadata address.
</li>
<li className="mb-2">
<strong>Profile pictures</strong> —{" "}
{outbound && (outbound.profilePictures.gravatar || outbound.profilePictures.identityProvider) ? (
<>
this server fetches pictures
{outbound.profilePictures.identityProvider ? ` from the identity provider${outbound.profilePictures.identityProviderHost ? ` (${outbound.profilePictures.identityProviderHost})` : ""}` : ""}
{outbound.profilePictures.identityProvider && outbound.profilePictures.gravatar ? " and" : ""}
{outbound.profilePictures.gravatar ? " from Gravatar, which is sent a hash of each person's email address and sees this server's IP address" : ""}. Your browser never
contacts either: it asks this app, which keeps each picture for a day.
</>
) : (
"switched off, so nothing is fetched. People are shown as their initials."
)}
</li>
<li className="mb-2">
<strong>Skatteverket</strong> — only when an admin clicks "Import from Skatteverket" under Settings → Names, the app asks
Skatteverket's open name statistics for the most common given names. The request carries a sex and a birth year, nothing about you
+7 -1
View File
@@ -9,6 +9,7 @@ import { ErrorNotice } from "../components/Notice";
import { SearchBox } from "../components/TableToolbar";
import { useTableSearch } from "../hooks/useTableSearch";
import { EmptyRow, LoadingRow } from "../components/EmptyState";
import Avatar from "../components/Avatar";
const ROLES: UserRole[] = ["viewer", "operator", "admin"];
@@ -95,7 +96,12 @@ export default function Users() {
<tbody>
{sorted?.map((u) => (
<tr key={u.id}>
<td>{u.name ?? "—"}</td>
<td>
<span className="d-inline-flex align-items-center gap-2">
<Avatar name={u.name ?? u.email ?? u.oidcSub} src={u.avatarUrl} />
{u.name ?? "—"}
</span>
</td>
<td>{u.email ?? "—"}</td>
<td style={{ maxWidth: 160 }}>
<select
+42 -3
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { api, type GroupRolePreview, type SignInSettings as SignInSettingsData } from "../../api/client";
import { api, type GroupRolePreview, type ProfilePictureSettings, type SignInSettings as SignInSettingsData } from "../../api/client";
import { ErrorNotice } from "../../components/Notice";
import { PageSkeleton } from "../../components/Skeleton";
import { readableError } from "../../utils/errors";
@@ -7,6 +7,7 @@ import { toast } from "../../utils/toast";
import ExportTableButton from "../../components/ExportTableButton";
const DEFAULTS: SignInSettingsData = { roleFromGroups: false, groupsClaim: "groups", adminGroups: [], operatorGroups: [], otherwise: "viewer" };
const NO_PICTURES: ProfilePictureSettings = { gravatar: false, identityProvider: false };
/** One name per line or separated by commas — whichever is easier to paste in. */
const parseNames = (text: string): string[] => [...new Set(text.split(/[\n,]/).map((s) => s.trim()).filter(Boolean))];
@@ -25,6 +26,8 @@ export default function SignInSettings() {
const [operatorText, setOperatorText] = useState("");
const [otherwise, setOtherwise] = useState<"viewer" | "keep">("viewer");
const [preview, setPreview] = useState<GroupRolePreview | null>(null);
const [loadedPictures, setLoadedPictures] = useState<ProfilePictureSettings>(NO_PICTURES);
const [pictures, setPictures] = useState<ProfilePictureSettings>(NO_PICTURES);
const [busy, setBusy] = useState<"check" | "save" | null>(null);
useEffect(() => {
@@ -38,6 +41,9 @@ export default function SignInSettings() {
setAdminText(s.adminGroups.join("\n"));
setOperatorText(s.operatorGroups.join("\n"));
setOtherwise(s.otherwise);
const p = res.settings.profilePictures ?? NO_PICTURES;
setLoadedPictures(p);
setPictures(p);
})
.catch((err) => setError(readableError(err)));
}, []);
@@ -45,7 +51,7 @@ export default function SignInSettings() {
if (!loaded) return error ? <ErrorNotice error={error} /> : <PageSkeleton />;
const draft = (): SignInSettingsData => ({ roleFromGroups: enabled, groupsClaim: claim.trim() || "groups", adminGroups: parseNames(adminText), operatorGroups: parseNames(operatorText), otherwise });
const dirty = JSON.stringify(draft()) !== JSON.stringify(loaded);
const dirty = JSON.stringify(draft()) !== JSON.stringify(loaded) || JSON.stringify(pictures) !== JSON.stringify(loadedPictures);
async function check() {
setBusy("check");
@@ -65,8 +71,9 @@ export default function SignInSettings() {
setError(null);
try {
const d = draft();
await api.settings.update({ signIn: d });
await api.settings.update({ signIn: d, profilePictures: pictures });
setLoaded(d);
setLoadedPictures(pictures);
toast.success(d.roleFromGroups ? "Saved. Roles now follow groups at each sign-in." : "Saved. Roles are set by hand on the Users page.");
} catch (err) {
setError(readableError(err));
@@ -144,6 +151,38 @@ export default function SignInSettings() {
</div>
</div>
<div className="card mb-3">
<div className="card-header">
<h3 className="card-title">Profile pictures</h3>
</div>
<div className="card-body">
<p className="text-secondary">
Without a picture a person is shown as their initials. Either source below can be allowed; the picture from the identity provider is tried first. Both are off, because each means
<strong> this server</strong> asks an outside address for a picture. People's browsers never do: the server fetches, checks (small PNG, JPEG, WebP or GIF only) and keeps the pictures for a day,
and serves them from this app. A change shows within a day, or on the next sign-in for a new picture address.
</p>
<label className="form-check mb-2">
<input type="checkbox" className="form-check-input" checked={pictures.identityProvider} onChange={(e) => setPictures({ ...pictures, identityProvider: e.target.checked })} />
<span className="form-check-label">
The picture the identity provider gives
<span className="form-hint d-block">
The <code>picture</code> claim from Authentik, kept at each sign-in. Only addresses on Authentik's own host (or Gravatar, if that is allowed too) are used.
</span>
</span>
</label>
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={pictures.gravatar} onChange={(e) => setPictures({ ...pictures, gravatar: e.target.checked })} />
<span className="form-check-label">
Gravatar
<span className="form-hint d-block">
gravatar.com is sent a SHA-256 hash of the person's email address (not the address itself), and sees this server's IP address. Anyone who already knows an address can check
it against a hash, so leave this off if the email addresses are private.
</span>
</span>
</label>
</div>
</div>
{preview && (
<div className="card">
<div className="card-header">
+8
View File
@@ -149,6 +149,14 @@ html[data-env] .navbar-vertical {
background: color-mix(in srgb, currentColor 14%, transparent);
}
/* A profile picture fills the little circle; without one the circle holds initials. */
.avatar .avatar-img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: inherit;
}
.user-menu-who {
flex: 1;
min-width: 0;