Allow server admins to grant server admin access to other users

This commit is contained in:
carlosmonastyrski
2025-03-04 12:38:27 -03:00
parent e5bca5b5df
commit be4adc2759
5 changed files with 134 additions and 24 deletions
@@ -291,6 +291,18 @@ export const superAdminServiceFactory = ({
return user;
};
const grantServerAdminAccessToUser = async (userId: string) => {
if (!licenseService.onPremFeatures?.instanceUserManagement) {
throw new BadRequestError({
message: "Failed to grant server admin access to user due to plan restriction. Upgrade to Infisical's Pro plan."
});
}
await userDAL.transaction(async (tx) => {
await userDAL.updateById(userId, { superAdmin: true }, tx);
});
};
const getAdminSlackConfig = async () => {
const serverCfg = await serverCfgDAL.findById(ADMIN_CONFIG_DB_UUID);
@@ -381,6 +393,7 @@ export const superAdminServiceFactory = ({
deleteUser,
getAdminSlackConfig,
updateRootEncryptionStrategy,
getConfiguredEncryptionStrategies
getConfiguredEncryptionStrategies,
grantServerAdminAccessToUser
};
};