Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ROLE_ADOPTION_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ The lockout-safe order proven on retiregolden.org, transplanted:

## Phase 4 — retire the allowlist

- [ ] Delete the allowlist path whole (`SUPPORT_STAFF_EMAILS` /
- [x] Delete the allowlist path whole (`SUPPORT_STAFF_EMAILS` /
`SUPPORT_STAFF_PRINCIPALS` parsing and the legacy staff context) — it
must not survive as a quiet second gate. After this, a role-store
failure is a controlled **503, fail closed, no fallback**.
- [ ] Delete the env vars from the Worker configuration and update
- [x] Delete the env vars from the Worker configuration and update
`SUPPORT_COMPOSITION.md`'s staff section to role-only.

## Phase 5 — the shared admin surface (GATED)
Expand Down
17 changes: 9 additions & 8 deletions docs/SUPPORT_COMPOSITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ nothing was granted because `Support` was already held through another
assignment — so a later revocation stays revoked while the env var lingers.
Delete the var once the first operator holds the role.

**Legacy allowlist (Phase 4 deletes it).** `SUPPORT_STAFF_EMAILS` /
`SUPPORT_STAFF_PRINCIPALS` are still honored beside the role path during the
lockout-safe retirement order; if the role store errors, the gate logs and
falls through to the allowlist. Parsing and the legacy resolver are deleted
whole in Phase 4 once the live bootstrap seed is confirmed.
**Fail-closed posture.** The role store is the only gate: a host wired
without one answers staff routes with **503** `support_not_configured`, and a
role-store failure is **503** `service_unavailable` — never a quiet allow or
a misleading 403. The former `SUPPORT_STAFF_EMAILS` /
`SUPPORT_STAFF_PRINCIPALS` allowlist was deleted whole in Phase 4 of
`docs/ROLE_ADOPTION_PLAN.md`.

`principalId` is always the Identity principal / account id from the
server-side session (`__Host-pegma_session`). Browser-supplied identity fields
Expand Down Expand Up @@ -153,7 +154,7 @@ Durable rate-limit policies (separate from Identity):
| --- | --- |
| `/feedback` | Customer create + list |
| `/feedback/ticket/?id=…` | Customer read + reply |
| `/staff/support` | Staff queue (allowlisted operators) |
| `/staff/support` | Staff queue (Support role holders) |
| `/staff/support/ticket/?id=…` | Staff ticket detail, compose, lifecycle |

## Maintenance and health
Expand All @@ -172,8 +173,8 @@ store probe runs only when `SUPPORT_HEALTH_PROBE` is exactly `"true"`.
authorized operators.
- Feedback is not automatically published to the roadmap, documentation, or
GitHub Issues.
- The staff surface is only for allowlisted operators (env allowlist). It is
not a shared control plane with other hosts.
- The staff surface is only for operators holding the stored Support role.
It is not a shared control plane with other hosts.
- Staff ticket views may include requester email after staff authz; customer
endpoints never gain staff fields.
- Internal notes must never appear on customer reads.
Expand Down
10 changes: 5 additions & 5 deletions src/pages/staff/support.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import Base from '../../layouts/Base.astro';

<Base
title="Staff support queue — Pegma"
description="Operator queue for pegma.dev product feedback. Allowlisted staff only."
description="Operator queue for pegma.dev product feedback. Support role required."
>
<section class="account-hero">
<p class="eyebrow">Staff · Support Desk</p>
<h1>Support queue</h1>
<p class="lede">
Review and act on product feedback tickets. Access is limited to operators
listed in the host staff allowlist — this is not a public control plane.
Review and act on product feedback tickets. Access requires the stored
Support operator role — this is not a public control plane.
Comment thread
FlyOverCoderKY marked this conversation as resolved.
Resolved
</p>
</section>

Expand All @@ -30,8 +30,8 @@ import Base from '../../layouts/Base.astro';
<section id="staff-queue-forbidden" class="account-panel" hidden>
<h2>You do not have staff access</h2>
<p>
This surface is only available to allowlisted operators. If you expected
access, contact an administrator.
This surface is only available to operators holding the Support role. If
you expected access, contact an administrator.
</p>
<p>
<a href="/account">Account</a>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/staff/support/ticket.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Base from '../../../layouts/Base.astro';

<Base
title="Staff ticket — Pegma"
description="Operator view of a pegma.dev support ticket. Allowlisted staff only."
description="Operator view of a pegma.dev support ticket. Support role required."
>
<section class="account-hero">
<p class="eyebrow">Staff · Ticket</p>
Expand All @@ -30,7 +30,7 @@ import Base from '../../../layouts/Base.astro';
<section id="staff-ticket-forbidden" class="account-panel" hidden>
<h2>You do not have staff access</h2>
<p>
This surface is only available to allowlisted operators.
This surface is only available to operators holding the Support role.
</p>
<p>
<a href="/account">Account</a>
Expand Down
5 changes: 1 addition & 4 deletions worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
import { handleGetReleases, readReleasesConfig } from './releases-api';
import { parseBootstrapPrincipals } from './role-bootstrap';
import { createSupportApi } from './support-api';
import { parseStaffAllowlist } from './support-access';
import {
createProductionSupportRuntime,
probeSupportStore,
Expand Down Expand Up @@ -59,12 +58,10 @@ function createSupportHandler(env: AppEnv, logger: ReturnType<typeof createAppLo
createLimiter: supportRuntime.createLimiter,
replyLimiter: supportRuntime.replyLimiter,
logger,
// The Support ROLE is the real staff gate; the allowlist is the legacy
// path until Phase 4 of docs/ROLE_ADOPTION_PLAN.md deletes it.
// The stored Support ROLE is the only staff gate (fail closed).
roleStore: supportRuntime.roleStore,
bootstrapMarkers: supportRuntime.bootstrapMarkers,
bootstrapPrincipals: parseBootstrapPrincipals(env),
staffAllowlist: parseStaffAllowlist(env),
});
return { supportRuntime, api };
}
Expand Down
83 changes: 0 additions & 83 deletions worker/src/support-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,56 +71,6 @@ export type SupportRoleReader = Pick<
'listActiveRoleAssignments'
>;

/** Parsed host allowlists for Support Desk staff operators. */
export interface StaffAllowlist {
/** Lowercased verified emails. */
readonly emails: ReadonlySet<string>;
/** Identity principal / subject ids. */
readonly principals: ReadonlySet<string>;
}

const EMPTY_STAFF_ALLOWLIST: StaffAllowlist = Object.freeze({
emails: Object.freeze(new Set<string>()),
principals: Object.freeze(new Set<string>()),
});

function parseCommaList(value: string | undefined): string[] {
if (value === undefined || value.trim() === '') {
return [];
}
return value
.split(',')
.map((part) => part.trim())
.filter((part) => part.length > 0);
}

/**
* Parse `SUPPORT_STAFF_EMAILS` and `SUPPORT_STAFF_PRINCIPALS` from host env.
*
* Emails are lowercased for case-insensitive comparison. Principal ids are
* kept as-is (trimmed). Empty or missing env → empty allowlist (no staff).
*/
export function parseStaffAllowlist(env: {
readonly SUPPORT_STAFF_EMAILS?: string;
readonly SUPPORT_STAFF_PRINCIPALS?: string;
}): StaffAllowlist {
const emails = new Set(
parseCommaList(env.SUPPORT_STAFF_EMAILS).map((email) =>
email.toLowerCase(),
),
);
const principals = new Set(parseCommaList(env.SUPPORT_STAFF_PRINCIPALS));
return Object.freeze({
emails: Object.freeze(emails),
principals: Object.freeze(principals),
});
}

/** Empty allowlist for hosts/tests that inject staff later. */
export function emptyStaffAllowlist(): StaffAllowlist {
return EMPTY_STAFF_ALLOWLIST;
}

/**
* Resolve an AccessContext for an authenticated Identity principal.
*
Expand Down Expand Up @@ -160,36 +110,3 @@ export async function staffAccessContextFromRoles(
: null;
}

/**
* LEGACY staff AccessContext from the host env allowlist — honored beside
* the role path during the lockout-safe retirement order
* (docs/ROLE_ADOPTION_PLAN.md Phases 2–4), then deleted whole.
*
* A principal is staff only when authenticated **and** (principal id is in
* `SUPPORT_STAFF_PRINCIPALS` **or** verified user email is in
* `SUPPORT_STAFF_EMAILS`). Returns `null` when not staff — callers map that
* to HTTP 403 `forbidden` (not 404).
*/
export function staffAccessContext(
principalId: PrincipalId,
allowlist: StaffAllowlist,
userEmail?: string,
): AccessContext | null {
const principalAllowed = allowlist.principals.has(principalId);
const emailAllowed =
userEmail !== undefined &&
userEmail.trim() !== '' &&
allowlist.emails.has(userEmail.trim().toLowerCase());
if (!principalAllowed && !emailAllowed) {
return null;
}
const context = resolveAccess(
{ principalId, roles: [SUPPORT_ROLE] },
PEGMA_ACCESS_POLICY,
);
// Same permission proof as the role path: allowlisting alone never
// outranks what the policy actually grants.
return hasPermission(context, supportPermissions.queueRead)
? context
: null;
}
Loading