Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(dynamic-secret): Added new options to username template

carlosmonastyrski5367d1ac2ef8
diff --git a/backend/src/ee/routes/v1/dynamic-secret-router.ts b/backend/src/ee/routes/v1/dynamic-secret-router.ts
index 2cff708430..b916bab67e 100644
--- a/backend/src/ee/routes/v1/dynamic-secret-router.ts
+++ b/backend/src/ee/routes/v1/dynamic-secret-router.ts
@@ -23,7 +23,10 @@ const validateUsernameTemplateCharacters = characterValidator([
CharacterType.CloseBrace,
CharacterType.CloseBracket,
CharacterType.OpenBracket,
- CharacterType.Fullstop
+ CharacterType.Fullstop,
+ CharacterType.SingleQuote,
+ CharacterType.Spaces,
+ CharacterType.Pipe
]);
const userTemplateSchema = z
@@ -33,7 +36,7 @@ const userTemplateSchema = z
.refine((el) => validateUsernameTemplateCharacters(el))
.refine((el) =>
isValidHandleBarTemplate(el, {
- allowedExpressions: (val) => ["randomUsername", "unixTimestamp", "identityName"].includes(val)
+ allowedExpressions: (val) => ["randomUsername", "unixTimestamp", "identity.name"].includes(val)
})
);
diff --git a/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts b/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts
index e21d26a9eb..701efc2bd9 100644
--- a/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/aws-elasticache.ts
@@ -16,6 +16,7 @@ import { BadRequestError } from "@app/lib/errors";
import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
import { DynamicSecretAwsElastiCacheSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const CreateElastiCacheUserSchema = z.object({
UserId: z.string().trim().min(1),
@@ -136,10 +137,9 @@ const generateUsername = (usernameTemplate?: string | null, identityName?: strin
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
const randomUsername = `inf-${customAlphabet(charset, 32)()}`;
if (!usernameTemplate) return randomUsername;
-
- return handlebars.compile(usernameTemplate)({
+ return compileUsernameTemplate({
+ usernameTemplate,
randomUsername,
- unixTimestamp: Math.floor(Date.now() / 100),
identityName
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/aws-iam.ts b/backend/src/ee/services/dynamic-secret/providers/aws-iam.ts
index 6eabd31aa1..57c12485e7 100644
--- a/backend/src/ee/services/dynamic-secret/providers/aws-iam.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/aws-iam.ts
@@ -16,21 +16,21 @@ import {
PutUserPolicyCommand,
RemoveUserFromGroupCommand
} from "@aws-sdk/client-iam";
-import handlebars from "handlebars";
import { z } from "zod";
import { BadRequestError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { DynamicSecretAwsIamSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = alphaNumericNanoId(32);
if (!usernameTemplate) return randomUsername;
- return handlebars.compile(usernameTemplate)({
+ return compileUsernameTemplate({
+ usernameTemplate,
randomUsername,
- unixTimestamp: Math.floor(Date.now() / 100),
identityName
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/cassandra.ts b/backend/src/ee/services/dynamic-secret/providers/cassandra.ts
index c0317df4bc..cc3f1fa6ac 100644
--- a/backend/src/ee/services/dynamic-secret/providers/cassandra.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/cassandra.ts
@@ -8,6 +8,7 @@ import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretCassandraSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = (size = 48) => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -17,10 +18,9 @@ const generatePassword = (size = 48) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/elastic-search.ts b/backend/src/ee/services/dynamic-secret/providers/elastic-search.ts
index c4a9afad39..b8f1ae588d 100644
--- a/backend/src/ee/services/dynamic-secret/providers/elastic-search.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/elastic-search.ts
@@ -1,5 +1,4 @@
import { Client as ElasticSearchClient } from "@elastic/elasticsearch";
-import handlebars from "handlebars";
import { customAlphabet } from "nanoid";
import { z } from "zod";
@@ -7,6 +6,7 @@ import { alphaNumericNanoId } from "@app/lib/nanoid";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretElasticSearchSchema, ElasticSearchAuthTypes, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = () => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -16,10 +16,9 @@ const generatePassword = () => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/ldap.ts b/backend/src/ee/services/dynamic-secret/providers/ldap.ts
index 06196a3b02..447ce4a946 100644
--- a/backend/src/ee/services/dynamic-secret/providers/ldap.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/ldap.ts
@@ -9,6 +9,7 @@ import { BadRequestError } from "@app/lib/errors";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { LdapCredentialType, LdapSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = () => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*$#";
@@ -25,10 +26,9 @@ const encodePassword = (password?: string) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/mongo-atlas.ts b/backend/src/ee/services/dynamic-secret/providers/mongo-atlas.ts
index 5ac479393e..0baee26a8b 100644
--- a/backend/src/ee/services/dynamic-secret/providers/mongo-atlas.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/mongo-atlas.ts
@@ -1,5 +1,4 @@
import axios, { AxiosError } from "axios";
-import handlebars from "handlebars";
import { customAlphabet } from "nanoid";
import { z } from "zod";
@@ -7,6 +6,7 @@ import { createDigestAuthRequestInterceptor } from "@app/lib/axios/digest-auth";
import { alphaNumericNanoId } from "@app/lib/nanoid";
import { DynamicSecretMongoAtlasSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = (size = 48) => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -16,10 +16,9 @@ const generatePassword = (size = 48) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = alphaNumericNanoId(32);
if (!usernameTemplate) return randomUsername;
-
- return handlebars.compile(usernameTemplate)({
+ return compileUsernameTemplate({
+ usernameTemplate,
randomUsername,
- unixTimestamp: Math.floor(Date.now() / 100),
identityName
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts b/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts
index 0d1a4fd27e..4a25e8ce85 100644
--- a/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/mongo-db.ts
@@ -1,4 +1,3 @@
-import handlebars from "handlebars";
import { MongoClient } from "mongodb";
import { customAlphabet } from "nanoid";
import { z } from "zod";
@@ -7,6 +6,7 @@ import { alphaNumericNanoId } from "@app/lib/nanoid";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretMongoDBSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = (size = 48) => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -16,10 +16,9 @@ const generatePassword = (size = 48) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = alphaNumericNanoId(32);
if (!usernameTemplate) return randomUsername;
-
- return handlebars.compile(usernameTemplate)({
+ return compileUsernameTemplate({
+ usernameTemplate,
randomUsername,
- unixTimestamp: Math.floor(Date.now() / 100),
identityName
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/rabbit-mq.ts b/backend/src/ee/services/dynamic-secret/providers/rabbit-mq.ts
index 48c37179e9..91156fa3e2 100644
--- a/backend/src/ee/services/dynamic-secret/providers/rabbit-mq.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/rabbit-mq.ts
@@ -1,5 +1,4 @@
import axios, { Axios } from "axios";
-import handlebars from "handlebars";
import https from "https";
import { customAlphabet } from "nanoid";
import { z } from "zod";
@@ -9,6 +8,7 @@ import { alphaNumericNanoId } from "@app/lib/nanoid";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretRabbitMqSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = () => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -18,10 +18,9 @@ const generatePassword = () => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/redis.ts b/backend/src/ee/services/dynamic-secret/providers/redis.ts
index 6b0e719132..8584891091 100644
--- a/backend/src/ee/services/dynamic-secret/providers/redis.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/redis.ts
@@ -9,6 +9,7 @@ import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretRedisDBSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = () => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
@@ -18,10 +19,9 @@ const generatePassword = () => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/sap-ase.ts b/backend/src/ee/services/dynamic-secret/providers/sap-ase.ts
index 18dcbb90dc..f8b89f8b9b 100644
--- a/backend/src/ee/services/dynamic-secret/providers/sap-ase.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/sap-ase.ts
@@ -9,6 +9,7 @@ import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretSapAseSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = (size = 48) => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -18,10 +19,9 @@ const generatePassword = (size = 48) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = `inf_${alphaNumericNanoId(25)}`; // 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts b/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
index f5ccb222be..1c7357faca 100644
--- a/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/sap-hana.ts
@@ -15,6 +15,7 @@ import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretSapHanaSchema, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const generatePassword = (size = 48) => {
const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -24,10 +25,9 @@ const generatePassword = (size = 48) => {
const generateUsername = (usernameTemplate?: string | null, identityName?: string) => {
const randomUsername = 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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/snowflake.ts b/backend/src/ee/services/dynamic-secret/providers/snowflake.ts
index da8670aff5..110679ed9f 100644
--- a/backend/src/ee/services/dynamic-secret/providers/snowflake.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/snowflake.ts
@@ -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
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/sql-database.ts b/backend/src/ee/services/dynamic-secret/providers/sql-database.ts
index d20b1dd06c..13fc81b062 100644
--- a/backend/src/ee/services/dynamic-secret/providers/sql-database.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/sql-database.ts
@@ -10,6 +10,7 @@ import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars
import { TGatewayServiceFactory } from "../../gateway/gateway-service";
import { verifyHostInputValidity } from "../dynamic-secret-fns";
import { DynamicSecretSqlDBSchema, PasswordRequirements, SqlProviders, TDynamicProviderFns } from "./models";
+import { compileUsernameTemplate } from "./templateUtils";
const EXTERNAL_REQUEST_TIMEOUT = 10 * 1000;
@@ -113,11 +114,13 @@ const generateUsername = (provider: SqlProviders, usernameTemplate?: string | nu
randomUsername = alphaNumericNanoId(32);
}
if (!usernameTemplate) return randomUsername;
-
- return handlebars.compile(usernameTemplate)({
+ return compileUsernameTemplate({
+ usernameTemplate,
randomUsername,
- unixTimestamp: Math.floor(Date.now() / 100),
- identityName
+ identityName,
+ options: {
+ toUpperCase: provider === SqlProviders.Oracle
+ }
});
};
diff --git a/backend/src/ee/services/dynamic-secret/providers/templateUtils.ts b/backend/src/ee/services/dynamic-secret/providers/templateUtils.ts
new file mode 100644
index 0000000000..76d923ad1b
--- /dev/null
+++ b/backend/src/ee/services/dynamic-secret/providers/templateUtils.ts
@@ -0,0 +1,98 @@
+/* eslint-disable func-names */
+import handlebars from "handlebars";
+import RE2 from "re2";
+
+import { alphaNumericNanoId } from "@app/lib/nanoid";
+
+export const compileUsernameTemplate = ({
+ usernameTemplate,
+ randomUsername,
+ identityName,
+ unixTimestamp,
+ options
+}: {
+ usernameTemplate: string;
+ randomUsername: string;
+ identityName?: string;
+ unixTimestamp?: number;
+ options?: {
+ toUpperCase?: boolean;
+ };
+}): string => {
+ // Pre-process template to replace {{random-N}} patterns before compiling
+ let processedTemplate = usernameTemplate;
+ const randomPattern = /\{\{random-(\d+)\}\}/g;
+ let match;
+
+ // eslint-disable-next-line no-cond-assign
+ while ((match = randomPattern.exec(usernameTemplate)) !== null) {
+ const fullMatch = match[0];
+ const length = parseInt(match[1], 10);
+
+ if (length > 0 && length <= 100) {
+ const randomValue = alphaNumericNanoId(length);
+ processedTemplate = processedTemplate.replace(fullMatch, randomValue);
+ }
+ }
+
+ // Register replace helper
+ handlebars.registerHelper(
+ "replace",
+ function (text: string, searchValue: string, replaceValue: string, limit?: number) {
+ // Convert to string if it's not already
+ const textStr = String(text || "");
+ if (!textStr) {
+ return textStr;
+ }
+
+ try {
+ const re2Pattern = new RE2(searchValue, "g");
+
+ if (limit && limit > 0) {
+ // Replace only up to the specified limit
+ let count = 0;
+ return textStr.replace(re2Pattern, (textMatch) => {
+ if (count < limit) {
+ count += 1;
+ return replaceValue;
+ }
+ return textMatch;
+ });
+ }
+ // Replace all occurrences
+ return textStr.replace(re2Pattern, replaceValue);
+ } catch (error) {
+ return textStr;
+ }
+ }
+ );
+
+ // Register truncate helper
+ handlebars.registerHelper("truncate", function (text: string, length: number) {
+ // Convert to string if it's not already
+ const textStr = String(text || "");
+ if (!textStr) {
+ return textStr;
+ }
+
+ if (typeof length !== "number" || length <= 0) return textStr;
+ return textStr.substring(0, length);
+ });
+
+ // Compile template with context
+ const context = {
+ randomUsername,
+ unixTimestamp: unixTimestamp || Math.floor(Date.now() / 100),
+ identity: {
+ name: identityName
+ }
+ };
+
+ const result = handlebars.compile(processedTemplate)(context);
+
+ if (options?.toUpperCase) {
+ return result.toUpperCase();
+ }
+
+ return result;
+};
diff --git a/backend/src/lib/template/validate-handlebars.ts b/backend/src/lib/template/validate-handlebars.ts
index 08343e9629..e312a1d800 100644
--- a/backend/src/lib/template/validate-handlebars.ts
+++ b/backend/src/lib/template/validate-handlebars.ts
@@ -1,4 +1,5 @@
import handlebars from "handlebars";
+import RE2 from "re2";
import { BadRequestError } from "../errors";
import { logger } from "../logger";
@@ -7,13 +8,31 @@ type SanitizationArg = {
allowedExpressions?: (arg: string) => boolean;
};
+const randomPattern = new RE2("^random-\\d+$");
+
+const isValidExpression = (expression: string, dto: SanitizationArg): boolean => {
+ // Check for random-N pattern (e.g., random-16, random-8)
+ if (expression.startsWith("random-") && randomPattern.test(expression)) {
+ return true;
+ }
+
+ // Allow helper functions (replace, truncate)
+ const allowedHelpers = ["replace", "truncate"];
+ if (allowedHelpers.includes(expression)) {
+ return true;
+ }
+
+ // Check regular allowed expressions
+ return dto?.allowedExpressions?.(expression) || false;
+};
+
export const validateHandlebarTemplate = (templateName: string, template: string, dto: SanitizationArg) => {
const parsedAst = handlebars.parse(template);
parsedAst.body.forEach((el) => {
if (el.type === "ContentStatement") return;
if (el.type === "MustacheStatement" && "path" in el) {
const { path } = el as { type: "MustacheStatement"; path: { type: "PathExpression"; original: string } };
- if (path.type === "PathExpression" && dto?.allowedExpressions?.(path.original)) return;
+ if (path.type === "PathExpression" && isValidExpression(path.original, dto)) return;
}
logger.error(el, "Template sanitization failed");
throw new BadRequestError({ message: `Template sanitization failed: ${templateName}` });
@@ -26,7 +45,7 @@ export const isValidHandleBarTemplate = (template: string, dto: SanitizationArg)
if (el.type === "ContentStatement") return true;
if (el.type === "MustacheStatement" && "path" in el) {
const { path } = el as { type: "MustacheStatement"; path: { type: "PathExpression"; original: string } };
- if (path.type === "PathExpression" && dto?.allowedExpressions?.(path.original)) return true;
+ if (path.type === "PathExpression" && isValidExpression(path.original, dto)) return true;
}
return false;
});
diff --git a/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx b/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx
index c91b1acf76..b7c287d338 100644
--- a/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx
+++ b/docs/documentation/platform/dynamic-secrets/aws-elasticache.mdx
@@ -95,13 +95,28 @@ The Infisical AWS ElastiCache dynamic secret allows you to generate AWS ElastiCa
</Step>
<Step title="(Optional) Modify ElastiCache Statements">
![Modify ElastiCache Statements Modal](/images/platform/dynamic-secrets/modify-elasticache-statement.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+ <ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
<ParamField path="Customize ElastiCache Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the ElastiCache statement to your needs. This is useful if you want to only give access to a specific resource.
diff --git a/docs/documentation/platform/dynamic-secrets/aws-iam.mdx b/docs/documentation/platform/dynamic-secrets/aws-iam.mdx
index bc563a52e8..5c929feb25 100644
--- a/docs/documentation/platform/dynamic-secrets/aws-iam.mdx
+++ b/docs/documentation/platform/dynamic-secrets/aws-iam.mdx
@@ -105,14 +105,29 @@ Replace **\<account id\>** with your AWS account id and **\<aws-scope-path\>** w
The AWS IAM inline policy that should be attached to the created users. Multiple values can be provided by separating them with commas
</ParamField>
-<ParamField path="Username Template" type="string" default="{{randomUsername}}">
-Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
-Allowed template variables are
-- `{{randomUsername}}`: Random username string
-- `{{unixTimestamp}}`: Current Unix timestamp
-- `{{identityName}}`: Name of the identity that is generating the secret
-</ParamField>
+ <ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
![Dynamic Secret Setup Modal](../../../images/platform/dynamic-secrets/dynamic-secret-setup-modal-aws-iam.png)
diff --git a/docs/documentation/platform/dynamic-secrets/cassandra.mdx b/docs/documentation/platform/dynamic-secrets/cassandra.mdx
index 6752faa66e..5928e7315f 100644
--- a/docs/documentation/platform/dynamic-secrets/cassandra.mdx
+++ b/docs/documentation/platform/dynamic-secrets/cassandra.mdx
@@ -80,12 +80,27 @@ The above configuration allows user creation and granting permissions.
<Step title="(Optional) Modify CQL Statements">
![Modify CQL Statements Modal](../../../images/platform/dynamic-secrets/modify-cql-statements.png)
<ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
<ParamField path="Customize CQL Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the CQL statement to your needs. This is useful if you want to only give access to a specific key-space(s).
diff --git a/docs/documentation/platform/dynamic-secrets/elastic-search.mdx b/docs/documentation/platform/dynamic-secrets/elastic-search.mdx
index eec4813974..560e10d4d9 100644
--- a/docs/documentation/platform/dynamic-secrets/elastic-search.mdx
+++ b/docs/documentation/platform/dynamic-secrets/elastic-search.mdx
@@ -87,14 +87,29 @@ The port that your Elasticsearch instance is running on. _(Example: 9200)_
<ParamField path="CA(SSL)" type="string">
A CA may be required if your DB requires it for incoming connections. This is often the case when connecting to a managed service.
</ParamField>
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
![Dynamic Secret Setup Modal](../../../images/platform/dynamic-secrets/dynamic-secret-input-modal-elastic-search.png)
diff --git a/docs/documentation/platform/dynamic-secrets/ldap.mdx b/docs/documentation/platform/dynamic-secrets/ldap.mdx
index bb6fd0e07c..11557c6c86 100644
--- a/docs/documentation/platform/dynamic-secrets/ldap.mdx
+++ b/docs/documentation/platform/dynamic-secrets/ldap.mdx
@@ -123,14 +123,29 @@ The Infisical LDAP dynamic secret allows you to generate user credentials on dem
changetype: delete
```
</ParamField>
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
Allowed template variables are
- `{{randomUsername}}`: Random username string
- `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
</Step>
<Step title="Click `Submit`">
diff --git a/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx b/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx
index f619d0fadd..63ad908a02 100644
--- a/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx
+++ b/docs/documentation/platform/dynamic-secrets/mongo-atlas.mdx
@@ -63,14 +63,29 @@ Create a project scoped API Key with the required permission in your Mongo Atlas
![Modify Scope Modal](../../../images/platform/dynamic-secrets/advanced-option-atlas.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
<ParamField path="Customize Scope" type="string">
List that contains clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances that this database user can access. If omitted, MongoDB Cloud grants the database user access to all the clusters, MongoDB Atlas Data Lakes, and MongoDB Atlas Streams Instances in the project.
diff --git a/docs/documentation/platform/dynamic-secrets/mongo-db.mdx b/docs/documentation/platform/dynamic-secrets/mongo-db.mdx
index 756195f4ea..6815645636 100644
--- a/docs/documentation/platform/dynamic-secrets/mongo-db.mdx
+++ b/docs/documentation/platform/dynamic-secrets/mongo-db.mdx
@@ -66,13 +66,28 @@ Create a user with the required permission in your MongoDB instance. This user w
<ParamField path="CA(SSL)" type="string">
A CA may be required if your DB requires it for incoming connections.
</ParamField>
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
Allowed template variables are
- `{{randomUsername}}`: Random username string
- `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
![Dynamic Secret Setup Modal](../../../images/platform/dynamic-secrets/dynamic-secret-mongodb.png)
diff --git a/docs/documentation/platform/dynamic-secrets/mssql.mdx b/docs/documentation/platform/dynamic-secrets/mssql.mdx
index 24d48ee4c9..3347ebca48 100644
--- a/docs/documentation/platform/dynamic-secrets/mssql.mdx
+++ b/docs/documentation/platform/dynamic-secrets/mssql.mdx
@@ -9,7 +9,6 @@ The Infisical MS SQL dynamic secret allows you to generate Microsoft SQL server
Create a user with the required permission in your SQL instance. This user will be used to create new accounts on-demand.
-
## Set up Dynamic Secrets with MS SQL
<Steps>
@@ -27,105 +26,123 @@ Create a user with the required permission in your SQL instance. This user will
Name by which you want the secret to be referenced
</ParamField>
- <ParamField path="Default TTL" type="string" required>
- Default time-to-live for a generated secret (it is possible to modify this value after a secret is generated)
- </ParamField>
+ <ParamField path="Default TTL" type="string" required>
+ Default time-to-live for a generated secret (it is possible to modify this value after a secret is generated)
+ </ParamField>
- <ParamField path="Max TTL" type="string" required>
- Maximum time-to-live for a generated secret
- </ParamField>
+ <ParamField path="Max TTL" type="string" required>
+ Maximum time-to-live for a generated secret
+ </ParamField>
- <ParamField path="Metadata" type="list" required>
- List of key/value metadata pairs
- </ParamField>
+ <ParamField path="Metadata" type="list" required>
+ List of key/value metadata pairs
+ </ParamField>
- <ParamField path="Service" type="string" required>
- Choose the service you want to generate dynamic secrets for. This must be selected as **MS SQL**.
- </ParamField>
+ <ParamField path="Service" type="string" required>
+ Choose the service you want to generate dynamic secrets for. This must be selected as **MS SQL**.
+ </ParamField>
- <ParamField path="Host" type="string" required>
- Database host
- </ParamField>
+ <ParamField path="Host" type="string" required>
+ Database host
+ </ParamField>
- <ParamField path="Port" type="number" required>
- Database port
- </ParamField>
+ <ParamField path="Port" type="number" required>
+ Database port
+ </ParamField>
- <ParamField path="User" type="string" required>
- Username that will be used to create dynamic secrets
- </ParamField>
+ <ParamField path="User" type="string" required>
+ Username that will be used to create dynamic secrets
+ </ParamField>
- <ParamField path="Password" type="string" required>
- Password that will be used to create dynamic secrets
- </ParamField>
+ <ParamField path="Password" type="string" required>
+ Password that will be used to create dynamic secrets
+ </ParamField>
- <ParamField path="Database Name" type="string" required>
- Name of the database for which you want to create dynamic secrets
- </ParamField>
+ <ParamField path="Database Name" type="string" required>
+ Name of the database for which you want to create dynamic secrets
+ </ParamField>
- <ParamField path="CA(SSL)" type="string">
- A CA may be required if your DB requires it for incoming connections. AWS RDS instances with default settings will requires a CA which can be downloaded [here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html#UsingWithRDS.SSL.CertificatesAllRegions).
- </ParamField>
+ <ParamField path="CA(SSL)" type="string">
+ A CA may be required if your DB requires it for incoming connections. AWS RDS instances with default settings will requires a CA which can be downloaded [here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html#UsingWithRDS.SSL.CertificatesAllRegions).
+ </ParamField>
- ![Dynamic Secret Setup Modal](../../../images/platform/dynamic-secrets/dynamic-secret-setup-modal-mssql.png)
+ ![Dynamic Secret Setup Modal](../../../images/platform/dynamic-secrets/dynamic-secret-setup-modal-mssql.png)
</Step>
<Step title="(Optional) Modify SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/modify-sql-statements-mssql.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
- <ParamField path="Customize SQL Statement" type="string">
- If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL statement to your needs. This is useful if you want to only give access to a specific table(s).
- </ParamField>
</Step>
<Step title="Click 'Submit'">
After submitting the form, you will see a dynamic secret created in the dashboard.
- <Note>
- If this step fails, you may have to add the CA certificate.
- </Note>
+ <Note>
+ If this step fails, you may have to add the CA certificate.
+ </Note>
+
+ ![Dynamic Secret](../../../images/platform/dynamic-secrets/dynamic-secret.png)
- ![Dynamic Secret](../../../images/platform/dynamic-secrets/dynamic-secret.png)
</Step>
<Step title="Generate dynamic secrets">
Once you've successfully configured the dynamic secret, you're ready to generate on-demand credentials.
To do this, simply click on the 'Generate' button which appears when hovering over the dynamic secret item.
Alternatively, you can initiate the creation of a new lease by selecting 'New Lease' from the dynamic secret lease list section.
- ![Dynamic Secret](/images/platform/dynamic-secrets/dynamic-secret-generate.png)
- ![Dynamic Secret](/images/platform/dynamic-secrets/dynamic-secret-lease-empty.png)
+ ![Dynamic Secret](/images/platform/dynamic-secrets/dynamic-secret-generate.png)
+ ![Dynamic Secret](/images/platform/dynamic-secrets/dynamic-secret-lease-empty.png)
+
+ When generating these secrets, it's important to specify a Time-to-Live (TTL) duration. This will dictate how long the credentials are valid for.
- When generating these secrets, it's important to specify a Time-to-Live (TTL) duration. This will dictate how long the credentials are valid for.
+ ![Provision Lease](/images/platform/dynamic-secrets/provision-lease.png)
- ![Provision Lease](/images/platform/dynamic-secrets/provision-lease.png)
+ <Tip>
+ Ensure that the TTL for the lease fall within the maximum TTL defined when configuring the dynamic secret.
+ </Tip>
- <Tip>
- Ensure that the TTL for the lease fall within the maximum TTL defined when configuring the dynamic secret.
- </Tip>
+ Once you click the `Submit` button, a new secret lease will be generated and the credentials for it will be shown to you.
- Once you click the `Submit` button, a new secret lease will be generated and the credentials for it will be shown to you.
+ ![Provision Lease](/images/platform/dynamic-secrets/lease-values.png)
- ![Provision Lease](/images/platform/dynamic-secrets/lease-values.png)
</Step>
</Steps>
## Audit or Revoke Leases
+
Once you have created one or more leases, you will be able to access them by clicking on the respective dynamic secret item on the dashboard.
This will allow you to see the expiration time of the lease or delete the lease before it's set time to live.
![Provision Lease](/images/platform/dynamic-secrets/lease-data.png)
## Renew Leases
+
To extend the life of the generated dynamic secret leases past its initial time to live, simply click on the **Renew** button as illustrated below.
![Provision Lease](/images/platform/dynamic-secrets/dynamic-secret-lease-renew.png)
<Warning>
- Lease renewals cannot exceed the maximum TTL set when configuring the dynamic secret
+ Lease renewals cannot exceed the maximum TTL set when configuring the dynamic
+ secret
</Warning>
diff --git a/docs/documentation/platform/dynamic-secrets/mysql.mdx b/docs/documentation/platform/dynamic-secrets/mysql.mdx
index 4003d1eb5b..82f76bb467 100644
--- a/docs/documentation/platform/dynamic-secrets/mysql.mdx
+++ b/docs/documentation/platform/dynamic-secrets/mysql.mdx
@@ -69,16 +69,28 @@ Create a user with the required permission in your SQL instance. This user will
</Step>
<Step title="(Optional) Modify SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/modify-sql-statement-mysql.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
- <ParamField path="Customize SQL Statement" type="string">
- If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL statement to your needs. This is useful if you want to only give access to a specific table(s).
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
</Step>
<Step title="Click `Submit`">
diff --git a/docs/documentation/platform/dynamic-secrets/oracle.mdx b/docs/documentation/platform/dynamic-secrets/oracle.mdx
index b9527d700c..0f9c0aff15 100644
--- a/docs/documentation/platform/dynamic-secrets/oracle.mdx
+++ b/docs/documentation/platform/dynamic-secrets/oracle.mdx
@@ -71,16 +71,28 @@ Create a user with the required permission in your SQL instance. This user will
</Step>
<Step title="(Optional) Modify SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/modify-sql-statement-oracle.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
- <ParamField path="Customize SQL Statement" type="string">
- If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL statement to your needs. This is useful if you want to only give access to a specific table(s).
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
</Step>
<Step title="Click 'Submit'">
diff --git a/docs/documentation/platform/dynamic-secrets/postgresql.mdx b/docs/documentation/platform/dynamic-secrets/postgresql.mdx
index dbb73b51a5..29cf35c6ae 100644
--- a/docs/documentation/platform/dynamic-secrets/postgresql.mdx
+++ b/docs/documentation/platform/dynamic-secrets/postgresql.mdx
@@ -72,13 +72,28 @@ Create a user with the required permission in your SQL instance. This user will
</Step>
<Step title="(Optional) Modify SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/modify-sql-statements.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
<ParamField path="Customize SQL Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL statement to your needs. This is useful if you want to only give access to a specific table(s).
diff --git a/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx b/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx
index ac7ee50a97..9cd82f4991 100644
--- a/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx
+++ b/docs/documentation/platform/dynamic-secrets/rabbit-mq.mdx
@@ -66,13 +66,28 @@ The port that the RabbitMQ management plugin is listening on. This is `15672` by
</ParamField>
<ParamField path="Username Template" type="string" default="{{randomUsername}}">
-Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
-Allowed template variables are
-- `{{randomUsername}}`: Random username string
-- `{{unixTimestamp}}`: Current Unix timestamp
-- `{{identityName}}`: Name of the identity that is generating the secret
-</ParamField>
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
<ParamField path="CA(SSL)" type="string">
A CA may be required if your DB requires it for incoming connections. This is often the case when connecting to a managed service.
diff --git a/docs/documentation/platform/dynamic-secrets/redis.mdx b/docs/documentation/platform/dynamic-secrets/redis.mdx
index 528cbb56cd..6b3373c6cb 100644
--- a/docs/documentation/platform/dynamic-secrets/redis.mdx
+++ b/docs/documentation/platform/dynamic-secrets/redis.mdx
@@ -57,13 +57,28 @@ Create a user with the required permission in your Redis instance. This user wil
</Step>
<Step title="(Optional) Modify Redis Statements">
![Modify Redis Statements Modal](/images/platform/dynamic-secrets/modify-redis-statement.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
<ParamField path="Customize Redis Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the Redis statement to your needs. This is useful if you want to only give access to a specific table(s).
diff --git a/docs/documentation/platform/dynamic-secrets/sap-ase.mdx b/docs/documentation/platform/dynamic-secrets/sap-ase.mdx
index d4bbb54ea7..313533e5d9 100644
--- a/docs/documentation/platform/dynamic-secrets/sap-ase.mdx
+++ b/docs/documentation/platform/dynamic-secrets/sap-ase.mdx
@@ -64,14 +64,29 @@ The Infisical SAP ASE dynamic secret allows you to generate SAP ASE database cre
</Step>
<Step title="(Optional) Modify SAP SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/sap-ase/dynamic-secret-sap-ase-statements.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
<ParamField path="Customize Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL statement to your needs.
diff --git a/docs/documentation/platform/dynamic-secrets/sap-hana.mdx b/docs/documentation/platform/dynamic-secrets/sap-hana.mdx
index ec224b8b61..413e49c78a 100644
--- a/docs/documentation/platform/dynamic-secrets/sap-hana.mdx
+++ b/docs/documentation/platform/dynamic-secrets/sap-hana.mdx
@@ -64,13 +64,28 @@ The Infisical SAP HANA dynamic secret allows you to generate SAP HANA database c
</Step>
<Step title="(Optional) Modify SAP SQL Statements">
![Modify SQL Statements Modal](../../../images/platform/dynamic-secrets/modify-sap-hana-sql-statements.png)
- <ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
+<ParamField path="Username Template" type="string" default="{{randomUsername}}">
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
</ParamField>
<ParamField path="Customize Statement" type="string">
diff --git a/docs/documentation/platform/dynamic-secrets/snowflake.mdx b/docs/documentation/platform/dynamic-secrets/snowflake.mdx
index 13606a9019..e6cad24326 100644
--- a/docs/documentation/platform/dynamic-secrets/snowflake.mdx
+++ b/docs/documentation/platform/dynamic-secrets/snowflake.mdx
@@ -78,13 +78,28 @@ Infisical's Snowflake dynamic secrets allow you to generate Snowflake user crede
<Step title="(Optional) Modify SQL Statements">
![Modify SQL Statements Modal](/images/platform/dynamic-secrets/snowflake/dynamic-secret-snowflake-sql-statements.png)
<ParamField path="Username Template" type="string" default="{{randomUsername}}">
- Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
-
- Allowed template variables are
- - `{{randomUsername}}`: Random username string
- - `{{unixTimestamp}}`: Current Unix timestamp
- - `{{identityName}}`: Name of the identity that is generating the secret
- </ParamField>
+ Specifies a template for generating usernames. This field allows customization of how usernames are automatically created.
+
+ Allowed template variables are
+ - `{{randomUsername}}`: Random username string
+ - `{{unixTimestamp}}`: Current Unix timestamp
+ - `{{identity.name}}`: Name of the identity that is generating the secret
+ - `{{random-N}}`: Random string of N characters
+
+ Allowed template functions are
+ - `truncate`: Truncates a string to a specified length
+ - `replace`: Replaces a substring with another value
+
+ Examples:
+ ```
+ {{randomUsername}} // 3POnzeFyK9gW2nioK0q2gMjr6CZqsRiX
+ {{unixTimestamp}} // 17490641580
+ {{identity.name}} // testuser
+ {{random-5}} // x9k2m
+ {{truncate identity.name 4}} // test
+ {{replace identity.name 'user' 'replace'}} // testreplace
+ ```
+ </ParamField>
<ParamField path="Customize Statement" type="string">
If you want to provide specific privileges for the generated dynamic credentials, you can modify the SQL