Files
spaces-startos/startos/actions/enableSubsAuth.ts
T
spacesopsandCursor 073344d4d1
Build Service / BuildPackage (push) Canceled after 0s
0.3.0:1
Group Actions and Config by category (Space-CLI, Bitcoin, Spaced,
Subspaces, Certrelay, Nacho) and build x86 + arm only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 03:34:34 -04:00

55 lines
1.8 KiB
TypeScript

import { storeJson } from '../fileModels/storeJson'
import { actionGroups } from '../actionGroups'
import { i18n } from '../i18n'
import { sdk } from '../sdk'
import { randomPassword } from '../utils'
const DEFAULT_USERNAME = 'spaces'
export const enableSubsAuth = sdk.Action.withoutInput(
// id
'enable-subs-auth',
// metadata
async ({ effects }) => {
const enabled = await storeJson.read((s) => s.subsAuthEnabled).once()
return {
name: i18n('Enable Subspaces Auth'),
description: i18n(
'Turn on HTTP basic auth in front of the Subspaces Web UI and the Subs API (both on port 7777). If no credentials have been set yet, a random password is generated (username defaults to "spaces"). Use "Show Subspaces Auth Credentials" afterwards to retrieve them. Service restarts so subs picks up the auth env vars.',
),
warning: null,
allowedStatuses: 'any',
group: actionGroups.subspacesAuth,
visibility: enabled === true ? 'hidden' : 'enabled',
}
},
// run
async ({ effects }) => {
const existing = await storeJson.read((s) => s.subsAuth).once()
const subsAuth = existing ?? {
username: DEFAULT_USERNAME,
password: randomPassword(),
}
await storeJson.merge(effects, {
subsAuth,
subsAuthEnabled: true,
})
return {
version: '1',
title: i18n('Success'),
message: existing
? i18n(
'Subspaces Auth enabled with the existing stored credentials. The service is restarting; use "Show Subspaces Auth Credentials" to view them.',
)
: i18n(
'Subspaces Auth enabled and a fresh credential pair was generated. The service is restarting; use "Show Subspaces Auth Credentials" to view them.',
),
result: null,
}
},
)