Files
envbao-admin/src/model/connectionUrl.ts
T
mattandClaude Sonnet 5.5 fd20caa525 Config: show each database connection's URL and allowed roles
The connections table reads each connection and lists its URL and
allowed roles. Literal passwords in a URL are masked; templated
{{password}} URLs are shown as-is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 14:09:42 +00:00

14 lines
616 B
TypeScript

const MASK = '••••'
/**
* A connection URL safe to put on screen. Templated passwords ("{{password}}", which OpenBao fills in itself) are
* kept, but a literal one typed into the URL ("user:secret@host", "?password=secret") is hidden.
*/
export function maskConnectionUrl(url: string): string {
return url
.replace(/^([a-z][a-z0-9+.-]*:\/\/[^:@/\s]*:)([^@/\s]*)(@)/i, (m, head: string, pw: string, at: string) =>
pw.includes('{{') ? m : `${head}${MASK}${at}`,
)
.replace(/([?&;\s]password=)([^&;\s]*)/gi, (m, head: string, pw: string) => (pw.includes('{{') ? m : `${head}${MASK}`))
}