mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 07:26:45 +00:00
requested changes
This commit is contained in:
+21
-14
@@ -61,21 +61,23 @@ export const redisCredentialsRotationFactory: TRotationFactory<
|
||||
* Creates a new user and password for the redis user using ACL
|
||||
*/
|
||||
const $rotateAclUser = async () => {
|
||||
const client = await $getClient();
|
||||
|
||||
const username = generatePassword({
|
||||
length: 32,
|
||||
required: {
|
||||
symbols: 0,
|
||||
digits: 5,
|
||||
uppercase: 5,
|
||||
lowercase: 5
|
||||
}
|
||||
});
|
||||
|
||||
const password = generatePassword(parameters.passwordRequirements || DEFAULT_PASSWORD_REQUIREMENTS);
|
||||
let client: Redis | null = null;
|
||||
|
||||
try {
|
||||
client = await $getClient();
|
||||
|
||||
const username = generatePassword({
|
||||
length: 32,
|
||||
required: {
|
||||
symbols: 0,
|
||||
digits: 5,
|
||||
uppercase: 5,
|
||||
lowercase: 5
|
||||
}
|
||||
});
|
||||
|
||||
const password = generatePassword(parameters.passwordRequirements || DEFAULT_PASSWORD_REQUIREMENTS);
|
||||
|
||||
// important: permissionScope is user input so we need to sanitize it, which we do by splitting the permission scope into parts and then passing them to the ACL command as separate arguments
|
||||
const permissionParts = (parameters.permissionScope || "~* +@all").split(" ");
|
||||
await client.call("ACL", "SETUSER", username, `>${password}`, "on", ...permissionParts);
|
||||
@@ -88,6 +90,8 @@ export const redisCredentialsRotationFactory: TRotationFactory<
|
||||
throw new BadRequestError({
|
||||
message: "Unable to validate connection: verify credentials"
|
||||
});
|
||||
} finally {
|
||||
if (client) await client.quit();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -95,14 +99,17 @@ export const redisCredentialsRotationFactory: TRotationFactory<
|
||||
* Revokes a ACL password from the Redis server using its username and password.
|
||||
*/
|
||||
const revokeCredential = async (username: string) => {
|
||||
const client = await $getClient();
|
||||
let client: Redis | null = null;
|
||||
|
||||
try {
|
||||
client = await $getClient();
|
||||
await client.call("ACL", "DELUSER", username);
|
||||
} catch (error: unknown) {
|
||||
throw new BadRequestError({
|
||||
message: "Unable to revoke credential: verify credentials"
|
||||
});
|
||||
} finally {
|
||||
if (client) await client.quit();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -61,8 +61,8 @@ export const ValidateRedisConnectionCredentialsSchema = z.discriminatedUnion("me
|
||||
|
||||
export const CreateRedisConnectionSchema = ValidateRedisConnectionCredentialsSchema.and(
|
||||
GenericCreateAppConnectionFieldsSchema(AppConnection.Redis, {
|
||||
supportsPlatformManagedCredentials: true,
|
||||
supportsGateways: true
|
||||
supportsPlatformManagedCredentials: false,
|
||||
supportsGateways: false
|
||||
})
|
||||
);
|
||||
|
||||
@@ -74,8 +74,8 @@ export const UpdateRedisConnectionSchema = z
|
||||
})
|
||||
.and(
|
||||
GenericUpdateAppConnectionFieldsSchema(AppConnection.Redis, {
|
||||
supportsPlatformManagedCredentials: true,
|
||||
supportsGateways: true
|
||||
supportsPlatformManagedCredentials: false,
|
||||
supportsGateways: false
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user