Skip to content

Staff rule: a dupezero.com Google Workspace account becomes super admin #1401

Backlog

Description

@athvin

Why

DupeZero staff need the operator console (tenants, impersonation, the audit log) without anyone hand-granting is_super_admin in the database. The owner's rule is that a dupezero.com Google Workspace account is a super admin.

Super admin is the most powerful role in the product, so the check has to rest on something Google asserts about the organization, not on what the address looks like.

What the user sees

  • A staff member signs in with their @dupezero.com Google account and lands on /admin.
  • A former staff member whose Workspace account was suspended or removed can't sign in. Any session they already had expires within 12 hours.
  • Everyone else is unaffected.

How

  1. The staff test. All three must hold:

    • the ID token's hd claim equals ERWEB_STAFF_GOOGLE_DOMAIN (dupezero.com);
    • the email's domain equals the same value;
    • email_verified is true.

    A Gmail account has no hd, so it can never pass. An address that merely ends in @dupezero.com without hd doesn't pass either.

  2. First sign-in (the router's step 2 in First-sign-in router: join an existing workspace vs found a new one #1400):

    • Create the user with no password, is_super_admin = true and super_admin_source = google_domain.
    • Create the identity.
    • Call createSession and land on /admin.
  3. Every sign-in after that. Re-run the test in the callback.

    • If the user has super_admin_source = google_domain and no longer passes, set is_super_admin = false and clear the source. They land wherever their memberships take them, or on "no workspace".
    • A manual grant is never changed by this rule. That covers [email protected] today.
  4. Session lifetime. A session created through the staff path gets a 12-hour absolute expiry, with no sliding. frontend/src/lib/auth/session.ts currently gives every session a 30-day sliding expiry; add an absolute-expiry option and use it here.

    • This bounds how long a removed staff member keeps access, because Google won't tell us about offboarding.
  5. Audit. Write user.super_admin.granted and user.super_admin.revoked, with reason: google_domain.

  6. Copy. /admin shows a small line: "Signed in as staff through dupezero.com Google Workspace".

Acceptance criteria

These are mock-IdP tests:

  • hd=dupezero.com, an @dupezero.com email and verified: super admin, landing on /admin.
  • hd missing (Gmail): not staff. They take the normal router path.
  • hd=other.com: not staff.
  • An @dupezero.com email with no hd: not staff.
  • hd=dupezero.com with an email on another domain: not staff.
  • A user granted through google_domain who then signs in without hd loses /admin. It returns 404, the house rule.
  • A manual super admin is never demoted by this rule.
  • A staff session is refused 12 hours after creation, even with activity in between. Use a fake clock in a unit test.
  • Impersonation still works for a super admin granted by domain, and the impersonation banner still shows.
  • Grant and revoke both appear in the audit log.

Out of scope

  • Super admins on more than one domain.
  • Dropping [email protected], which keeps its password and its manual grant.

Depends on

#1398 (for super_admin_source), #1399 and #1400.

Where to start

  • frontend/src/lib/bff/admin.ts: requireSuperAdmin at L11-18.
  • frontend/src/lib/auth/session.ts L12-13, L71-76.
  • frontend/src/app/(admin)/admin/layout.tsx.

Estimate: 0.5 engineer-weeks.


Part of the E31 epic (#1396) (linked as parent). Decisions recorded 2026-11-28 with the owner.

Activity

  1. added
    post-mvp
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    post-mvp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions