Why Deleting Accounts Fails to Revoke AI Keys: The Offboarding Credential Gap
This article explains why standard employee offboarding processes often fail to revoke AI API keys stored locally, detailing four credential layers, risks of shared keys, a five-step revocation process, and architectural solutions like centralized AI gateways to ensure complete access removal.
The article opens with a direct answer: when an employee leaves, the AI API keys on their computer may still be valid. Standard offboarding — disabling email, reclaiming badges, closing Feishu/DingTalk/WeCom accounts, removing from internal directories — only revokes the organizational login identity. It does not automatically invalidate static API keys that the employee saved in environment variables, .env files, Codex or other coding tool configs, shell history, local scripts, CI pipelines, or temporary code snippets.
Four Credential Layers with Different Lifecycles
The author identifies four distinct credential layers that employees interact with when using AI:
Organizational login identity (e.g., SSO via Feishu, DingTalk, WeCom OAuth). This answers "who is this person?" Revoking the user in the identity source (and syncing to TokenHub) blocks new logins.
Login session/token issued after authentication. This answers "is this person already authenticated?" Existing sessions must be explicitly revoked; otherwise browsers may retain access for a while.
Internal project API keys . These answer "does the holder have a credential to call this project?" If a key was copied to a local machine, deleting the user account does not change the key's validity.
Upstream model provider accounts, API keys, or OAuth tokens (OpenAI, Anthropic, etc.). This is the highest-risk layer. If employees directly hold provider credentials, the company must log into each provider console to rotate passwords, revoke tokens, and audit usage.
These four layers have independent lifecycles. Deleting a user in SSO only addresses layer one; complete offboarding must also handle sessions, project keys, and upstream credentials.
Shared Keys Create Blind Spots
Many teams initially share a single key across developers, testers, product managers, and contractors. This speeds adoption but makes offboarding painful: administrators cannot confirm whether a departing employee saved the key, nor which systems still depend on it. Revoking the key breaks the whole team; keeping it leaves access unproven. Moreover, logs only show "project made a call" — they cannot distinguish between a current employee, a departed one, or an abandoned automation script. Shared keys defer management cost to the moment of personnel change or security incident.
Post-Departure Automated Consumption
After departure, AI requests may not be initiated by the person. The employee's terminal may retain environment variables; a local agent task may still run; a personal cron job may hold the key; a repository, CI job, or test server configured by them may continue using the credential. Such calls can generate small daily token amounts hidden in normal bills, or suddenly spike if an agent loops, revealing the credential was never revoked.
Therefore offboarding checks must go beyond "can they log in?" and ask: Can their keys still complete a model request? Are their automation tasks still running? Did their recent usage show anomalies? Were keys committed to repos or shared? Are requests still originating from their devices, IPs, or User-Agents after departure?
Five-Step Offboarding Process
Step 1: Disable Identity
Deactivate the employee in the corporate identity provider (Feishu, DingTalk, WeCom OAuth). Synced TokenHub login identities become invalid. For local or non-synced accounts, disable/delete the user in TokenHub and remove from teams/projects.
Step 2: Revoke Existing Sessions
Revoke all console sessions issued to the user so browsers and other logged-in terminals cannot continue operating on old sessions.
Step 3: Inventory and Handle Keys
List project keys the employee used and determine if they are shared with other members, applications, or automation. Personal keys can be revoked immediately; shared keys require dependency confirmation before rotation. New keys are distributed via approved secret management; old keys get a short grace period then expire. If unsure whether a key reached the departing employee, treat it as exposed.
Step 4: Check Upstream Accounts and Automation
Verify whether the employee ever held model provider accounts, API keys, OAuth tokens, or recovery credentials. Also inspect CI pipelines, scheduled tasks, agents, test servers, and local profiles they created. Tasks to keep must be reassigned with updated credentials; unused tasks stopped immediately.
Step 5: Audit Recent Call Logs
Review logs for the employee's projects and keys around the departure date: last use time, request volume, tokens, source IP, User-Agent, model, errors. If calls appear post-departure, determine if they are from unmigrated legitimate tasks or unauthorized access, then decide whether to expand investigation. This step validates whether the offboarding process actually worked.
Architectural Fix: Centralize Upstream Credentials in an AI Gateway
The root cause of difficult offboarding is flawed credential hierarchy. If every employee holds provider accounts/keys, each personnel change forces repeated external platform operations. Better: store upstream provider accounts and keys centrally in an enterprise AI gateway. Employees only use company-issued project keys, never touching provider passwords or OAuth tokens. Provider changes are handled once by admins; employee departure doesn't require touching the model accounts. This brings externally scattered credential problems back under unified internal control.
Stop Issuing One Long-Lived Key per Department
Split keys by purpose: personal development, project application, CI automation, production, testing. Each key gets a clear name, owner, allowed models, daily/monthly request limits, token/cost budgets, max concurrency, source IP restrictions, and expiry. More keys reduce blast radius: revoking one departing employee's key doesn't affect others; closing a test environment only disables its key; anomalies are quickly traced to a specific task. Security comes from clear boundaries, single purpose, traceability, and independent revocability — not from minimizing key count.
How TokenHub Implements Controllable Offboarding
TokenHub separates identity, project permissions, and model access credentials into layers:
Identity layer : Supports enterprise SSO and generic OAuth/OIDC with built-in Feishu, DingTalk, WeCom templates. When an employee is deactivated in the org, synced TokenHub login identities automatically expire. No separate AI platform offboarding list needed. RBAC distinguishes regular users, team leads, platform admins. For local/non-synced accounts, admins can disable/delete users, revoke console sessions, and audit team/project memberships.
Credential layer : Central view of project keys; create independent credentials per member, app, environment. Keys can restrict models, daily/monthly requests, tokens, cost, concurrency, source IP, expiry, and support revocation/rotation.
Upstream layer : Provider accounts, API keys, subscriptions managed centrally by admins. Regular employees never see upstream credentials; personnel changes don't force redistribution of provider accounts.
Audit layer : Logs every request with project, key, model, provider resource, tokens, status, source IP, User-Agent. Also records admin actions: user deletion, permission changes, key revocation, policy adjustments.
Important: deleting a TokenHub user does not automatically invalidate static project keys already copied to an employee's machine. The platform makes keys centrally visible, restrictable, traceable, and revocable — it does not pretend a "delete user" button overrides the independent lifecycle of static credentials.
Validation Test: The "Laptop Still Works?" Check
A simple acceptance criterion for AI access revocation: Assume the departed employee still has all their laptop configs — can they still complete a model call? If the answer is "maybe yes," offboarding is incomplete. True completion means:
Corporate identity synced and invalid, no new login possible.
Old console sessions revoked.
Team/project permissions removed.
Employee's keys revoked or rotated.
Upstream accounts not in employee's possession.
Leftover automation stopped or credentials migrated.
Pre/post-departure call logs reviewed.
Only then can the company confidently say the person has left the organization and their AI call capability is gone.
AI Era: Offboarding Must Revoke Model Call Capability, Not Just Accounts
Traditionally offboarding recovered email, VPN, code repos, business system accounts. In the AI era, companies must also recover a new production capability: model access. A still-valid AI key represents not just potential ongoing cost, but access to approved models, consumption of project budgets, and camouflage within normal call logs. The question at departure shouldn't be "did we delete the account?" but "is the AI key on their laptop truly unusable?" If the answer is uncertain, a unified AI identity, credential, and audit platform is needed. TokenHub addresses this problem; it is open-source under Apache 2.0 and supports private deployment. GitHub: https://github.com/astaxie/TokenHub
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
