dlboard

dlboard official documentation

View on GitHub

Auth

What is this

Who is making a request, and what they’re allowed to see and do. It’s split in three, and only the first part is a plugin:

Layer Owned by Answers
Authentication an AuthProvider plugin — swappable How does a person prove who they are?
API tokens core How does a training script prove who it is? (the same way under every provider)
Authorization core, always on What may this user see or change?

Built-in providers:

When you’d need this

How it works

Every request goes through one gate. install_request_gate (dlboard/serve/_backend/_auth.py) puts a before_request hook in front of every route: pages, Dash callbacks, REST, and /artifact/<id>. In order, it tries:

  1. an API token, Authorization: Bearer dlb_.... A token that doesn’t check out is a 401. It never falls back to another way of identifying the caller.
  2. a signed-in session cookie (only under a provider that verifies identity),
  3. the provider’s own authenticate().

Whoever that resolves to is bound to the request, and get_current_user() reads it back. Someone it can’t resolve is redirected to the provider’s login_url() if they’re a browser asking for a page. Anything else gets a 401. Only routes registered with add_public_route skip the gate.

Every store access is authorized. get_data_store()/get_artifact_store() return wrappers bound to the request’s user (dlboard/serve/_backend/_authorization.py), so no page, callback or REST handler can forget to check, and no storage backend has to know about users. Background work with no user behind it uses get_system_data_store() explicitly.

Access is per project. Experiments, runs, metrics, artifacts, views and notes inherit it from their project:

Role Can
viewer read everything, post notes, save personal views
editor + log runs/metrics/artifacts, create experiments, edit the shared layout, soft-delete within the project, keep a run, hold an experiment to a stricter retention rule
owner + manage members and sharing, rename or delete the project, set its retention rule, release or delete a kept run

A role comes from a grant to a user, a grant to an IdP group, or the project’s everyone_role (“everyone signed in can view/edit”). Whoever creates a project owns it. Something you can’t see reads as missing, exactly like something that doesn’t exist. Site-wide powers are Scopes on the user: restore, purge, the audit log, and user:manage. An admin (Scope.ALL) is an owner everywhere.

Under anonymous, grants aren’t enforced: everyone is an editor everywhere, and deleting still takes the scope it always has. The first user anonymous ever sees becomes the admin. A provider that verifies identity never does that; its admins come from configuration instead.

Hosting dlboard for other people (PASSWORD_AUTH)

# mydeployment.py
from dlboard.plugins import BUILTIN_BACKEND, BUILTIN_CHARTS, PASSWORD_AUTH, POSTGRES_S3_STORAGE, themes

PLUGINS = [*POSTGRES_S3_STORAGE, *PASSWORD_AUTH, *BUILTIN_BACKEND, *BUILTIN_CHARTS, themes.default]
export DLBOARD_SECRET_KEY=$(openssl rand -hex 32)   # signs sessions; the same for every worker
dlboard serve custom --plugins mydeployment:PLUGINS --host 0.0.0.0 --workers 4
dlboard users set-password alice --admin --plugins mydeployment:PLUGINS   # your first admin

Serve it over HTTPS (session cookies are Secure by default), behind a reverse proxy that rate-limits /login. The provider’s own throttle is per username, per worker process.

Without a shell, set DLBOARD_PASSWORD_FIRST_ADMIN_SETUP=true for the first start instead. Then open /setup, which logs a setup token derived from DLBOARD_SECRET_KEY so every worker agrees on it, and enter that token to create the admin. Turn the setting back off afterwards. If it’s still on once the database has users, the server refuses to start until you turn it off.

The setting is off by default, and even when it’s on, /setup only works while the database has no users at all. Once any user exists, /setup returns 404 for good. Demoting every admin doesn’t reopen it, and neither does relying on DLBOARD_ADMIN_USERS. Anyone who can read the server log during that first window could create the admin first, so do it before sharing the address.

Letting people sign up

There is a sign-up page, /signup, but it is off by default: on a server anyone can reach, strangers should not be able to make themselves an account unless you say so. With the default, DLBOARD_PASSWORD_SIGNUP=admin_creates, /signup answers 404, the login page offers no way to make an account, and an admin creates each one from Admin → Users (or dlboard users set-password NAME). Set it to open the page; the login page then links to it (“No account yet? Create one”):

Either way, a new account sees only the projects that let it: one shared with it from the project’s Sharing tab, or one that gives everyone a role (which DLBOARD_NEW_PROJECT_ACCESS, below, does for each new project).

Setting Default  
DLBOARD_SECRET_KEY — (required) Signs session cookies. Startup fails without it.
DLBOARD_ADMIN_USERS none Comma-separated usernames made admin whenever they sign in.
DLBOARD_ADMIN_GROUPS none Comma-separated IdP groups whose members are made admin, and stop being one when they leave the group.
DLBOARD_TOKEN_IDLE_DAYS unset (never) An API token nothing has used for this many days stops working; using it starts that over.
DLBOARD_NEW_PROJECT_ACCESS unset (private) viewer/editor: what everyone signed in gets on a new project.
DLBOARD_SESSION_LIFETIME_HOURS 336 How long a browser stays signed in.
DLBOARD_SECURE_COOKIES true Turn off only for plain-HTTP testing.
DLBOARD_PASSWORD_SIGNUP admin_creates Who may make an account at /signup: approval (sign up, then an admin enables you) or open. See Letting people sign up.
DLBOARD_PASSWORD_MIN_LENGTH 12  
DLBOARD_PASSWORD_FIRST_ADMIN_SETUP false Serve /setup for the first admin (above). Startup fails if it’s on and the database already has users.

The rest happens in the app:

Signing in with your identity provider (OIDC_AUTH)

dlboard can be the OpenID Connect client itself, so Okta, Entra ID, Google, Keycloak or any other OIDC provider signs people in with no proxy in front:

# mydeployment.py
from dlboard.plugins import BUILTIN_BACKEND, BUILTIN_CHARTS, OIDC_AUTH, POSTGRES_STORAGE, themes

PLUGINS = [*POSTGRES_STORAGE, *OIDC_AUTH, *BUILTIN_BACKEND, *BUILTIN_CHARTS, themes.default]
export DLBOARD_SECRET_KEY=$(openssl rand -hex 32)   # signs sessions; the same for every worker
export DLBOARD_OIDC_ISSUER=https://example.okta.com/oauth2/default
export DLBOARD_OIDC_CLIENT_ID=0oa1example
export DLBOARD_OIDC_CLIENT_SECRET=...
export DLBOARD_ADMIN_GROUPS=dlboard-admins          # optional: who is an admin
dlboard serve custom --plugins mydeployment:PLUGINS --host 0.0.0.0 --workers 4

A signed-out browser is sent to /login, which sends it on to the provider, and comes back to /oidc/callback; register that as the redirect URI, under your server’s public address (and DLBOARD_URL_PREFIX, if you set one). The other settings (scopes, which claims name someone and list their groups, timeouts) are in Configuration.

Setting it up in Okta

  1. In the Admin Console, go to Applications → Create App Integration, and choose OIDC - OpenID Connect and Web Application.
  2. Set the sign-in redirect URI to https://dlboard.example.com/oidc/callback and the sign-out redirect URI to https://dlboard.example.com/, and keep the Authorization Code grant. Also tick the Refresh Token grant, so that dlboard can ask Okta about each person once a day (below).
  3. Assign it the people or groups who may use dlboard. Okta refuses anyone else, and dlboard shows them why.
  4. Copy the client ID and secret into DLBOARD_OIDC_CLIENT_ID and DLBOARD_OIDC_CLIENT_SECRET.
  5. For groups, go to Security → API → Authorization Servers, open the server (default), and add a claim on its Claims tab: name groups, included in the ID token always, value type Groups, with a filter such as “Starts with” dlboard-.
  6. Set DLBOARD_OIDC_ISSUER to that server’s Issuer URI, https://example.okta.com/oauth2/default.

Other providers differ in where the issuer and groups come from:

What it does

Behind an authenticating proxy (TRUSTED_HEADER_AUTH)

When a reverse proxy in front already signs people in against your identity provider, dlboard can believe the headers it forwards:

# mydeployment.py
from dlboard.plugins import BUILTIN_BACKEND, BUILTIN_CHARTS, POSTGRES_STORAGE, TRUSTED_HEADER_AUTH, themes

PLUGINS = [*POSTGRES_STORAGE, *TRUSTED_HEADER_AUTH, *BUILTIN_BACKEND, *BUILTIN_CHARTS, themes.default]

It needs DLBOARD_TRUSTED_HEADER_ISSUER, a stable name for the identity source, and DLBOARD_TRUSTED_HEADER_PROXIES, the proxy’s addresses; the headers it reads are settings too (see Configuration). Their defaults are what oauth2-proxy sends with --pass-user-headers. Authelia sends Remote-User, Remote-Email and Remote-Groups; Pomerium sends what its jwt_claims_headers names. DLBOARD_SECRET_KEY is needed as for any provider that verifies identity.

How do I build a provider

Implement AuthProvider (dlboard/models/_auth.py) and register it from plug(app). For example, behind a proxy that has already authenticated the caller:

from typing import ClassVar

from flask import request

from dlboard.models import Principal
from dlboard.serve import set_auth_provider


class ProxyHeaderProvider:
    display_name: ClassVar[str] = "Company SSO"
    verifies_identity: ClassVar[bool] = True
    verifies_email: ClassVar[bool] = False  # True only if it checks their email (`email_verified`)
    manage_url: ClassVar[str | None] = None  # where a user manages their own sign-in
    admin_url: ClassVar[str | None] = None  # where an admin adds users; None = users come from the IdP

    def authenticate(self) -> Principal | None:
        email = request.headers.get("X-Forwarded-Email")
        if email is None:
            return None
        groups = frozenset(filter(None, request.headers.get("X-Forwarded-Groups", "").split(",")))
        return Principal(
            issuer="https://sso.example.com",
            subject=email,
            username=email.split("@")[0],
            email=email,
            groups=groups,
        )

    def login_url(self, next_path: str) -> str | None:
        return None  # the proxy handles sign-in before a request ever gets here

    def sign_out_url(self) -> str | None:
        return None  # signing out is the proxy's too; an OIDC provider returns its end-session URL

    @classmethod
    def get_or_create(cls) -> "ProxyHeaderProvider":
        return cls()


def plug(app) -> None:
    set_auth_provider(app, ProxyHeaderProvider.get_or_create())