Skip to content

Templates

dagster_authkit.utils.templates

HTML Templates - Centralized UI Components All HTML/CSS/JS strings for AuthKit interface.

render_login_page

render_login_page(next_url='/', error='', csrf_token='')

Render the Dagster AuthKit login page.

Produces a self-contained HTML document styled with the Dagster design system (Geist Sans font, CSS custom properties, dark mode). All user-supplied values are HTML-escaped before interpolation.

Parameters:

Name Type Description Default
next_url str

Redirect destination after successful login.

'/'
error str

Optional error message displayed above the form.

''
csrf_token str

Signed CSRF token injected as a hidden form field.

''

Returns:

Type Description
str

Complete HTML string (<!DOCTYPE html> to </html>).

render_403_page

render_403_page(user, path, method, reason)

Render a 403 Forbidden error page.

Displays the user's identity, role, the blocked request details, and the reason for denial. All values are HTML-escaped.

Parameters:

Name Type Description Default
user

AuthUser instance (must have .username, .role attributes).

required
path str

Requested URL path that was blocked.

required
method str

HTTP method of the blocked request.

required
reason str

Human-readable RBAC denial reason.

required

Returns:

Type Description
str

Complete HTML string.

render_user_menu_injection

render_user_menu_injection(user_data_json, debug, safe_mode)

Render the client-side JavaScript that injects the AuthKit user profile menu into the Dagster UI sidebar.

Uses resilient retry logic with multiple CSS selector fallbacks for cross-version Dagster compatibility. When the sidebar cannot be located, an optional safe-mode corner menu is rendered.

Parameters:

Name Type Description Default
user_data_json str

JSON-serialized user object (XSS-escaped by caller).

required
debug bool

Enable verbose client-side console logging.

required
safe_mode bool

Activate safe-mode corner menu on injection failure.

required

Returns:

Type Description
str

String containing <style> and <script> blocks.