mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-19 05:51:44 +00:00
feat(dynamic-secret): Added new options to username template
This commit is contained in:
@@ -8,6 +8,7 @@ import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||
import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
|
||||
|
||||
import { DynamicSecretSnowflakeSchema, TDynamicProviderFns } from "./models";
|
||||
import { compileUsernameTemplate } from "./templateUtils";
|
||||
|
||||
// destroy client requires callback...
|
||||
const noop = () => {};
|
||||
@@ -20,10 +21,9 @@ const generatePassword = (size = 48) => {
|
||||
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
|
||||
const randomUsername = `infisical_${alphaNumericNanoId(32)}`; // Username must start with an ascii letter, so we prepend the username with "inf-"
|
||||
if (!usernameTemplate) return randomUsername;
|
||||
|
||||
return handlebars.compile(usernameTemplate)({
|
||||
return compileUsernameTemplate({
|
||||
usernameTemplate,
|
||||
randomUsername,
|
||||
unixTimestamp: Math.floor(Date.now() / 100),
|
||||
identityName
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user