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>
14 lines
616 B
TypeScript
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}`))
|
|
}
|