GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #4160 from lidge-jun/lane-b/3-3859 · agentHits/opencodex@b27aa50

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs-site/src/content/docs/reference/configuration
    • server.md
  • src
    • cli
      • index.ts
    • codex
      • auth-api.ts
    • config.ts
    • lib
      • privacy.ts
    • oauth
      • index.ts
    • server/management
      • oauth-account-routes.ts
    • types
      • config.ts
  • tests
    • codex-integration
      • codex-auth-api.test.ts
    • lib
      • privacy-mask-account.test.ts
    • oauth
      • oauth-status-privacy.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs-site/src/content/docs/reference/configuration/server.md‎

Copy file name to clipboardExpand all lines: docs-site/src/content/docs/reference/configuration/server.md
+26Lines changed: 26 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,32 @@ use `ssh -g -L`, broad container publishing, or forwarding modes that expose the
224224
`0.0.0.0`. Bind explicitly with `ssh -L 127.0.0.1:20100:localhost:10100` when unsure.
225225
:::
226226

227+
## Account email masking (`privacy`)
228+
229+
Stored account emails are masked everywhere they leave the proxy — the dashboard account lists,
230+
`GET /api/codex-auth/accounts`, `GET /api/oauth/status`, and the `ocx status` logins section all
231+
show `p***[email protected]` rather than the address on file.
232+
233+
| Field | Type | Default | Meaning |
234+
| --- | --- | --- | --- |
235+
| `privacy.maskEmails?` | `boolean` | `true` | Set to `false` to show stored account emails in full. Absent, `true`, and any malformed value all keep masking, so only a deliberate `false` reveals an address. |
236+
237+
Turn it off when you run many accounts on a machine you control and cannot tell them apart from
238+
masked forms. Read the flag as a disclosure decision rather than a display preference: management
239+
is not always loopback, so on a hub configured with `remoteGui` an unmasked address reaches every
240+
management principal that can reach the hub, not only someone sitting at the machine. The flag
241+
moves only the email field — tokens, refresh tokens, and account identifiers stay redacted either
242+
way.
243+
244+
```json
245+
{ "privacy": { "maskEmails": false } }
246+
```
247+
248+
`ocx config set privacy.maskEmails false` fails with `config parent path not found` until the
249+
block exists, because `config set` walks into existing objects and never creates them. Write the
250+
whole object instead — `ocx config set privacy '{"maskEmails":false}'` — or add the block to
251+
`config.json` by hand.
252+
227253
## Storage cleanup
228254

229255
`storageCleanupPolicy` is disabled by default. When enabled, it runs on `startup`, `daily`, `weekly`,
Collapse file

‎src/cli/index.ts‎

Copy file name to clipboardExpand all lines: src/cli/index.ts
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1428,9 +1428,13 @@ async function handleStatus() {
14281428
}
14291429
}
14301430
const { collectOAuthHealthEntriesForCli, oauthLoginSummary } = await import("../oauth");
1431+
const { emailMaskingEnabled } = await import("../lib/privacy");
14311432
const { formatOAuthHealthForStatus } = await import("./status-oauth");
14321433
console.log(` OAuth logins:`);
1433-
for (const e of oauthLoginSummary()) {
1434+
// The operator's own `privacy.maskEmails` decision applies to the CLI too: `ocx status` is not
1435+
// the dashboard, but it reads the same stored addresses, and a flag that only moved one of the
1436+
// two would leave the operator unable to tell which surface they had configured.
1437+
for (const e of oauthLoginSummary(emailMaskingEnabled(loadConfig()))) {
14341438
console.log(` ${e.provider.padEnd(10)} ${e.loggedIn ? `✓ logged in${e.email ? ` (${e.email})` : ""}` : "✗ not logged in"}`);
14351439
}
14361440
const oauthHealthBlock = formatOAuthHealthForStatus(await collectOAuthHealthEntriesForCli());
Collapse file

‎src/codex/auth-api.ts‎

Copy file name to clipboardExpand all lines: src/codex/auth-api.ts
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export { clearMainAccountInfoCache } from "./main-account-cache";
115115
import type { CodexQuotaRefreshOutcome } from "./quota-refresh-outcome";
116116
import { getMainAccountHardLockStatus, type MainAccountHardLockStatus } from "./main-account-hard-lock";
117117
import { observeMainReserveRevocation } from "./reserve-availability";
118-
import { maskEmail } from "../lib/privacy";
118+
import { emailMaskingEnabled, projectEmail } from "../lib/privacy";
119119
import { codexWarmupFailureReason, warmCodexAccount } from "./warmup";
120120
export { maskEmail } from "../lib/privacy";
121121
import type { CodexAccount, CodexAccountCredentials, OcxConfig } from "../types";
@@ -370,14 +370,15 @@ function poolAccountDto(
370370
hasCredential: boolean,
371371
paused: boolean,
372372
priority: number,
373+
maskEmails: boolean,
373374
): CodexAuthAccountDto {
374375
const plan = codexPlanValue(account.plan);
375376
const quota = quotaForPlan(quotaResult.quota, plan);
376377
const needsReauth = !hasCredential || quotaResult.needsReauth || isAccountNeedsReauth(account.id);
377378
const health = projectCodexAccountHealth({ accountId: account.id, needsReauth });
378379
return {
379380
id: account.id,
380-
email: maskEmail(account.email) ?? account.email,
381+
email: projectEmail(account.email, maskEmails) ?? account.email,
381382
...(account.alias !== undefined ? { alias: account.alias } : {}),
382383
...(plan !== undefined ? { plan } : {}),
383384
logLabel: codexAccountLogLabel(account),
@@ -1929,6 +1930,8 @@ export async function listCodexAuthAccountsSnapshot(
19291930
): Promise<CodexAuthAccountsSnapshot> {
19301931
const runtimeConfig = getRuntimeConfig(config);
19311932
const poolAccounts = (runtimeConfig.codexAccounts ?? []).filter(isSelectableCodexPoolAccount);
1933+
// One redaction decision for the whole snapshot, read once from the operator's config (#3859).
1934+
const maskEmails = emailMaskingEnabled(runtimeConfig);
19321935
const mainResult = await fetchMainAccountInfoAttempt(forceRefresh, 1);
19331936
const refreshedPool = await mapWithConcurrency(poolAccounts, POOL_QUOTA_REFRESH_CONCURRENCY, async account => {
19341937
const cred = getCodexAccountCredential(account.id);
@@ -1973,6 +1976,7 @@ export async function listCodexAuthAccountsSnapshot(
19731976
false,
19741977
isCodexAccountPaused(runtimeConfig, accountId),
19751978
getCodexAccountPriority(runtimeConfig, accountId),
1979+
maskEmails,
19761980
)];
19771981
}
19781982
const resultGeneration = quotaResult.credentialGeneration ?? quotaResult.freshCredentialGeneration;
@@ -1992,6 +1996,7 @@ export async function listCodexAuthAccountsSnapshot(
19921996
true,
19931997
isCodexAccountPaused(runtimeConfig, accountId),
19941998
getCodexAccountPriority(runtimeConfig, accountId),
1999+
maskEmails,
19952000
)];
19962001
});
19972002
const fetchedMainGeneration = mainResult.identityGeneration ?? captureMainAccountIdentityGeneration();
@@ -2008,7 +2013,7 @@ export async function listCodexAuthAccountsSnapshot(
20082013
});
20092014
const main: CodexAuthAccountDto = {
20102015
id: MAIN_CODEX_ACCOUNT_ID,
2011-
email: maskEmail(mainInfo.email) ?? "Codex App login",
2016+
email: projectEmail(mainInfo.email, maskEmails) ?? "Codex App login",
20122017
plan: mainInfo.plan,
20132018
...(mainSnapshotLive && mainResult.quotaRefresh && mainResult.quotaRefreshGeneration !== undefined
20142019
&& isMainAccountIdentityGenerationLive(mainResult.quotaRefreshGeneration)
@@ -3026,6 +3031,9 @@ export async function handleCodexAuthAPI(
30263031
if (url.pathname === "/api/codex-auth/login-status" && req.method === "GET") {
30273032
const flowId = url.searchParams.get("flowId");
30283033
const accountId = url.searchParams.get("accountId")?.trim();
3034+
// Transient flow state carries the address of the account being added, so it follows the
3035+
// same operator policy as the stored accounts it is about to become.
3036+
const maskFlowEmails = emailMaskingEnabled(config);
30293037
// Reauth always has a pre-existing credential; never treat "credential exists" as success
30303038
// when the flow map entry is gone (would false-complete on lost/expired flow state).
30313039
const reauthStatus = url.searchParams.get("reauth") === "1";
@@ -3042,11 +3050,11 @@ export async function handleCodexAuthAPI(
30423050
...(readCodexAccountRecord(accountId)?.codexValidationPending ? { validationPending: true } : {}),
30433051
});
30443052
}
3045-
return jsonResponse(st ? { ...st, email: maskEmail(st.email) ?? undefined } : { status: "expired" });
3053+
return jsonResponse(st ? { ...st, email: projectEmail(st.email, maskFlowEmails) ?? undefined } : { status: "expired" });
30463054
}
30473055
// Legacy fallback: return latest pending flow
30483056
for (const [, st] of codexAuthLoginState) {
3049-
if (st.status === "pending") return jsonResponse({ ...st, email: maskEmail(st.email) ?? undefined });
3057+
if (st.status === "pending") return jsonResponse({ ...st, email: projectEmail(st.email, maskFlowEmails) ?? undefined });
30503058
}
30513059
return jsonResponse({ status: "idle" });
30523060
}
Collapse file

‎src/config.ts‎

Copy file name to clipboardExpand all lines: src/config.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,9 @@ const configSchema = z.object({
11461146
// candidates are rejected explicitly by remoteGuiConfigError below.
11471147
hub: hubConfigSchema.optional().catch(undefined),
11481148
remoteGui: remoteGuiConfigSchema.optional().catch(undefined),
1149+
// A malformed privacy block must never be read as "unmask": .catch(undefined) drops it and
1150+
// emailMaskingEnabled then falls back to masked, which is also what an absent block means.
1151+
privacy: z.object({ maskEmails: z.boolean().optional() }).strict().optional().catch(undefined),
11491152
// A malformed present client block must remain diagnosable from raw config and
11501153
// fail closed through src/client/state.ts; unrelated provider state still loads.
11511154
client: clientConnectionSchema.optional().catch(undefined),
Collapse file

‎src/lib/privacy.ts‎

Copy file name to clipboardExpand all lines: src/lib/privacy.ts
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@ export function maskEmail(value: string | null | undefined): string | null {
1010
return `${local[0]}***${local[local.length - 1]}@${domain}`;
1111
}
1212

13+
/**
14+
* Whether stored account emails are masked in management and CLI projections (#3859).
15+
*
16+
* Fail closed on every ambiguity: a missing config, a missing `privacy` block, and a missing or
17+
* malformed `maskEmails` all mask. Only the literal boolean `false` unmasks, so a hand-edited
18+
* `"false"` string or a typo cannot silently disclose an address. Callers read this once at the
19+
* request boundary and pass the answer down — the projection helpers take a boolean rather than
20+
* a config so that `getLoginStatus` stays free of config I/O.
21+
*/
22+
export function emailMaskingEnabled(config: { privacy?: { maskEmails?: boolean } } | null | undefined): boolean {
23+
return config?.privacy?.maskEmails !== false;
24+
}
25+
26+
/**
27+
* Project a stored account email for a surface outside the proxy (#3859).
28+
*
29+
* One redaction decision for every call site, rather than each one forking on the flag: an
30+
* unmasked projection still normalises an empty or absent address to `null`, so a consumer's
31+
* "is there an email" test cannot start answering differently just because masking is off.
32+
*/
33+
export function projectEmail(value: string | null | undefined, mask: boolean): string | null {
34+
if (!mask) return value ? value : null;
35+
return maskEmail(value);
36+
}
37+
1338
export function maskAccountId(value: string | null | undefined): string | null {
1439
if (!value) return null;
1540
const id = value.trim();
Collapse file

‎src/oauth/index.ts‎

Copy file name to clipboardExpand all lines: src/oauth/index.ts
+18-7Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { parseCallbackInput } from "./callback-server";
44
import type { OcxConfig, OcxProviderConfig, RefreshPolicy } from "../types";
55
import { ConfigMutationLockError, loadConfig, mutatePersistedConfig, saveConfig } from "../config";
66
import { resolveProviderApiKey } from "../providers/key-store";
7-
import { maskEmail } from "../lib/privacy";
7+
import { projectEmail } from "../lib/privacy";
88
import { KiroTokenRefreshError, environmentKiroRoutingMetadata, loginKiro, refreshKiroToken, settleKiroLoginTransaction } from "./kiro";
99
import {
1010
OAuthMutationBusyError,
@@ -1805,14 +1805,22 @@ export interface OAuthAccountSummary {
18051805
plan: string | null;
18061806
}
18071807

1808-
export function getLoginStatus(provider: string): { loggedIn: boolean; email?: string; source?: OAuthCredentials["source"]; error?: string; done: boolean; activeAccountId?: string; accounts?: OAuthAccountSummary[] } {
1808+
/**
1809+
* Token-safe login state for one provider.
1810+
*
1811+
* `maskEmails` is an explicit boolean rather than a config read (#3859). This module must not
1812+
* acquire a dependency on config I/O to answer a redaction question: the caller already holds
1813+
* the config at its request boundary and resolves the policy there with `emailMaskingEnabled`.
1814+
* The default masks, so every existing caller keeps today's behaviour.
1815+
*/
1816+
export function getLoginStatus(provider: string, maskEmails = true): { loggedIn: boolean; email?: string; source?: OAuthCredentials["source"]; error?: string; done: boolean; activeAccountId?: string; accounts?: OAuthAccountSummary[] } {
18091817
const cred = getCredential(provider);
18101818
const st = loginState.get(provider);
18111819
const set = getAccountSet(provider);
18121820
const accounts: OAuthAccountSummary[] | undefined = set?.accounts.map(a => ({
18131821
id: a.id,
18141822
...(a.alias ? { alias: a.alias } : {}),
1815-
email: maskEmail(a.credential.email) ?? undefined,
1823+
email: projectEmail(a.credential.email, maskEmails) ?? undefined,
18161824
active: a.id === set.activeAccountId,
18171825
...(a.needsReauth ? { needsReauth: true } : {}),
18181826
expiresAt: a.credential.expires,
@@ -1832,18 +1840,21 @@ export function getLoginStatus(provider: string): { loggedIn: boolean; email?: s
18321840
.find(a => a.id === set.activeAccountId)?.needsReauth === true;
18331841
return {
18341842
loggedIn: !!cred && !activeNeedsReauth,
1835-
email: maskEmail(cred?.email) ?? undefined,
1843+
email: projectEmail(cred?.email, maskEmails) ?? undefined,
18361844
source: cred?.source,
18371845
error: st?.error,
18381846
done: st?.done ?? false,
18391847
...(set ? { activeAccountId: set.activeAccountId, accounts } : {}),
18401848
};
18411849
}
18421850

1843-
/** Token-safe per-provider login state for the CLI `ocx status` logins section (no tokens, masked email). */
1844-
export function oauthLoginSummary(): Array<{ provider: string; loggedIn: boolean; email?: string }> {
1851+
/**
1852+
* Token-safe per-provider login state for the CLI `ocx status` logins section. Never tokens; the
1853+
* email follows the operator's `privacy.maskEmails` policy, masked by default (#3859).
1854+
*/
1855+
export function oauthLoginSummary(maskEmails = true): Array<{ provider: string; loggedIn: boolean; email?: string }> {
18451856
return listOAuthProviders().map(provider => {
1846-
const status = getLoginStatus(provider);
1857+
const status = getLoginStatus(provider, maskEmails);
18471858
return { provider, loggedIn: status.loggedIn, ...(status.email ? { email: status.email } : {}) };
18481859
});
18491860
}
Collapse file

‎src/server/management/oauth-account-routes.ts‎

Copy file name to clipboardExpand all lines: src/server/management/oauth-account-routes.ts
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from "../../oauth";
2626
import { OAuthMutationBusyError, removeCredential } from "../../oauth/store";
2727
import { providerDestinationResolvedError } from "../../lib/destination-policy";
28+
import { emailMaskingEnabled } from "../../lib/privacy";
2829
import { reconcileLiveStateStores } from "../../lib/state-store-registrations";
2930
import { enrichProviderFromCatalog, listKeyLoginProviders } from "../../oauth/key-providers";
3031
import { deriveProviderPresets } from "../../providers/derive";
@@ -233,7 +234,10 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
233234
if (url.pathname === "/api/oauth/status" && req.method === "GET") {
234235
const provider = (url.searchParams.get("provider") ?? "").trim().toLowerCase();
235236
if (!isPublicOAuthProvider(provider)) return jsonResponse({ error: "unknown oauth provider" }, 400);
236-
const status = getLoginStatus(provider);
237+
// Resolved here, at the request boundary that already holds the config, and passed down.
238+
// getLoginStatus stays free of config I/O. This route does not re-mask afterwards: it
239+
// consumes the already-projected status rather than redacting a second time.
240+
const status = getLoginStatus(provider, emailMaskingEnabled(config));
237241
return jsonResponse(status);
238242
}
239243

@@ -269,7 +273,7 @@ export async function handleOauthAccountRoutes(ctx: ManagementContext): Promise<
269273
} = await import("../../oauth/health");
270274
const projectAccounts = () => {
271275
const set = getAccountSet(provider);
272-
const current = getLoginStatus(provider);
276+
const current = getLoginStatus(provider, emailMaskingEnabled(config));
273277
return {
274278
activeAccountId: current.activeAccountId ?? null,
275279
accounts: (current.accounts ?? []).map(summary => {
Collapse file

‎src/types/config.ts‎

Copy file name to clipboardExpand all lines: src/types/config.ts
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,26 @@ export interface OcxRemoteGuiConfig {
288288

289289
export type OcxConnectedClientId = "codex" | "claude";
290290

291+
/**
292+
* Redaction policy for management and CLI projections (#3859).
293+
*
294+
* `privacy` rather than `dashboard`: `ocx status` and `ocx account` are not the dashboard, and
295+
* they read the same projections.
296+
*/
297+
export interface OcxPrivacyConfig {
298+
/**
299+
* Mask stored account emails before they leave the proxy. Omitted or `true` is the historical
300+
* behaviour and the default.
301+
*
302+
* Setting this to `false` is a real disclosure decision, not a display preference. Management
303+
* is not always loopback — under `remoteGui` the unmasked address reaches every management
304+
* principal that can reach the hub, not only someone sitting at the machine. The default
305+
* therefore stays masked, and turning it off is an explicit opt-in by the operator who owns
306+
* those accounts.
307+
*/
308+
maskEmails?: boolean;
309+
}
310+
291311
export interface OcxClientConnectionConfig {
292312
serverUrl: string;
293313
managementUrl: string;
@@ -335,6 +355,8 @@ export interface OcxConfig {
335355
remoteGui?: OcxRemoteGuiConfig;
336356
/** Remote-hub client state. The admission secret is stored only in service-api-token. */
337357
client?: OcxClientConnectionConfig;
358+
/** Operator-facing redaction policy for management and CLI projections. */
359+
privacy?: OcxPrivacyConfig;
338360
/** Opt in to one identical-turn retry when a Responses completion has no text or tool call. */
339361
emptyCompletionRetry?: boolean;
340362
/**

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.