gating-sensitive-actions
БесплатноБез исполняемых скриптовНе проверенUse when deciding whether an endpoint, settings section, or UI flow should require recent authentication (re-auth), when adding…
от PostHog★ 41 278 звёзд на GitHubОб этом скилле
Gating sensitive actions behind re-authentication
A session cookie that is older than SESSION_SENSITIVE_ACTIONS_AGE (2 hours by default) can still read everything, but it cannot do sensitive writes until the user re-authenticates.
This skill says which writes count as sensitive, where the gate goes, and how the UI recovers when a write is refused.
The decision
These rules are settled. Do not reopen them in a feature PR.
- Reads stay open. Opening a page or loading a list never asks for re-auth. Only an action that changes something sensitive does.
- The backend enforces the gate. A frontend-only gate protects nothing, because anyone with the cookie can call the API directly. If an action is sensitive, its endpoint carries
TimeSensitiveActionPermission. Adding a frontend gate instead of this is wrong. - The frontend reacts, and does not gate up front. A write that fails with
sensitive_action_required_reauthopens the re-auth modal. After the user re-authenticates, the same request is sent again. The user does not repeat the action. - Organization settings are the exception. The whole organization level of settings is wrapped in
TimeSensitiveAuthenticationArea, so it prompts on navigation. Keep it like that. - User, project, and environment settings never prompt on navigation. There is no per-section opt-in. If reading a section feels sensitive, the fix is to stop the read from returning the secret (see below), not to gate the page.
- A GET never returns a live secret that already exists. Return a secret only in the response that creates it: new personal API keys, rolled keys, new backup codes. A later read returns metadata, a masked value, or a count.
two_factor_statusreturnsbackup_codes_remaining, not the codes.
What counts as sensitive
Gate a write when it does one of these:
- It changes how someone signs in or proves who they are: password, email, 2FA, passkeys, backup codes.
- It creates, rolls, or revokes a credential: personal API keys, project secret API keys, OAuth connected apps, personal integrations (GitHub, Slack), personal PostHog connections.
- It ends sessions or deletes the account.
- It changes who can act as the user, or what data is collected about them: allow impersonation, data opt-out.
- It changes organization membership, roles, domains, SSO, or invites.
Do not gate UI preferences and bookkeeping: theme, sidebar layout, navigation items, homepage, current team or organization, product intro flags, hedgehog config, cache refreshes such as github_repos_refresh.
Exempt these explicitly, as described in the next section.
Backend: adding the gate
TimeSensitiveActionPermission is in posthog/permissions.py. Read it before you change anything. The behavior to know:
- It applies only to
SessionAuthentication. Personal API keys and OAuth tokens always pass. The desktop app and MCP are therefore not affected. - Safe methods (GET, HEAD, OPTIONS) always pass.
- If
step_up_required(request.session)is set, every write is refused and the exemption lists do not apply. - The default permission is only
IsAuthenticated. No mixin adds this permission, so a viewset is protected only when it listsTimeSensitiveActionPermissioninpermission_classes, or on the action.
Add the permission to the viewset permission_classes, then exempt the non-sensitive writes:
| Attribute | Use it for |
|---|---|
time_sensitive_allow_if_only_fields |
A write where every submitted field is a preference (see UserViewSet). A pending step-up still blocks it. |
time_sensitive_allow_actions |
Named actions that skip the freshness window. A pending step-up still blocks them. |
time_sensitive_exclude_actions |
Named actions that are never sensitive. They skip the step-up check too, so use this only for bookkeeping. |
References: posthog/api/user.py (UserViewSet), posthog/api/personal_api_key.py, posthog/api/webauthn.py, posthog/api/oauth/connected_apps.py, posthog/api/user_integration.py.
When one viewset serves both personal credentials and team-shared records, gate only the personal ones. PersonalConnectionRecentAuthPermission in posthog/api/integration.py gates posthog connections and leaves team integrations as they were.
If a read returns a secret, change the response to a count or a masked value. Do not gate the read. Update the serializer, run hogli build:openapi, and change the frontend to show the secret only from the create response.
Frontend: what happens on a refused write
handleFetchinfrontend/src/lib/api.tssees the 403 withsensitive_action_required_reauthand calls `awaitReauthenticat
Установить gating-sensitive-actions в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл gating-sensitive-actions?
Use when deciding whether an endpoint, settings section, or UI flow should require recent authentication (re-auth), when adding `TimeSensitiveActionPermission` or its exemptions (`time_sensitive_allow_if_only_fields`, `time_sensitive_exclude_actions`, `time_sensitive_allow_actions`), when wrapping a page or settings section in `TimeSensitiveAuthenticationArea`, when an API read returns secret material, or when a write fails with `sensitive_action_required_reauth`. Carries the product decision: reads stay open, only sensitive writes need a fresh session, and the backend enforces it; organization settings are the one area gated on navigation. Covers how the frontend opens the re-auth modal and retries the failed request, and how to test a new gate. Trigger terms: re-auth, reauthenticate, reauthentication, sensitive session, fresh session, sudo mode, step-up, TimeSensitiveActionPermission, TimeSensitiveAuthenticationArea, sensitive_action_required_reauth.
Как установить скилл gating-sensitive-actions?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл gating-sensitive-actions запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic