Skip to content

CLI

dagster_authkit.cli.main

Dagster AuthKit CLI Entry Point - v1.0

Main orchestrator that: 1. Intercepts management commands (user, init-db, etc.) 2. Performs environment & compatibility checks. 3. Applies authentication monkey-patches. 4. Delegates execution to the official Dagster webserver CLI.

main

main()

Primary entry point for dagster-authkit.

Orchestrates the full startup sequence:

  1. Initialise structured logging.
  2. Intercept management commands (add-user, list-users, etc.) and delegate to cli_tools.handle_user_management().
  3. Print startup banner and configuration summary.
  4. Verify Dagster API compatibility (exits on failure).
  5. Apply monkey-patches to DagsterWebserver (middleware, routes, UI). Verify patches were applied successfully.
  6. Bootstrap the SQL backend if configured (create tables, admin user).
  7. Delegate normal webserver invocation to Dagster's own CLI (dagster_webserver.cli.main or legacy dagit.cli.main).
  8. Trap SystemExit for user-friendly error messages on missing args.

This function calls sys.exit(); it does not return normally.

dagster_authkit.cli.cli_tools

CLI tools for managing users in SQL databases via Peewee. Supports unified SQL backends (SQLite, PostgreSQL, MySQL).

init_db_command

init_db_command(args)

Initialise a new database and create necessary tables.

Parameters:

Name Type Description Default
args

argparse.Namespace with optional db_path and with_admin flag.

required

Returns:

Type Description

0 on success, 1 on failure.

add_user_command

add_user_command(args)

Add a new user to the SQL database.

Parameters:

Name Type Description Default
args

argparse.Namespace with username and optional password, email, full_name, db_path, and role flags (--admin, --editor, --launcher).

required

Returns:

Type Description

0 on success, 1 on failure (user may already exist).

change_password_command

change_password_command(args)

Update a user's password and revoke all their active sessions.

Parameters:

Name Type Description Default
args

argparse.Namespace with username and optional password, db_path.

required

Returns:

Type Description

0 on success, 1 if user not found.

list_users_command

list_users_command(args)

List all registered users from the SQL database.

Parameters:

Name Type Description Default
args

argparse.Namespace with optional db_path.

required

Returns:

Type Description

0 always (lists users or prints "No users found").

delete_user_command

delete_user_command(args)

Deactivate a user (soft delete) — sets is_active=False.

Parameters:

Name Type Description Default
args

argparse.Namespace with username and optional --yes flag to skip confirmation, db_path.

required

Returns:

Type Description

0 on success (or cancellation), 1 if user not found.

list_permissions_command

list_permissions_command(args)

Display the full RBAC permissions matrix for all roles.

Parameters:

Name Type Description Default
args

Unused (for CLI dispatch consistency).

required

Returns:

Type Description

0 always.