mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 09:28:28 +00:00
only list compartments which the user is authorized to 'use vaults' in
This commit is contained in:
@@ -59,6 +59,9 @@ export const listOCICompartments = async (appConnection: TOCIConnection) => {
|
|||||||
const provider = await getOCIProvider(appConnection);
|
const provider = await getOCIProvider(appConnection);
|
||||||
|
|
||||||
const identityClient = new identity.IdentityClient({ authenticationDetailsProvider: provider });
|
const identityClient = new identity.IdentityClient({ authenticationDetailsProvider: provider });
|
||||||
|
const keyManagementClient = new keymanagement.KmsVaultClient({
|
||||||
|
authenticationDetailsProvider: provider
|
||||||
|
});
|
||||||
|
|
||||||
const rootCompartment = await identityClient
|
const rootCompartment = await identityClient
|
||||||
.getTenancy({
|
.getTenancy({
|
||||||
@@ -77,7 +80,24 @@ export const listOCICompartments = async (appConnection: TOCIConnection) => {
|
|||||||
lifecycleState: identity.models.Compartment.LifecycleState.Active
|
lifecycleState: identity.models.Compartment.LifecycleState.Active
|
||||||
});
|
});
|
||||||
|
|
||||||
return [rootCompartment, ...compartments.items];
|
const allCompartments = [rootCompartment, ...compartments.items];
|
||||||
|
const filteredCompartments = [];
|
||||||
|
|
||||||
|
for await (const compartment of allCompartments) {
|
||||||
|
try {
|
||||||
|
// Check if user can list vaults in this compartment
|
||||||
|
await keyManagementClient.listVaults({
|
||||||
|
compartmentId: compartment.id,
|
||||||
|
limit: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
filteredCompartments.push(compartment);
|
||||||
|
} catch (error) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredCompartments;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const listOCIVaults = async (appConnection: TOCIConnection, compartmentOcid: string) => {
|
export const listOCIVaults = async (appConnection: TOCIConnection, compartmentOcid: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user