UI: pgcreds create button; show logged-in user
* web/templates/pgcreds.html: New Credentials card is now always rendered; Add Credentials toggle button reveals the create form (hidden by default). Shows a message when all system accounts already have credentials. Previously the card was hidden when UncredentialedAccounts was empty. * internal/ui/ui.go: added ActorName string field to PageData; added actorName(r) helper resolving username from JWT claims via DB lookup, returns empty string if unauthenticated. * internal/ui/handlers_*.go: all full-page PageData constructors now pass ActorName: u.actorName(r). * web/templates/base.html: nav bar renders actor username as a muted label before the Logout button when logged in. * web/static/style.css: added .nav-actor rule (muted grey, 0.85rem).
This commit is contained in:
@@ -162,6 +162,35 @@ CREATE TABLE IF NOT EXISTS policy_rules (
|
||||
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
|
||||
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now'))
|
||||
);
|
||||
`,
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
sql: `
|
||||
-- Track which accounts own each set of pg_credentials and which other
|
||||
-- accounts have been granted read access to them.
|
||||
--
|
||||
-- owner_id: the account that administers the credentials and may grant/revoke
|
||||
-- access. Defaults to the system account itself. This column is
|
||||
-- nullable so that rows created before migration 5 are not broken.
|
||||
ALTER TABLE pg_credentials ADD COLUMN owner_id INTEGER REFERENCES accounts(id);
|
||||
|
||||
-- pg_credential_access records an explicit "all-or-nothing" read grant from
|
||||
-- the credential owner to another account. Grantees may view connection
|
||||
-- metadata (host, port, database, username) but the password is never
|
||||
-- decrypted for them in the UI. Only the owner may update or delete the
|
||||
-- credential set.
|
||||
CREATE TABLE IF NOT EXISTS pg_credential_access (
|
||||
id INTEGER PRIMARY KEY,
|
||||
credential_id INTEGER NOT NULL REFERENCES pg_credentials(id) ON DELETE CASCADE,
|
||||
grantee_id INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
|
||||
granted_by INTEGER REFERENCES accounts(id),
|
||||
granted_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
|
||||
UNIQUE (credential_id, grantee_id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_pgcred_access_cred ON pg_credential_access (credential_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_pgcred_access_grantee ON pg_credential_access (grantee_id);
|
||||
`,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user