[Feature] Trusted Local Provisioning for Immich #28792
caniko
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have searched the existing feature requests, both open and closed, to make sure this is not a duplicate request.
The feature
Summary
Add
immich-admin provision-token, a server-local command that mints ashort-lived admin session token for infrastructure automation running on the
Immich host. The token is a normal Immich session token. It is then used against
the existing admin API.
Also allow
UserAdminCreateDto.passwordto be omitted when OAuth is enabled.Together, these changes let declarative operators manage Immich users and OIDC
without storing a long-lived admin API key, scraping the UI, or writing directly
to the database.
Motivation
Immich already supports most of the surfaces a declarative operator needs.
System settings can come from
IMMICH_CONFIG_FILE, OAuth settings are part ofnormal system config, and users can be reconciled through the admin API. The
missing piece is bootstrap authentication for automation that already controls
the local service.
API keys are the right default for ordinary third-party applications. They are
not a good bootstrap primitive for host-level automation, because a persistent
admin credential has to exist before the automation can safely manage the
instance. That pushes operators toward manual setup, secret sprawl, or database
writes.
This proposal keeps Immich's API-first administration model. It only adds a
short local bridge from service access to a temporary session, then returns to
the existing API surface.
Fit with Immich
Immich already has an administrative server CLI for local recovery and
operations, including password reset, password-login toggles, OAuth-login
toggles, maintenance mode, and user listing.
provision-tokenbelongs in thatsame family:
service-level access.
validation path.
validation and business logic still apply.
The intended users are NixOS modules, Ansible roles, Kubernetes operators, Helm
post-install jobs, Terraform or OpenTofu providers, GitOps systems, and similar
host-owned automation. Desktop clients, mobile clients, and general third-party
integrations should continue to use Immich's normal authentication flows and API
keys.
API contract impact
This is not a fourth authentication scheme. Immich continues to authenticate API
requests through its existing session, API-key, and shared-key paths.
provision-tokenonly gives local automation a short-lived session that the APIalready knows how to validate.
Making
UserAdminCreateDto.passwordoptional is a real API contract change, butthe intended contract is narrow:
password.passwordas optional, with endpointdocumentation explaining the OAuth-enabled precondition.
Proposal
immich-admin provision-token --ttl 300 # seconds, 1..3600, default 300The command runs inside the server environment, finds the admin account, creates
a normal admin session with
expiresAt = now + ttlthrough the existingsession table, and prints the raw bearer token to stdout. It adds no new auth
primitive and persists nothing outside the session table.
Separately, make
UserAdminCreateDto.passwordoptional.UserAdminService.createalready rejects passwordless creates when OAuth is disabled, so the authorization
policy stays centralized in service code.
Reference implementation:
crates/immich-provision/patches/immich/0001-add-trusted-local-provision-token.patch(verified to apply against Immich v2.7.5).
Security model
store path, agenix secret, or process argument.
Declarative semantics
Provisioners should match users by normalized email, create OAuth-only users
without a password when OAuth is enabled, and avoid writing
oauthId.The
oauthIdvalue is provider-defined and may be pairwise. Letting Immich setit during OAuth login avoids guessing the subject in external tooling. For
freshly provisioned users, the first OAuth login is expected to bind the
provider identity. That linking behavior should be covered by tests if Immich
accepts passwordless OAuth-user creation. For migrations of existing local users
with attached libraries, operators must still verify the email-linking behavior
against the exact Immich version before enabling the migration.
Destructive operations should remain explicitly gated. A reconciler should not
delete users unless both a global delete flag and a per-user delete flag are set.
Alternatives
permanent admin secret. API keys remain the right answer for many
integrations, but they are a poor fit for first-run host automation.
oauthId: brittle because the subject comes from the providerand may be pairwise.
new remotely reachable privileged path. A server-local CLI keeps the bootstrap
boundary tied to existing host access.
Test requirements
provision-token --ttl 300returns a token that an admin API endpointaccepts, the token stops working after expiry, and the command fails when no
admin exists.
code path.
oauthId.oauthIduser is covered by anintegration test or version-specific migration check before relying on it for
existing libraries.
Platform
All reactions