Default new tokens to the default policy only (ENB-21)
CI / integration (push) Successful in 13s
CI / check (push) Successful in 16s

OpenBao copies the creator's policies when none are sent, so a token created
with nothing ticked while signed in as root was itself root. The New token form
now starts with `default` ticked, and createToken sends ['default'] for an
empty selection.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-20 12:52:13 +01:00
1 parent 0a2054eb41
commit b55259c492
4 files changed
+44 -9

No files matched your search

+4 -1
View File
@@ -39,13 +39,16 @@ export async function listTokens(c: BaoClient): Promise<TokenSummary[]> {
return found.filter((t): t is TokenSummary => t !== null)
}
/** What a token gets when no policy is chosen. OpenBao would otherwise copy the creator's policies (root, for root). */
export const DEFAULT_TOKEN_POLICIES = ['default']
export async function createToken(c: BaoClient, input: CreateTokenInput): Promise<CreatedToken> {
const res = await c.request<{ auth: { client_token: string; accessor: string; policies: string[] } }>(
'POST',
'auth/token/create',
{
display_name: input.displayName || undefined,
policies: input.policies,
policies: input.policies.length ? input.policies : DEFAULT_TOKEN_POLICIES,
ttl: input.ttl || undefined,
renewable: input.renewable,
no_parent: input.orphan || undefined,