User and device administration
User and device administration gives RomM a controlled way to create accounts, assign access, issue client credentials, register client devices, and approve new device sign-ins. The web administration screens use the same API contracts that clients use. Request enforcement is described in Authentication and authorization, while the wider identity model is described in Identity and access.
Administration model
The administration model separates the person who owns access from the reusable rules and credentials used to exercise that access. A user may belong to a permission group and may own client tokens and devices. A device-authentication approval joins those objects only after a signed-in user accepts the request.
RomM has two account roles: admin and user. Administrators bypass permission-group checks. Regular users receive access from their group and per-user changes. Kiosk mode uses a synthetic visitor identity for an anonymous read-only session. That identity is not a stored account. Accounts can also link to an OpenID Connect identity, which gives the system a stable provider identity even when the provider email changes.
Administrative objects
| Object | Purpose | Relationship |
|---|---|---|
| User | Represents an account with profile data and an administrator or regular-user role. | Owns devices and client tokens. |
| Permission group | Provides a named set of entity and action grants. | Supplies access to its members and can be the server default. |
| Client token | Provides a long-lived API credential with a selected set of scopes. | Belongs to one user and may be bound to one device. |
| Device | Represents a client installation or endpoint that uses RomM. | Belongs to one user and can be linked to a client token. |
| Hidden entity | Removes a platform or ROM from a user or group view. | Applies in addition to access grants. |
References: backend/…/user.py• L27-39 backend/…/user.py• L44-89 backend/…/user.py• L127-138 backend/…/permission.py• L20-45 backend/…/client_token.py• L16-32 backend/…/device.py• L42-73
User management
The user API supports direct account creation, invite-based registration, profile updates, listing, and deletion. The administration UI presents these actions as a searchable user list with create, invite, edit, enable, and delete controls.
Account lifecycle
An administrator or an authorized account with the user-management grant can create a regular user with a username, email, password, and role. When an administrator already exists, only an administrator can create an administrator account or an administrator invite. An invite link offers a separate path: an authorized user creates a time-limited link for a role, and the recipient uses its token to complete registration. Existing usernames and email addresses are rejected without regard to letter case. The user store can also resolve an account from its OpenID Connect issuer and subject.
Once an account exists, its owner can update profile information. An administrator can also change another user's role and enabled state. Sensitive self-edits require the current password for password accounts or an authenticated web session for accounts without a password. A password or username change ends the affected sessions. An OpenID Connect-managed email cannot be changed through this API. The API protects the last administrator with an atomic check that locks administrator rows during the update or delete transaction. It does not allow a user to delete, disable, or change the role of the account currently in use.
Account creation, invite registration, tracked account changes, and deletion produce audit records. A role change notifies the affected user. Disabling a user closes that user's client-token connections.
flowchart LR
A[Administrator or authorized user] --> B{Creation path}
B -->|Direct| C[Create account]
B -->|Invite| D[Create invite link]
D --> E[Recipient registers]
C --> F[Enabled user account]
E --> F
F --> G[Profile and access updates]
F --> H[Delete account]
References: backend/…/user.py• L95-132 backend/…/user.py• L135-217 backend/…/user.py• L220-275 backend/…/user.py• L278-344 backend/…/user.py• L347-407 backend/…/user.py• L443-653 backend/…/user.py• L656-710 backend/…/users_handler.py• L18-127 backend/…/users_handler.py• L195-217 frontend/…/UsersSection.vue• L199-249
User administration interface
The v2 Administration route is itself restricted to administrators. Inside it, Users, Groups, Tasks, and Streaming appear as sibling tabs. Groups require the users.write grant, Tasks require tasks.run, and Streaming requires administrator access. The selected tab stays in the query string so an allowed deep link survives a reload. If permissions later show that a requested tab is not available, the view returns to Users instead of opening a panel whose requests would fail.
The user edit view combines profile fields with access controls. It saves the account change first, then applies group, override, and visibility changes as needed. The current user's role control and delete or disable actions are restricted in the interface as well as by the API. Avatar changes are part of the profile update and are served to authenticated users through the user asset endpoint.
References: frontend/…/Administration.vue• L1-130 frontend/…/UsersSection.vue• L41-63 frontend/…/EditUserDialog.vue• L92-133 frontend/…/EditUserDialog.vue• L199-248 backend/…/user.py• L338-431
External profile linking
The user profile settings can link an account to a RetroAchievements profile and refresh the progression data shown by RomM. A changed profile name starts a full background sync so old progression does not remain attached to the new profile, while a refresh of the same name uses an incremental sync.
The API reports the background result through a socket event. A successful sync reloads the current user state, while a failed sync shows an error without replacing the last known profile data.
References: frontend/…/RetroAchievementsSection.vue• L23-88 frontend/…/user.ts• L63-119 backend/…/user.py• L565-572 backend/…/user.py• L727-753 frontend/…/RetroAchievementsSection.test.ts• L41-56
Audit and log interfaces
The settings Logs view gives administrators a record of user and access changes and gives permitted users access to the live application log. These are separate views because the event record is an administration function, while the runtime log is controlled by the logs.read scope and can be disabled by a server setting.
Log views
Administrators see the Events tab. Users with logs.read see the Logs tab when the log viewer is enabled. A user who is not an administrator cannot open Events even when the user has logs.read. The ?tab=logs query selects the live log view, while an unavailable or absent selection falls back to the first view that the user can access.
References: frontend/…/Logs.vue• L1-74 frontend/…/Logs.test.ts• L60-102
Permission-group management
A permission group is a named access template. It describes which entity types a member can read, write, or delete. An optional own_only rule limits a grant to resources owned by that user. This gives administrators a shared policy for many users without making every access decision a role change.
Effective user access
Regular users receive grants from their assigned group. A user without an explicit group follows the server-wide default group. Per-user overrides then add or revoke individual grants. Hidden-entity rules remove selected platforms or ROMs from the user's visible catalog.
The /permissions/me response exposes backend-enforced access in the UI action vocabulary. Its grants are global in this phase. A single backend grant can unlock several UI actions. Administrators bypass the group and override matrix. The resolved grants are also projected into the application's coarse OAuth scope vocabulary so the same effective access can protect API routes and client tokens.
A hidden platform also hides its ROMs from the affected user. Direct access to hidden platforms, ROMs, and their child resources is masked as not found. Administrators remain able to see hidden entities.
| Access source | Effect |
|---|---|
| Administrator role | Bypasses group grants and hidden-entity rules. |
| Assigned permission group | Supplies the base entity and action grants. |
| Default permission group | Supplies the base grants when no group is assigned. |
| User override | Adds or revokes one entity and action grant. |
| Hidden entity | Hides a specific platform or ROM from the user or group. |
References: backend/…/permissions.py• L68-108 backend/…/permissions.py• L111-162 backend/…/permissions.py• L165-200 backend/…/user.py• L83-89 backend/…/user.py• L161-168 backend/…/permission.py• L63-145 backend/…/permission.py• L1-9 backend/…/permission.py• L23-29 backend/…/permission.py• L57-149 backend/…/test_permissions_me.py• L24-96 backend/…/test_permissions_visibility.py• L75-176
Group and membership flows
Administrators can inspect the permission catalog, create groups, replace group grants, and delete groups. Exactly one group remains the default. A group cannot be removed as the default until another group takes its place. Members of a deleted non-default group fall back to the default group.
The user access editor assigns a group and replaces per-user overrides. It also adds or removes hidden platforms and ROMs. A permission change emits a notification and closes the affected users' client-token connections so their interfaces and clients do not keep stale access. Group changes, user access changes, and visibility changes also produce audit events for the Events view.
References: backend/…/permissions.py• L42-67 backend/…/permissions.py• L147-265 backend/…/permissions.py• L294-345 backend/…/permissions.py• L351-432 frontend/…/PermissionGroupsSection.vue• L101-138 frontend/…/EditUserDialog.vue• L173-245
Client-token management
A client token is a credential for an API client that cannot use the browser session. A user chooses its name, scopes, and expiry. The token is stored and displayed as a raw secret only when it is created or regenerated. Later list responses show its identity, scope set, expiry, and last-use information instead of the secret.
Token lifecycle
Users can create, list, regenerate, and delete their own tokens. A requested scope must be within the user's effective access. A user can have at most 25 tokens. Expiry can be set to 30 days, 90 days, one year, or never.
Administrators can list tokens across users and revoke a token by its identifier. Revoking another administrator's token still requires administrator status. This supports account cleanup without exposing the token secret or changing the owning user's profile.
References: backend/…/client_tokens.py• L41-116 backend/…/client_tokens.py• L119-189 backend/…/client_tokens.py• L192-212 backend/…/client_tokens.py• L35-56 frontend/…/client-token.ts• L29-56 frontend/…/ClientApiTokens.vue• L130-177
Existing-token pairing
The token settings UI can create a short pairing code for an existing token. A second client exchanges that code for a newly generated raw token. The server replaces the stored token hash. The code is short-lived and single-use, so it transfers access without placing the existing secret in a URL or requiring the second client to know it.
sequenceDiagram
participant U as Signed-in user
participant A as RomM API
participant C as Client
U->>A: Pair an existing token
A-->>U: Short-lived pairing code
U->>C: Provide pairing code
C->>A: Exchange code
A-->>C: New raw token
A-->>A: Replace stored token hash
References: backend/…/client_tokens.py• L149-189 backend/…/client_tokens.py• L18-32 backend/…/client_tokens.py• L116-150 frontend/…/CreateClientTokenDialog.vue• L255-326 frontend/…/client-token.ts• L59-70
Device management
A device is a named client endpoint associated with a user. Its record lets RomM recognize a client installation and track client metadata, last-seen time, and the selected save-sync mode. It does not act as a user account.
Device registration and ownership
An authenticated client registers a device through the devices API. The request can include a stable client identifier and descriptive metadata. When a matching device fingerprint already belongs to the user, registration can return that device and update its last-seen time instead of creating a duplicate. Clients can request duplicate creation when they need a separate device record.
Users can list, inspect, update, and delete their own devices. Deleting a device also removes its device-owned sync records. A file-transfer device may receive the folders needed for save exchange when it is first registered.
References: backend/…/device.py• L22-40 backend/…/device.py• L56-134 backend/…/device.py• L137-193 backend/…/device.py• L18-20 backend/…/device.py• L42-73
Device and token relationship
The device link on a client token identifies which registered endpoint received or uses that credential. Device-authentication approval creates both records as one operation. A regular token can remain unbound, so token administration and device administration are related but do not require each other.
The token settings interface loads the user's devices and shows a linked device next to a token when the token has one. This gives the user a way to recognize credentials without exposing their raw values.
References: backend/…/client_token.py• L16-32 backend/…/auth.py• L185-257 frontend/…/ClientApiTokens.vue• L40-49 frontend/…/ClientApiTokens.vue• L179-190 frontend/…/ClientApiTokens.vue• L222-241
Device authentication
Device authentication is a user-approved sign-in flow for a client that has no credential yet. It follows the shape of the OAuth device authorization flow: the client starts a request, the user reviews it in the web UI, and the client polls until RomM returns a device-bound client token.
Authorization sequence
The initial request is open because the new device has no credentials. RomM keeps the pending request in Redis for up to ten minutes. It returns a secret device code for polling and a shorter user code for the approval link or QR flow. The user must already be signed in to view and handle that request.
The approval screen shows the client identity and requested scopes. It limits selectable scopes to the intersection of the request and the user's effective scopes. The user can edit the device name, choose token expiry, approve, or deny.
sequenceDiagram
participant D as New device
participant A as RomM API
participant W as Signed-in web user
D->>A: Start device authorization
A-->>D: Device code, user code, approval path
W->>A: Load request with user code
A-->>W: Device details and allowed scopes
W->>A: Approve selected scopes or deny
A-->>A: Create or update device and bound token
D->>A: Poll with device code
A-->>D: Pending, denied, or one-time access token
References: backend/…/auth.py• L69-108 backend/…/auth.py• L111-147 backend/…/auth.py• L150-270 backend/…/auth.py• L273-357 backend/…/device_auth.py• L19-24 backend/…/device_auth.py• L124-228
Approval interface
The /pair/device web route is the human approval surface. It accepts the user code from the query string, loads the pending request, preselects the scopes allowed to the signed-in user, and reports whether the request was approved, denied, expired, or already handled.
The device polls /auth/device/token until it receives a result. A pending request asks the client to continue polling at the supplied interval. An approved result contains the raw token, device identifier, selected scopes, and token expiry. The approved result is consumed once.
References: frontend/…/DevicePair.vue• L29-85 frontend/…/DevicePair.vue• L113-143 frontend/…/device-auth.ts• L19-46 backend/…/auth.py• L302-357
Administration task controls
The settings interface also gives administrators a view of server tasks and their recent results. It separates watcher, scheduled, and manual work. Manual work and scheduled work that allow it can be started from the interface, while the status feed shows completed outcomes.
When an administrator starts a task, the interface marks that task as running before the next status poll. It then refreshes task status every five seconds while the section is open. This prevents duplicate clicks during the gap between a run request and the first status result. Task errors are shown as a user message rather than being treated as a successful start.
References: frontend/…/TasksSection.vue• L24-119 frontend/…/TasksSection.vue• L122-261 frontend/…/TasksSection.test.ts• L73-151
Missing-file cleanup
The settings interface exposes a missing-games view for ROM records whose files are absent from disk. It lets an administrator filter the list by platform, sort the results, review the count, and queue cleanup for all missing records or for selected platforms.
The view loads only the rows near the current viewport, which keeps large result sets usable. Cleanup requires an explicit typed confirmation and runs as a task. After the task finishes, the view refreshes its count and visible rows. It restores the caller's gallery filters and selection when the administrator leaves the view so the temporary missing-file state does not affect later browsing.
References: frontend/…/MissingGamesSection.vue• L49-103 frontend/…/MissingGamesSection.vue• L112-210 frontend/…/MissingGamesSection.vue• L217-265 frontend/…/MissingGamesSection.vue• L269-375
User interface preferences
The user-interface settings let each user shape the web client without changing account access. They cover language, theme, home sections and widgets, gallery presentation, gameplay prompts, virtual collection type, UI version, and local developer or display behavior.
Theme choices include dark, light, and automatic modes. Users can also enable CRT effects or reduced motion. Home settings control visible sections, widget visibility, widget order, and the library-stat display. Gallery settings control grouping, metadata labels, animation, an experimental cache, and box-art style. A gallery-wide box-art change resets the detail and player styles to the same value, after which advanced controls can set separate styles.
Virtual collection type changes refresh the available collection view for the selected source. The UI version choice switches between the classic interface and the new v2 interface. The debug overlay remains a local per-device setting rather than an account preference.
References: frontend/…/UserInterface.vue• L39-110 frontend/…/UserInterface.vue• L129-204 frontend/…/UserInterface.vue• L207-347 frontend/…/UserInterface.vue• L349-455 frontend/…/UserInterface.vue• L457-535
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the two stored account roles and the normalization of older or unknown role values aligned with invite creation, account updates, and permission resolution. A stale role value can grant the wrong access path.
- Keep delegated
users.writeaccount creation separate from administrator-only creation of administrator accounts and administrator invite links. A mismatch can create a privilege-escalation path through direct or invite-based registration. - Keep username and email matching case-insensitive across account creation checks, lookups, and identity management. A case-sensitive path can allow duplicate account identities or fail to find an existing account.
- Keep OpenID Connect issuer and subject matching separate from case-insensitive email matching. The provider subject is case-sensitive and must remain the stable identity key.
- Keep sensitive self-edit proof aligned with the account type. Password accounts need the current password, while accounts without a password need an authenticated web session. Do not let a long-lived client token replace that proof.
- Keep the permission entity/action catalog, its projection to coarse scopes, and the route guards aligned. A new grant that does not project to the expected UI action or scope can make the interface, token creation, or route access fail in a different layer.
- Preserve the default-group fallback in both grant resolution and hidden-entity resolution. Changing only one path gives users different access and visibility results.
- Keep user role changes, group changes, overrides, and hidden-entity changes connected to permission-change notifications and client-token connection cleanup so active clients do not use stale effective permissions.
- Keep the last-admin guard in the same transaction as the role change or deletion, and lock the administrator rows while checking them. A check that runs outside the protected transaction can pass twice under concurrent requests and leave no administrator.
- Keep user and permission mutations represented by the event records that the Events view exposes. A missing audit record can hide an access change even when the mutation succeeds.
- Keep the administration route gate and tab visibility aligned with the scopes used by each tab. An allowed deep link must not open a panel whose requests the user cannot make.
- Keep the event-log administrator check separate from the runtime-log
logs.readcheck and the log-viewer disable flag. - Treat client-token responses as two contracts: creation and regeneration return the raw secret, while list and admin views must not.
- Keep device authorization state, user-code lookup, expiry, and one-time approved-token consumption consistent across the init, approval, and polling endpoints.
- Keep the device-to-token relationship optional for ordinary tokens and required for the device-authorization approval result.
- Keep the
/pair/deviceroute and the verification paths returned by the device authorization API in sync. - Keep
/permissions/meaction keys faithful to backend enforcement. The response currently reports global UI grants, while resource visibility and fine delete checks remain enforced by the backend. - Keep a changed RetroAchievements username paired with progression reset and a full sync, while a refresh of the same username remains incremental. Keep the background
ra:syncedresult tied to the current-user reload and failure notice. - Keep task registry names aligned with task status keys. The settings UI uses the task key to prevent a duplicate run, not the display title.
- Keep the missing-file filter isolated from the normal gallery filter state. Entering and leaving the settings view must not leak its temporary filter into later browsing.
- Keep gallery-wide and per-page box-art settings consistent. A gallery-wide change intentionally resets the detail and player choices before later overrides.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A delegated user tries to create an administrator after an administrator already exists | The account or invite is rejected, which blocks privilege escalation through delegated user management. | Allow administrator creation and administrator invite creation only for an administrator. |
| A username or email differs from an existing account only by letter case | The account lookup treats it as the same identity and the duplicate account is rejected. | Normalize both stored-query inputs and candidate values for case-insensitive matching. |
| A password account owner submits a sensitive self-edit without the current password or with the wrong password | The profile change is rejected and the existing credentials remain active. | Require and verify the current password before changing the username, password, or email. |
| A user tries to change an OpenID Connect-managed email | The profile update is rejected and the provider remains the source of truth. | Reject email edits for linked or password-less OIDC accounts. |
| A user requests a token scope outside their effective scopes | Token creation is rejected and no credential is issued. | Validate requested scopes against the resolved user scopes before creating the token. |
| An administrator tries to remove the default group without selecting another default | The group change is rejected, which preserves the fallback for group-less users. | Require another group to become default first. |
| A user tries to delete or demote the last administrator | The account change is rejected, preserving an administrator who can recover the server. | Check the administrator count in the same transaction as the update or delete, with administrator rows locked during the check. |
| A user has a coarse write scope but no fine delete grant | A delete request passes its coarse gate but returns forbidden. | Check the entity's delete grant separately from its write grant. |
| A hidden platform or ROM is addressed through a list, detail, download, or child-resource route | The resource is masked as not found and no protected side effect occurs. | Apply the visibility check to the parent resource before reading or changing it. |
| A user opens an administration tab that is not allowed by the current scopes | The tab is not shown or the deep link returns to Users instead of exposing a panel that will fail. | Derive tab visibility from the same access state that protects the tab's requests. |
| A non-administrator requests the Events view or the live log viewer is disabled | The Events view is unavailable, or the Logs view is hidden. | Require administrator access for Events and both logs.read and the enabled viewer setting for Logs. |
| A device polls after the authorization request expires or after approval is consumed | The client receives an expired-token result and must start a new flow. | Apply the pending TTL and consume approved state once. |
| A device polls faster than the requested interval | The client receives a slow-down result instead of a token. | Honor the polling interval and the per-IP rate limit. |
| A device authorization request is denied | The client receives an access-denied result and no device token is issued. | Mark the pending request denied before the client continues polling. |
| A client registers an existing device with duplicate creation disabled | The API returns a conflict instead of silently creating another device. | Match the user's device fingerprint and require an explicit duplicate request. |
| A linked RetroAchievements username changes without clearing old progression | Progression from the previous external profile can appear under the new profile. | Reset stored progression on a username change and queue a full sync. |
| A background RetroAchievements sync fails | The profile link remains, but the displayed progression can be stale and the user needs feedback. | Report the failed ra:synced event and do not reload the user as if the sync succeeded. |
| An administrator starts a task that is already queued or started | The run control stays disabled and avoids a duplicate request. | Match in-flight status by task key and hold the control while the start request is pending. |
| Missing-file cleanup finishes without refreshing the missing-file view | The count and rows can show records that no longer need cleanup. | Wait for task completion, invalidate the list, and reload its metadata. |
| A user changes the gallery box-art style while page-specific choices are active | The detail and player pages show an unexpected style split or stale choice. | Reset both page-specific styles with the gallery-wide style, then apply explicit overrides. |
Key files
| File | Why to read it |
|---|---|
| backend/…/user.py | Defines account roles, OpenID Connect identity state, group ownership, client-token and device ownership, kiosk identity, and the projection of user access to OAuth scopes. |
| backend/…/user.py | Defines account creation, invite registration, profile changes, self-edit proof, OpenID Connect restrictions, administrator safeguards, session cleanup, and audit-producing user mutations. |
| backend/…/users_handler.py | Provides case-insensitive user lookup and filtering, external identity lookup, administrator queries, activity updates, and the transaction-safe guard that prevents the last administrator from being removed. |
| backend/…/permissions.py | Defines group, per-user access, hidden-entity administration APIs, permission-change notifications, client-token connection cleanup, and access audit events. |
| backend/…/permission.py | Defines the permission catalog and the backend-enforced action vocabulary returned to the UI. |
| backend/…/permissions.py | Explains how groups, overrides, roles, hidden entities, and coarse scopes become effective access. |
| backend/…/client_tokens.py | Defines personal, administrator, and paired client-token operations. |
| backend/…/client_tokens.py | Defines token expiry, scope checks, pairing codes, and code exchange behavior. |
| backend/…/device.py | Defines device registration, deduplication, ownership, and lifecycle operations. |
| backend/…/auth.py | Defines the device authorization request, approval, denial, and polling flow. |
| backend/…/device_auth.py | Defines the short-lived state and code rules for device authorization. |
| frontend/…/Administration.vue | Shows the administrator route, scope-gated tabs, and deep-link behavior. |
| frontend/…/UsersSection.vue | Shows the user administration list and its account actions. |
| frontend/…/EditUserDialog.vue | Shows how profile data and effective access are edited together. |
| frontend/…/RetroAchievementsSection.vue | Shows the user profile flow for linking an external RetroAchievements profile and starting full or incremental progression syncs. |
| frontend/…/user.ts | Shows the user update and progression-refresh API calls used by the profile flow. |
| frontend/…/PermissionGroupsSection.vue | Shows the group administration surface. |
| frontend/…/ClientApiTokens.vue | Shows token listing and the device association presented to users. |
| frontend/…/DevicePair.vue | Shows the signed-in approval interface for a new device. |
| frontend/…/Logs.vue | Shows the administrator event view and the scope-gated live log view. |
| frontend/…/TasksSection.vue | Shows task controls, in-flight state, polling, and recent task results in settings. |
| frontend/…/MissingGamesSection.vue | Shows missing-file discovery, filtering, and cleanup from the settings interface. |
| frontend/…/UserInterface.vue | Shows user-level theme, home, gallery, gameplay, collection, UI version, and local display preferences. |