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

+2 -1
View File
@@ -11,6 +11,7 @@ import { users } from "../db/schema.js";
import { recordAudit } from "../services/audit.js";
import { verifyIdTokenSignature } from "./idToken.js";
import { rateLimit } from "../utils/rateLimit.js";
import { pictureFromClaims } from "../services/avatars.js";
export const authRouter = Router();
@@ -130,7 +131,7 @@ authRouter.get("/callback", signInLimiter, async (req, res, next) => {
console.warn(`[auth] roles follow groups, but the sign-in carried no "${signIn.groupsClaim}" claim — roles left as they are`);
}
const { user, created, roleChange } = await upsertUserFromLogin({ sub: claims.sub, email, name, groups });
const { user, created, roleChange } = await upsertUserFromLogin({ sub: claims.sub, email, name, groups, pictureUrl: pictureFromClaims(claimSources) });
if (roleChange) {
await recordAudit({
actor: user,
+4
View File
@@ -27,6 +27,8 @@ export async function upsertUserFromLogin(params: {
email?: string;
name?: string;
groups?: string[] | null;
/** The identity provider's "picture" claim, when it gave one; left as it was when it did not. */
pictureUrl?: string;
}): Promise<{ user: typeof users.$inferSelect; created: boolean; roleChange?: RoleChange }> {
const [existing] = await db.select().from(users).where(eq(users.oidcSub, params.sub)).limit(1);
const now = new Date().toISOString();
@@ -55,6 +57,7 @@ export async function upsertUserFromLogin(params: {
.set({
email: params.email ?? existing.email,
name: params.name ?? existing.name,
pictureUrl: params.pictureUrl ?? existing.pictureUrl,
lastLoginAt: now,
role,
...(groupsJson !== undefined ? { groups: groupsJson } : {}),
@@ -74,6 +77,7 @@ export async function upsertUserFromLogin(params: {
oidcSub: params.sub,
email: params.email,
name: params.name,
pictureUrl: params.pictureUrl ?? null,
role,
lastLoginAt: now,
...(groupsJson !== undefined ? { groups: groupsJson } : {}),