Skip to main content

tungsten-impersonate

"Log in as" plugin for Tungsten, the admin panel for FastAPI. An admin logs in as any user to see exactly what they see. Made for support, and safe by default.

What you get

  • A Log in as button on your users list and user pages, and a Log in as a user picker.
  • An orange bar on every page while you are someone else, with Back to my account and the minutes left.
  • Time limit: you go back to your own account after 60 minutes.
  • Impersonation log: who logged in as whom, when, why, for how long, from which IP and browser.
  • Safety rules: only allowed admins; never as yourself, a super admin, an inactive user or a user with more access than you; no "log in as" from inside another account.
  • Links with other plugins when installed: HR employees with a login, help desk ticket customers, and three security audit checks.

Install

pip install tungsten-impersonate
from tungsten_impersonate import ImpersonatePlugin

panel.plugin(ImpersonatePlugin())
panel.create_tables(engine)   # creates the impersonation log table

With roles, give the Log in as other users permission only to your support admins. Without roles every panel user may use it.

Options

ImpersonatePlugin(
    can_impersonate=None,       # fn(user, ctx) -> bool
    can_be_impersonated=None,   # fn(user, target, ctx) -> bool
    no_more_access=True,        # never become a user with permissions you don't have
    max_minutes=60,             # 0: no limit
    require_reason=False,       # ask "Why?" first
    redirect_to=None,           # page to open as the user
    users=True, link_plugins=True, banner=True, log_resource=True,
    on_start=None, on_end=None,
)

The buttons on your users list and other plugins' screens use panel.record_action() from the tungsten-admin release after 0.1.7. On 0.1.7 add plugin.action() to your users table yourself; the log screen's picker works everywhere.

Docs: https://tungsten.prisminfoways.com/docs/impersonate

Try it

pip install -e . -e plugins/impersonate uvicorn
uvicorn plugins.impersonate.example:app --reload     # from the repo root

Sign in as admin@example.com / password, open Users and press Log in as on a row.

Tests

pip install -e ".[dev]" -e plugins/impersonate -e plugins/hr -e plugins/tickets -e plugins/security-audit
pytest plugins/impersonate/tests

Metadata

Release files for tungsten-impersonate 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tungsten-impersonate 0.1.0
File Size Uploaded
tungsten_impersonate-0.1.0.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tungsten-impersonate 0.1.0
File Interpreter ABI Platform
tungsten_impersonate-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.7 kB

Release files / tungsten_impersonate-0.1.0.tar.gz

Download URL tungsten_impersonate-0.1.0.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5942849f1ac1d7750236dafd211c65be1ece0ba887a6945142a0e5003c6f1b67
BLAKE2b-256 checksum
How to use checksums
610d005ee41a94e73a136e46dee7470cdc6dec4107e2ddbecb50eb02aadb9d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tungsten_impersonate-0.1.0-py3-none-any.whl

Download URL tungsten_impersonate-0.1.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
871ea448a0c75455fda21841962efe81f654505c7705657c408a85611984206a
BLAKE2b-256 checksum
How to use checksums
5f8df3dc517cc53fa27a349057e3135d417d2bb2bcfd1431422696db8a5540ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page