Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix(agent-vault): address review on sessions on behalf of users
Scott Wilsone7c7b8485cc6
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.tsindex a1f71bd6a1..bdedfe76bc 100644--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts@@ -4196,6 +4196,34 @@ describe("Agent Vault V1 Router", async () => {}});+ test("an identity granted no bundles learns nothing about a user by listing on their behalf", async () => {+ const projectId = await getProjectId();+ const bot = await createMemberIdentity(`obo-probe-bot-${Date.now()}`);+ const alice = await createAgentVaultUser("obo-probe-alice", projectId);+ const outsider = await createAgentVaultUser("obo-probe-outsider", null);+ const bundle = await createAccessBundle(`obo-probe-${Date.now()}`);+ const listFor = (query: string) => bot.as("GET", `/api/v1/agent-vault/access-bundles?${query}`);+ try {+ await grantBundle(bundle.id, { userIds: [alice.userId] });+ await delegate(bot, { scope: "all-members" });++ // A member of Agent Vault, an org member outside it, and no one at all read the same.+ const replies = await Promise.all([+ listFor(`onBehalfOfUserId=${alice.userId}`),+ listFor(`onBehalfOfUserId=${outsider.userId}`),+ listFor(`onBehalfOfUserId=${crypto.randomUUID()}`),+ listFor(`onBehalfOfUserEmail=${encodeURIComponent(`obo-probe-nobody-${Date.now()}@example.com`)}`)+ ]);+ replies.forEach((reply) => {+ expect(reply.statusCode).toBe(200);+ expect(reply.json()).toMatchObject({ accessBundles: [], totalCount: 0 });+ });+ } finally {+ await bot.cleanup();+ await deleteUsers([alice.userId, outsider.userId]);+ }+ });+test("all-members covers every Agent Vault member and no one outside Agent Vault", async () => {const projectId = await getProjectId();const bundle = await createAccessBundle(`obo-all-${Date.now()}`);@@ -4366,6 +4394,47 @@ describe("Agent Vault V1 Router", async () => {}});+ // Nothing stops an identity being named "", and the name is what marks a session as started on someone's behalf.+ test("a session started by an identity named '' is checked like any other on a user's behalf", async () => {+ const bundle = await createAccessBundle(`obo-unnamed-${Date.now()}`);+ const proxy = await inject("POST", "/api/v1/agent-vault/proxies", { name: `obo-unnamed-${Date.now()}` });+ expect(proxy.statusCode).toBe(200);+ const proxyToken = proxy.json().proxyToken as string;+ const resolve = (sessionToken: string) =>+ testServer.inject({+ method: "POST",+ url: "/api/v1/agent-vault/proxy/resolve",+ headers: { authorization: `Bearer ${proxyToken}`, "x-infisical-agent-session": sessionToken }+ });++ const bot = await createMemberIdentity("");+ try {+ await grantBundle(bundle.id, { machineIdentityIds: [bot.id] });+ await delegate(bot, { scope: "selected", userIds: [seedData1.id] });+ const minted = await mintFor(bot, { userId: seedData1.id }, bundle.name);+ expect(minted.statusCode).toBe(200);+ const { id, token } = minted.json().session as { id: string; token: string };++ expect((await inject("GET", `${sessionsUrl}/${id}`)).json().session.actingIdentity).toEqual({+ id: bot.id,+ name: ""+ });+ expect((await resolve(token)).statusCode).toBe(200);++ // The seeded admin still reaches the bundle, so only the delegation check can stop the session.+ expect((await inject("DELETE", delegationUrl(bot.id))).statusCode).toBe(200);+ expect((await resolve(token)).statusCode).toBe(401);++ await bot.cleanup();+ expect((await inject("GET", `${sessionsUrl}/${id}`)).json().session).toMatchObject({+ status: "revoked",+ actingIdentity: { id: null, name: "" }+ });+ } finally {+ await bot.cleanup();+ }+ });+test("a delegation names Agent Vault members, and only an admin or the identity itself reads it", async () => {const projectId = await getProjectId();const bot = await createMemberIdentity(`obo-api-bot-${Date.now()}`);@@ -4400,9 +4469,17 @@ describe("Agent Vault V1 Router", async () => {}expect((await bot.as("GET", delegationUrl(bot.id))).statusCode).toBe(200);- expect((await other.as("GET", delegationUrl(bot.id))).statusCode).toBe(403);- expect((await other.as("PUT", delegationUrl(other.id), { scope: "all-members" })).statusCode).toBe(403);- expect((await bot.as("GET", delegationsUrl)).statusCode).toBe(403);+ // Each refusal is a CASL denial, which is what the audit log records as a permission denial.+ const refused = await Promise.all([+ other.as("GET", delegationUrl(bot.id)),+ other.as("PUT", delegationUrl(other.id), { scope: "all-members" }),+ other.as("DELETE", delegationUrl(bot.id)),+ bot.as("GET", delegationsUrl)+ ]);+ refused.forEach((res) => {+ expect(res.statusCode).toBe(403);+ expect(res.json().error).toBe("PermissionDenied");+ });const listed = await inject("GET", `${delegationsUrl}?machineIdentityIds=${bot.id},${other.id}`);expect(listed.statusCode).toBe(200);@@ -4424,6 +4501,128 @@ describe("Agent Vault V1 Router", async () => {}});+ test("removing a user or group from Agent Vault takes them out of every delegation", async () => {+ const projectId = await getProjectId();+ const membersUrl = "/api/v1/agent-vault/members";+ const bot = await createMemberIdentity(`obo-leave-bot-${Date.now()}`);+ const aliceOnlyBot = await createMemberIdentity(`obo-leave-alice-bot-${Date.now()}`);+ const everyoneBot = await createMemberIdentity(`obo-leave-everyone-bot-${Date.now()}`);+ const alice = await createAgentVaultUser("obo-leave-alice", projectId);+ const bob = await createAgentVaultUser("obo-leave-bob", projectId);+ const group = await createProjectGroup(projectId, `obo-leave-group-${Date.now()}`, ProjectMembershipRole.Member);+ const namedBy = async (identity: TMember) => {+ const res = await inject("GET", delegationUrl(identity.id));+ if (res.statusCode === 404) return null;+ const delegation = res.json().delegation as TDelegationDetail;+ return { users: delegation.users.map((row) => row.id), groups: delegation.groups.map((row) => row.id) };+ };+ try {+ await delegate(bot, { scope: "selected", userIds: [alice.userId, bob.userId], groupIds: [group.id] });+ await delegate(aliceOnlyBot, { scope: "selected", userIds: [alice.userId] });+ await delegate(everyoneBot, { scope: "all-members" });++ // A selected delegation left naming no one goes, since it would act for no one.+ expect((await inject("DELETE", membersUrl, { userIds: [alice.userId] })).statusCode).toBe(200);+ expect(await namedBy(bot)).toEqual({ users: [bob.userId], groups: [group.id] });+ expect(await namedBy(aliceOnlyBot)).toBeNull();++ expect((await inject("DELETE", membersUrl, { groupIds: [group.id] })).statusCode).toBe(200);+ expect(await namedBy(bot)).toEqual({ users: [bob.userId], groups: [] });++ // Adding Alice back to Agent Vault doesn't add her back to any delegation.+ const readded = await inject("POST", membersUrl, {+ userIds: [alice.userId],+ role: ProjectMembershipRole.Member+ });+ expect(readded.statusCode).toBe(200);+ expect(await namedBy(bot)).toEqual({ users: [bob.userId], groups: [] });+ expect(await namedBy(aliceOnlyBot)).toBeNull();+ expect(await namedBy(everyoneBot)).toEqual({ users: [], groups: [] });+ } finally {+ await bot.cleanup();+ await aliceOnlyBot.cleanup();+ await everyoneBot.cleanup();+ await deleteUsers([alice.userId, bob.userId]);+ await group.cleanup();+ }+ });++ test("a save checks only the users and groups it adds", async () => {+ const projectId = await getProjectId();+ const bot = await createMemberIdentity(`obo-departed-bot-${Date.now()}`);+ const alice = await createAgentVaultUser("obo-departed-alice", projectId);+ const carol = await createAgentVaultUser("obo-departed-carol", projectId);+ const dave = await createAgentVaultUser("obo-departed-dave", projectId);+ const userIdsOf = (delegation: TDelegationDetail) => delegation.users.map((row) => row.id).sort();+ try {+ await delegate(bot, { scope: "selected", userIds: [alice.userId, carol.userId] });+ // Leaving the organization deletes the Agent Vault membership without Agent Vault's own removal.+ await testDb("memberships")+ .where({ scope: AccessScope.Project, scopeProjectId: projectId, actorUserId: carol.userId })+ .delete();++ const kept = await delegate(bot, { scope: "selected", userIds: [alice.userId, carol.userId, dave.userId] });+ expect(userIdsOf(kept)).toEqual([alice.userId, carol.userId, dave.userId].sort());+ const removed = await delegate(bot, { scope: "selected", userIds: [alice.userId, dave.userId] });+ expect(userIdsOf(removed)).toEqual([alice.userId, dave.userId].sort());++ const added = await inject("PUT", delegationUrl(bot.id), {+ scope: "selected",+ userIds: [alice.userId, carol.userId]+ });+ expect(added.statusCode).toBe(400);+ expect(added.json().message).toBe(+ `User(s) '${carol.userId}' are not members of Agent Vault. Add them under Access Control first.`+ );+ } finally {+ await bot.cleanup();+ await deleteUsers([alice.userId, carol.userId, dave.userId]);+ }+ });++ test("a save waits for a removal from Agent Vault in flight, and then refuses what it removed", async () => {+ const projectId = await getProjectId();+ const bot = await createMemberIdentity(`obo-race-bot-${Date.now()}`);+ const alice = await createAgentVaultUser("obo-race-alice", projectId);+ // Stands in for a removal: its transaction deletes the membership, and commits once the rest of its cleanup is done.+ const saveDuringRemoval = async (+ actor: { actorIdentityId: string } | { actorUserId: string },+ save: () => ReturnType<typeof inject>+ ) => {+ const trx = await testDb.transaction();+ try {+ const { rows } = await trx.raw("select pg_backend_pid() as pid");+ await trx("memberships")+ .where({ scope: AccessScope.Project, scopeProjectId: projectId, ...actor })+ .delete();++ const pending = save();+ await waitUntilBlockedBy(rows[0].pid);+ await trx.commit();+ return await pending;+ } catch (err) {+ if (!trx.isCompleted()) await trx.rollback();+ throw err;+ }+ };+ try {+ const forAlice = await saveDuringRemoval({ actorUserId: alice.userId }, () =>+ inject("PUT", delegationUrl(bot.id), { scope: "selected", userIds: [alice.userId] })+ );+ expect(forAlice.statusCode).toBe(400);+ expect(forAlice.json().message).toContain("are not members of Agent Vault");++ const ofBot = await saveDuringRemoval({ actorIdentityId: bot.id }, () =>+ inject("PUT", delegationUrl(bot.id), { scope: "all-members" })+ );+ expect(ofBot.statusCode).toBe(404);+ expect((await inject("GET", delegationUrl(bot.id))).statusCode).toBe(404);+ } finally {+ await bot.cleanup();+ await deleteUsers([alice.userId]);+ }+ });+test("a delegation shows the bundles each user and group can use that the identity can't", async () => {const projectId = await getProjectId();const stamp = Date.now();@@ -4435,6 +4634,14 @@ describe("Agent Vault V1 Router", async () => {const group = await createProjectGroup(projectId, `obo-gap-group-${stamp}`, ProjectMembershipRole.Member);const admins = await createProjectGroup(projectId, `obo-gap-admins-${stamp}`, ProjectMembershipRole.Admin);const names = (row: TMissing) => row.missingAccessBundles.map((bundle) => bundle.name);+ // The missing bundles were never granted to the identity, so its own read leaves every list empty.+ const expectOwnReadWithoutMissing = async () => {+ const res = await bot.as("GET", delegationUrl(bot.id));+ expect(res.statusCode).toBe(200);+ const own = res.json().delegation as TDelegationDetail;+ expect([own, ...own.users, ...own.groups].flatMap((row) => names(row))).toEqual([]);+ return own;+ };const read = async () => {const res = await inject("GET", delegationUrl(bot.id));expect(res.statusCode).toBe(200);@@ -4465,6 +4672,9 @@ describe("Agent Vault V1 Router", async () => {expect(row).toEqual(expect.arrayContaining([alicesOnly.name, groupsOnly.name]));expect(row).not.toContain(shared.name);});+ const own = await expectOwnReadWithoutMissing();+ expect(own.users.map((row) => row.id)).toEqual(expect.arrayContaining([alice.userId, seedData1.id]));+ expect(own.groups.map((row) => row.id)).toEqual(expect.arrayContaining([group.id, admins.id]));await grantBundle(alicesOnly.id, { machineIdentityIds: [bot.id] });const after = await read();@@ -4476,6 +4686,7 @@ describe("Agent Vault V1 Router", async () => {expect(names(allMembers)).toContain(groupsOnly.name);expect(names(allMembers)).not.toContain(shared.name);expect(names(allMembers)).not.toContain(alicesOnly.name);+ await expectOwnReadWithoutMissing();// An admin identity can use every bundle, so nothing is missing. It's promoted before anything reads its// permission, since a role change reaches the permission cache only after its marker expires.diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-delegation-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-delegation-router.tsindex 290c6ab591..3a4ce1962b 100644--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-delegation-router.ts+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-delegation-router.ts@@ -41,8 +41,8 @@ const DelegationSchema = z.object({scope: DelegationScopeSchema,users: DelegationUserSchema.array().describe(AGENT_VAULT.DELEGATION.users),groups: DelegationGroupSchema.array().describe(AGENT_VAULT.DELEGATION.groups),- createdAt: z.date(),- updatedAt: z.date()+ createdAt: z.date().describe(AGENT_VAULT.DELEGATION.createdAt),+ updatedAt: z.date().describe(AGENT_VAULT.DELEGATION.updatedAt)});const missingAccessBundlesSchema = (description: string) =>@@ -104,7 +104,10 @@ export const registerAgentVaultDelegationRouter = async (server: FastifyZodProvioffset: z.coerce.number().int().min(0).max(10000).default(0).describe(AGENT_VAULT.DELEGATION.offset)}),response: {- 200: z.object({ delegations: DelegationSchema.array(), totalCount: z.number() })+ 200: z.object({+ delegations: DelegationSchema.array(),+ totalCount: z.number().describe(AGENT_VAULT.DELEGATION.totalCount)+ })}},onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),diff --git a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.tsindex 881f9b2522..9418b42b9d 100644--- a/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts+++ b/backend/src/ee/services/agent-vault-access-bundle/agent-vault-access-bundle-service.ts@@ -605,7 +605,8 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBund};// What a session on the user's behalf could use: the bundles both the user and the caller reach, counted against- // the user's personal values. It runs the same checks as minting that session, so it reveals no more about the org.+ // the user's personal values. Like minting that session, it checks the delegation and then the caller's own bundles+ // before it looks the user up, so a caller granted no bundle learns nothing about who is in the org.const $onBehalfOfListScope = async ({projectId,ctx,@@ -618,6 +619,10 @@ export const agentVaultAccessBundleServiceFactory = (deps: TAgentVaultAccessBundcallerAccessBundleIds: string[] | null;}) => {const delegation = await findCallerDelegation({ agentVaultDelegationDAL }, { projectId, ctx });+ if (callerAccessBundleIds?.length === 0) {+ return { scopeIds: [] as string[], excludeIds: [] as string[], owner: null };+ }+const { user, accessBundleIds: userAccessBundleIds } = await resolveOnBehalfOfUser({ agentVaultDelegationDAL, userDAL, orgDAL, permissionService, membershipDAL },{ projectId, ctx, onBehalfOf, delegation }diff --git a/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-dal.ts b/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-dal.tsindex f0c5ad4cef..d24908f707 100644--- a/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-dal.ts+++ b/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-dal.ts@@ -1,7 +1,7 @@import { Knex } from "knex";import { TDbClient } from "@app/db";-import { TableName, TAgentVaultDelegations } from "@app/db/schemas";+import { AccessScope, TableName, TAgentVaultDelegations, TMemberships } from "@app/db/schemas";import { DatabaseError } from "@app/lib/errors";import { ormify, selectAllTableCols } from "@app/lib/knex";@@ -190,7 +190,83 @@ export const agentVaultDelegationDALFactory = (db: TDbClient) => {return delegation ? coversUser({ delegation, userId }, tx) : false;};- return { ...orm, upsertScope, findViews, coversUser, identityCoversUser };+ /**+ * The Agent Vault memberships of the identity and of the users and groups a save names, taken FOR SHARE. Removing a+ * member deletes its row in a transaction of its own, so a save waits for a removal in flight and then sees the row+ * gone, and a removal that starts later waits for the save and then clears what it wrote.+ */+ const lockMemberships = async (+ {+ projectId,+ identityId,+ userIds,+ groupIds+ }: { projectId: string; identityId: string; userIds: string[]; groupIds: string[] },+ tx: Knex+ ) => {+ try {+ return (await tx(TableName.Membership)+ .where(`${TableName.Membership}.scope`, AccessScope.Project)+ .where(`${TableName.Membership}.scopeProjectId`, projectId)+ .where((actor) => {+ void actor.where(`${TableName.Membership}.actorIdentityId`, identityId);+ if (userIds.length) void actor.orWhereIn(`${TableName.Membership}.actorUserId`, userIds);+ if (groupIds.length) void actor.orWhereIn(`${TableName.Membership}.actorGroupId`, groupIds);+ })+ .forShare()+ .select(+ db.ref("actorIdentityId").withSchema(TableName.Membership),+ db.ref("actorUserId").withSchema(TableName.Membership),+ db.ref("actorGroupId").withSchema(TableName.Membership)+ )) as Pick<TMemberships, "actorIdentityId" | "actorUserId" | "actorGroupId">[];+ } catch (error) {+ throw new DatabaseError({ error, name: "Lock Agent Vault memberships for a delegation" });+ }+ };++ /**+ * Takes users and groups leaving Agent Vault out of the project's delegations, and deletes a selected delegation+ * left naming no one. The delegations that name them are locked first, so a save to one waits instead of changing+ * it between these statements.+ */+ const removeSubjects = async (+ { projectId, userIds, groupIds }: { projectId: string; userIds: string[]; groupIds: string[] },+ tx: Knex+ ) => {+ if (!userIds.length && !groupIds.length) return;+ const subjects = TableName.AgentVaultDelegationSubject;+ const ofDelegation = () =>+ tx(subjects)+ .whereRaw(`??.?? = ??.??`, [subjects, "delegationId", TableName.AgentVaultDelegation, "id"])+ .select(tx.raw("1"));+ const namingThem = (query: Knex.QueryBuilder) =>+ query.where((subject) => {+ if (userIds.length) void subject.orWhereIn(`${subjects}.userId`, userIds);+ if (groupIds.length) void subject.orWhereIn(`${subjects}.groupId`, groupIds);+ });++ try {+ const delegationIds = (+ (await tx(TableName.AgentVaultDelegation)+ .where(`${TableName.AgentVaultDelegation}.projectId`, projectId)+ .whereExists(namingThem(ofDelegation()))+ .forUpdate()+ .select(db.ref("id").withSchema(TableName.AgentVaultDelegation))) as { id: string }[]+ ).map((row) => row.id);+ if (!delegationIds.length) return;++ await namingThem(tx(subjects).whereIn(`${subjects}.delegationId`, delegationIds)).delete();+ await tx(TableName.AgentVaultDelegation)+ .whereIn(`${TableName.AgentVaultDelegation}.id`, delegationIds)+ .where(`${TableName.AgentVaultDelegation}.scope`, AgentVaultDelegationScope.Selected)+ .whereNotExists(ofDelegation())+ .delete();+ } catch (error) {+ throw new DatabaseError({ error, name: "Remove users and groups from Agent Vault delegations" });+ }+ };++ return { ...orm, upsertScope, findViews, coversUser, identityCoversUser, lockMemberships, removeSubjects };};export const agentVaultDelegationSubjectDALFactory = (db: TDbClient) =>diff --git a/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-service.ts b/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-service.tsindex f961a63819..d7150167f7 100644--- a/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-service.ts+++ b/backend/src/ee/services/agent-vault-delegation/agent-vault-delegation-service.ts@@ -1,7 +1,11 @@-import { AccessScope, ProjectMembershipRole, RESOURCE_SCOPE, ResourceType } from "@app/db/schemas";+import { ForbiddenError, subject } from "@casl/ability";+import { Knex } from "knex";++import { AccessScope, ProjectMembershipRole, RESOURCE_SCOPE, ResourceType, TMemberships } from "@app/db/schemas";import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";import { isActiveRole } from "@app/ee/services/permission/permission-fns";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";+import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";import { TGenericPermission } from "@app/lib/types";import { ActorType } from "@app/services/auth/auth-type";@@ -26,11 +30,11 @@ import {type TAgentVaultDelegationServiceFactoryDep = {agentVaultDelegationDAL: Pick<TAgentVaultDelegationDALFactory,- "upsertScope" | "findViews" | "delete" | "transaction"+ "upsertScope" | "findViews" | "delete" | "transaction" | "lockMemberships">;agentVaultDelegationSubjectDAL: Pick<TAgentVaultDelegationSubjectDALFactory, "find" | "delete" | "insertMany">;agentVaultAccessBundleDAL: Pick<TAgentVaultAccessBundleDALFactory, "find">;- membershipDAL: Pick<TMembershipDALFactory, "find" | "findOne" | "findResourceMembershipsForActor">;+ membershipDAL: Pick<TMembershipDALFactory, "find" | "findResourceMembershipsForActor">;membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;userGroupMembershipDAL: Pick<TUserGroupMembershipDALFactory, "find">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;@@ -43,6 +47,13 @@ type TMissingAccessBundle = { id: string; name: string };// The row id stays internal: a delegation is named by its machine identity, the one id a client sends back.const toDelegation = ({ id, ...delegation }: TAgentVaultDelegationView) => delegation;+const withNoMissingAccessBundles = (delegation: TAgentVaultDelegationView) => ({+ ...toDelegation(delegation),+ users: delegation.users.map((user) => ({ ...user, missingAccessBundles: [] as TMissingAccessBundle[] })),+ groups: delegation.groups.map((group) => ({ ...group, missingAccessBundles: [] as TMissingAccessBundle[] })),+ missingAccessBundles: [] as TMissingAccessBundle[]+});+const quoted = (ids: string[]) => ids.map((id) => `'${id}'`).join(", ");export const agentVaultDelegationServiceFactory = ({@@ -54,13 +65,19 @@ export const agentVaultDelegationServiceFactory = ({userGroupMembershipDAL,permissionService}: TAgentVaultDelegationServiceFactoryDep) => {- const checkAdmin = async (projectId: string, ctx: TGenericPermission) => {- const { isAdmin } = await getAgentVaultPermission({ permissionService }, { projectId, ctx });- if (!isAdmin) {- throw new ForbiddenRequestError({- message: "Only Agent Vault admins can manage which users a machine identity acts on behalf of"- });- }+ // A delegation says whom an identity can act as, so managing one is managing the identity, which in Agent Vault only+ // the admin role can do.+ const checkIdentityPermission = async (+ { projectId, ctx, machineIdentityId }: { projectId: string; ctx: TGenericPermission; machineIdentityId?: string },+ action: ProjectPermissionIdentityActions+ ) => {+ const { permission } = await getAgentVaultPermission({ permissionService }, { projectId, ctx });+ ForbiddenError.from(permission).throwUnlessCan(+ action,+ machineIdentityId+ ? subject(ProjectPermissionSub.Identity, { identityId: machineIdentityId })+ : ProjectPermissionSub.Identity+ );};const notFound = (machineIdentityId: string) =>@@ -68,26 +85,23 @@ export const agentVaultDelegationServiceFactory = ({message: `Machine identity with ID '${machineIdentityId}' has no delegation, so it can't act on behalf of users`});- // The same rule as granting an access bundle: a subject is named by its own Agent Vault membership.- const assertSubjectsInAgentVault = async ({- projectId,- userIds,- groupIds- }: {- projectId: string;- userIds: string[];- groupIds: string[];- }) => {- const projectScoped = (column: "actorUserId" | "actorGroupId", ids: string[]) =>- ids.length- ? membershipDAL.find({ scope: AccessScope.Project, scopeProjectId: projectId, $in: { [column]: ids } })- : [];- const [userRows, groupRows] = await Promise.all([- projectScoped("actorUserId", userIds),- projectScoped("actorGroupId", groupIds)- ]);-- const memberGroups = new Set(groupRows.map((row) => row.actorGroupId));+ // The same rule as granting an access bundle: a subject is named by its own Agent Vault membership. The memberships+ // are the rows the save holds locked, so no removal can land between this check and the write.+ const assertSubjectsInAgentVault = async (+ {+ projectId,+ userIds,+ groupIds,+ memberships+ }: {+ projectId: string;+ userIds: string[];+ groupIds: string[];+ memberships: Pick<TMemberships, "actorUserId" | "actorGroupId">[];+ },+ tx: Knex+ ) => {+ const memberGroups = new Set(memberships.map((row) => row.actorGroupId));const missingGroups = groupIds.filter((id) => !memberGroups.has(id));if (missingGroups.length) {throw new BadRequestError({@@ -95,17 +109,20 @@ export const agentVaultDelegationServiceFactory = ({});}- const memberUsers = new Set(userRows.map((row) => row.actorUserId));+ const memberUsers = new Set(memberships.map((row) => row.actorUserId));const missingUsers = userIds.filter((id) => !memberUsers.has(id));if (!missingUsers.length) return;- const groupMemberships = await userGroupMembershipDAL.find({ $in: { userId: missingUsers } });+ const groupMemberships = await userGroupMembershipDAL.find({ $in: { userId: missingUsers } }, { tx });const groupsInAgentVault = groupMemberships.length- ? await membershipDAL.find({- scope: AccessScope.Project,- scopeProjectId: projectId,- $in: { actorGroupId: [...new Set(groupMemberships.map((row) => row.groupId))] }- })+ ? await membershipDAL.find(+ {+ scope: AccessScope.Project,+ scopeProjectId: projectId,+ $in: { actorGroupId: [...new Set(groupMemberships.map((row) => row.groupId))] }+ },+ { tx }+ ): [];const memberGroupIds = new Set(groupsInAgentVault.map((row) => row.actorGroupId));const throughGroup = new Set(@@ -249,7 +266,7 @@ export const agentVaultDelegationServiceFactory = ({};const listDelegations = async ({ projectId, ctx, machineIdentityIds, limit, offset }: TListDelegationsDTO) => {- await checkAdmin(projectId, ctx);+ await checkIdentityPermission({ projectId, ctx }, ProjectPermissionIdentityActions.Read);const { delegations, totalCount } = await agentVaultDelegationDAL.findViews({projectId,identityIds: machineIdentityIds,@@ -261,61 +278,67 @@ export const agentVaultDelegationServiceFactory = ({// An identity may read its own, so an orchestrator can check what it was allowed before it acts.const getDelegation = async ({ projectId, ctx, machineIdentityId }: TGetDelegationDTO) => {- const { isAdmin } = await getAgentVaultPermission({ permissionService }, { projectId, ctx });+ const { permission, isAdmin } = await getAgentVaultPermission({ permissionService }, { projectId, ctx });const isSelf = ctx.actor === ActorType.IDENTITY && ctx.actorId === machineIdentityId;- if (!isAdmin && !isSelf) {- throw new ForbiddenRequestError({- message: "Only Agent Vault admins, and the machine identity itself, can read a machine identity's delegation"- });+ if (!isSelf) {+ ForbiddenError.from(permission).throwUnlessCan(+ ProjectPermissionIdentityActions.Read,+ subject(ProjectPermissionSub.Identity, { identityId: machineIdentityId })+ );}const {delegations: [delegation]} = await agentVaultDelegationDAL.findViews({ projectId, identityIds: [machineIdentityId] });if (!delegation) throw notFound(machineIdentityId);+ // The missing bundles were never granted to the identity, so reading its own delegation can't reveal them.+ if (!isAdmin) return { delegation: withNoMissingAccessBundles(delegation) };return { delegation: await withMissingAccessBundles({ projectId, ctx, delegation }) };};const setDelegation = async ({ projectId, ctx, machineIdentityId, scope, userIds, groupIds }: TSetDelegationDTO) => {- await checkAdmin(projectId, ctx);-- // Project-scoped, so an identity from another org is a 404 like one that doesn't exist.- const identityMembership = await membershipDAL.findOne({- scope: AccessScope.Project,- scopeProjectId: projectId,- actorIdentityId: machineIdentityId- });- if (!identityMembership) {- throw new NotFoundError({- message: `Machine identity with ID '${machineIdentityId}' is not a member of Agent Vault. Add it under Access Control first.`- });- }+ await checkIdentityPermission({ projectId, ctx, machineIdentityId }, ProjectPermissionIdentityActions.Edit);- if (scope === AgentVaultDelegationScope.Selected) {- await assertSubjectsInAgentVault({ projectId, userIds, groupIds });- }+ // A write replaces the whole list, so a subject left out is no longer covered.+ const wantedUserIds = scope === AgentVaultDelegationScope.Selected ? userIds : [];+ const wantedGroupIds = scope === AgentVaultDelegationScope.Selected ? groupIds : [];const delegation = await agentVaultDelegationDAL.transaction(async (tx) => {+ // Before the delegation row, the order a removal from Agent Vault takes them in, so a save and a removal can't+ // each hold a lock the other waits for.+ const memberships = await agentVaultDelegationDAL.lockMemberships(+ { projectId, identityId: machineIdentityId, userIds: wantedUserIds, groupIds: wantedGroupIds },+ tx+ );+ // Project-scoped, so an identity from another org is a 404 like one that doesn't exist.+ if (!memberships.some((row) => row.actorIdentityId === machineIdentityId)) {+ throw new NotFoundError({+ message: `Machine identity with ID '${machineIdentityId}' is not a member of Agent Vault. Add it under Access Control first.`+ });+ }+const row = await agentVaultDelegationDAL.upsertScope({ projectId, identityId: machineIdentityId, scope }, tx);- // A write replaces the whole list, so a subject left out is no longer covered. Rows that stay are kept rather- // than rewritten, so each one's addedAt still says when it was added.- const wantedUserIds = new Set(scope === AgentVaultDelegationScope.Selected ? userIds : []);- const wantedGroupIds = new Set(scope === AgentVaultDelegationScope.Selected ? groupIds : []);+ // Rows that stay are kept rather than rewritten, so each one's addedAt still says when it was added.const existing = await agentVaultDelegationSubjectDAL.find({ delegationId: row.id }, { tx });- const stale = existing.filter((subject) =>- subject.userId ? !wantedUserIds.has(subject.userId) : !wantedGroupIds.has(subject.groupId!)+ const keptUserIds = new Set(existing.map((named) => named.userId).filter(Boolean));+ const keptGroupIds = new Set(existing.map((named) => named.groupId).filter(Boolean));+ const addedUserIds = wantedUserIds.filter((id) => !keptUserIds.has(id));+ const addedGroupIds = wantedGroupIds.filter((id) => !keptGroupIds.has(id));++ // Only the subjects being added, so one that has left Agent Vault some other way, such as by leaving the+ // organization, can still be kept or taken out.+ await assertSubjectsInAgentVault({ projectId, userIds: addedUserIds, groupIds: addedGroupIds, memberships }, tx);++ const stale = existing.filter((named) =>+ named.userId ? !wantedUserIds.includes(named.userId) : !wantedGroupIds.includes(named.groupId!));if (stale.length) {- await agentVaultDelegationSubjectDAL.delete({ $in: { id: stale.map((subject) => subject.id) } }, tx);+ await agentVaultDelegationSubjectDAL.delete({ $in: { id: stale.map((named) => named.id) } }, tx);}- const keptUserIds = new Set(existing.map((subject) => subject.userId).filter(Boolean));- const keptGroupIds = new Set(existing.map((subject) => subject.groupId).filter(Boolean));const added = [- ...[...wantedUserIds].filter((id) => !keptUserIds.has(id)).map((userId) => ({ delegationId: row.id, userId })),- ...[...wantedGroupIds]- .filter((id) => !keptGroupIds.has(id))- .map((groupId) => ({ delegationId: row.id, groupId }))+ ...addedUserIds.map((userId) => ({ delegationId: row.id, userId })),+ ...addedGroupIds.map((groupId) => ({ delegationId: row.id, groupId }))];if (added.length) await agentVaultDelegationSubjectDAL.insertMany(added, tx);@@ -330,7 +353,7 @@ export const agentVaultDelegationServiceFactory = ({};const deleteDelegation = async ({ projectId, ctx, machineIdentityId }: TDeleteDelegationDTO) => {- await checkAdmin(projectId, ctx);+ await checkIdentityPermission({ projectId, ctx, machineIdentityId }, ProjectPermissionIdentityActions.Edit);const deleted = await agentVaultDelegationDAL.transaction(async (tx) => {const {diff --git a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.test.ts b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.test.tsindex 79434a8e33..f9cbb0c0f6 100644--- a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.test.ts+++ b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.test.ts@@ -107,7 +107,10 @@ const buildService = ({agentVaultPersonalValueDAL: { deleteForActorsWithoutGrant: vi.fn().mockResolvedValue(0) },userGroupMembershipDAL: { find: vi.fn().mockResolvedValue([]) },identityGroupMembershipDAL: { find: vi.fn().mockResolvedValue([]) },- agentVaultDelegationDAL: { delete: vi.fn().mockResolvedValue([]) }+ agentVaultDelegationDAL: {+ delete: vi.fn().mockResolvedValue([]),+ removeSubjects: vi.fn().mockResolvedValue(undefined)+ }};const service = agentVaultMembershipServiceFactory(diff --git a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.tsindex 14cb5e73f9..b252ac2b0b 100644--- a/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts+++ b/backend/src/ee/services/agent-vault-member/agent-vault-membership-service.ts@@ -54,7 +54,7 @@ type TAgentVaultMembershipServiceFactoryDep = {orgDAL: Pick<TOrgDALFactory, "findById">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;usageMeteringService: Pick<TUsageMeteringServiceFactory, "emitForProject">;- agentVaultDelegationDAL: Pick<TAgentVaultDelegationDALFactory, "delete">;+ agentVaultDelegationDAL: Pick<TAgentVaultDelegationDALFactory, "delete" | "removeSubjects">;} & TClearPersonalValuesDeps;export type TAgentVaultMembershipServiceFactory = ReturnType<typeof agentVaultMembershipServiceFactory>;@@ -676,11 +676,19 @@ export const agentVaultMembershipServiceFactory = ({await membershipDAL.delete({ $in: { id: membershipIds } }, tx);// A delegation left behind would come back with a later add, so an identity rejoining acts for no one until an- // admin allows it again.+ // admin allows it again. Users and groups come out of the delegations that name them for the same reason.const removedIdentityIds = named(held, AgentVaultMemberType.MachineIdentity);if (removedIdentityIds.length) {await agentVaultDelegationDAL.delete({ projectId, $in: { identityId: removedIdentityIds } }, tx);}+ await agentVaultDelegationDAL.removeSubjects(+ {+ projectId,+ userIds: named(held, AgentVaultMemberType.User),+ groupIds: named(held, AgentVaultMemberType.Group)+ },+ tx+ );// Their bundle grants went above. Their own variables stay, as they would if they only lost a bundle.await clearPersonalValuesAfterRevoke(diff --git a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.tsindex 5673b42c3c..6887f8a5ee 100644--- a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts+++ b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.ts@@ -717,17 +717,18 @@ export const agentVaultProxyServiceFactory = ({if (!session.userId && !session.identityId) {throw new UnauthorizedError({ message: "The identity this session belonged to has been deleted" });}- // The name marks an on-behalf-of session even after deleting the identity nulls its id.- const actingIdentity = session.actingIdentityName- ? {- reach: await $getActingIdentityReach({- projectId: session.projectId,- orgId,- userId: session.userId ?? null,- actingIdentityId: session.actingIdentityId ?? null- })- }- : null;+ // The name marks an on-behalf-of session, even an empty one, and even after deleting the identity nulls its id.+ const actingIdentity =+ session.actingIdentityName != null+ ? {+ reach: await $getActingIdentityReach({+ projectId: session.projectId,+ orgId,+ userId: session.userId ?? null,+ actingIdentityId: session.actingIdentityId ?? null+ })+ }+ : null;const actor = session.userId? { type: ActorType.USER as const, id: session.userId }diff --git a/backend/src/ee/services/agent-vault-session/agent-vault-session-dal.ts b/backend/src/ee/services/agent-vault-session/agent-vault-session-dal.tsindex 956ad26b38..0d8b2ff2bf 100644--- a/backend/src/ee/services/agent-vault-session/agent-vault-session-dal.ts+++ b/backend/src/ee/services/agent-vault-session/agent-vault-session-dal.ts@@ -326,9 +326,10 @@ export const agentVaultSessionDALFactory = (db: TDbClient) => {actingIdentityId: row.actingIdentityId,actingIdentityName: row.actingIdentityName,actor: toSessionActor(row),- actingIdentity: row.actingIdentityName- ? { id: row.actingIdentityId, name: row.actingIdentityLiveName ?? row.actingIdentityName }- : null,+ actingIdentity:+ row.actingIdentityName !== null+ ? { id: row.actingIdentityId, name: row.actingIdentityLiveName ?? row.actingIdentityName }+ : null,expiresAt: row.expiresAt,revokedAt: row.revokedAt,createdAt: row.createdAt,diff --git a/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.test.ts b/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.test.tsindex 00061a4dbe..951a3633a0 100644--- a/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.test.ts+++ b/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.test.ts@@ -20,6 +20,13 @@ describe("agent vault session status", () => {expect(deriveSessionStatus(session)).toBe(AgentVaultSessionStatus.Revoked);});+ // An identity can be named "", so a session is on someone's behalf when the name is set, not when it's truthy.+ test("an empty acting identity name still marks an on-behalf-of session", () => {+ const session = { ...live, userId: "user-1", actingIdentityId: null, actingIdentityName: "" };+ expect(isOrphanedSession(session)).toBe(true);+ expect(deriveSessionStatus(session)).toBe(AgentVaultSessionStatus.Revoked);+ });+test("an on-behalf-of session with both its user and its acting identity is active", () => {const session = { ...live, userId: "user-1", actingIdentityId: "identity-1", actingIdentityName: "slack-bot" };expect(isOrphanedSession(session)).toBe(false);diff --git a/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.ts b/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.tsindex 36c8e00cce..fd081d6269 100644--- a/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.ts+++ b/backend/src/ee/services/agent-vault-session/agent-vault-session-fns.ts@@ -25,7 +25,7 @@ type TSessionOwnerColumns = {// keeps its acting identity's name once that identity is deleted. Resolve refuses either; the status says the same,// or the list would show it Active when nothing can use it.export const isOrphanedSession = (session: TSessionOwnerColumns) =>- (!session.userId && !session.identityId) || (Boolean(session.actingIdentityName) && !session.actingIdentityId);+ (!session.userId && !session.identityId) || (session.actingIdentityName != null && !session.actingIdentityId);// The machine identity that started a session on a user's behalf holds it alongside the user.export const isSessionOwnedBy = (ctx: { actor: ActorType; actorId: string }, session: TSessionOwnerColumns) =>diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 554adfb74a..d192daaa8a 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -4783,15 +4783,18 @@ export const AGENT_VAULT = {groupName: "The name of the group.",addedAt: "When the user or group was added to the delegation.",missingAccessBundles:- "The access bundles that users the delegation covers can use and the machine identity can't. A session on behalf of a user can use only an access bundle that both can use, so the machine identity can't start sessions over these. With all-members, this is every access bundle the machine identity can't use, since Agent Vault admins can use every bundle.",+ "The access bundles that users the delegation covers can use and the machine identity can't. A session on behalf of a user can use only an access bundle that both can use, so the machine identity can't start sessions over these. With all-members, this is every access bundle the machine identity can't use, since Agent Vault admins can use every bundle. Always empty when the machine identity reads its own delegation, unless it's an Agent Vault admin.",userMissingAccessBundles:- "The access bundles this user can use and the machine identity can't, so the machine identity can't start sessions over them on the user's behalf. For an Agent Vault admin, this is every access bundle the machine identity can't use.",+ "The access bundles this user can use and the machine identity can't, so the machine identity can't start sessions over them on the user's behalf. For an Agent Vault admin, this is every access bundle the machine identity can't use. Always empty when the machine identity reads its own delegation, unless it's an Agent Vault admin.",groupMissingAccessBundles:- "The access bundles granted to this group, or every bundle if the group has the Admin role, that the machine identity can't use.",+ "The access bundles granted to this group, or every bundle if the group has the Admin role, that the machine identity can't use. Always empty when the machine identity reads its own delegation, unless it's an Agent Vault admin.",accessBundleId: "The ID of the access bundle.",accessBundleName: "The name of the access bundle.",+ createdAt: "When the delegation was set up.",+ updatedAt: "When the delegation was last saved.",limit: "The maximum number of delegations to return.",- offset: "How many delegations to skip."+ offset: "How many delegations to skip.",+ totalCount: "How many delegations match, across every page."}};diff --git a/docs/documentation/platform/agent-vault/sessions-on-behalf-of-users.mdx b/docs/documentation/platform/agent-vault/sessions-on-behalf-of-users.mdxindex c14ff1e480..3aa861011a 100644--- a/docs/documentation/platform/agent-vault/sessions-on-behalf-of-users.mdx+++ b/docs/documentation/platform/agent-vault/sessions-on-behalf-of-users.mdx@@ -110,14 +110,20 @@ A session created on behalf of a user can use an access bundle only if both the- The machine identity can use the access bundles granted to it, directly or through a group (if the machine identity is an Agent Vault admin, every bundle)- The proxy refuses the session's requests to a service until the user [sets up their personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values) for it-If a user or group in the delegation can use an access bundle that isn't granted to the machine identity, their row in the machine identity's **Delegation** section shows the number of excluded bundles, and hovering over the number lists them. Through the API, [the endpoint that reads a delegation](/api-reference/endpoints/agent-vault-delegations/get) returns the same bundles in `missingAccessBundles`. To let the machine identity create sessions over one of them, [grant the bundle](/documentation/platform/agent-vault/access-bundles#manage-access-to-access-bundles) to the machine identity.+If a user or group in the delegation can use an access bundle that isn't granted to the machine identity, Infisical shows the bundle in two places:++- In the machine identity's **Delegation** section, the row for the user or group shows the number of excluded bundles, and hovering over the number lists them+- [The endpoint that reads a delegation](/api-reference/endpoints/agent-vault-delegations/get) returns the bundles in `missingAccessBundles` (always empty if a machine identity that isn't an Agent Vault admin reads its own delegation)++To let the machine identity create sessions over one of them, [grant the bundle](/documentation/platform/agent-vault/access-bundles#manage-access-to-access-bundles) to the machine identity.## When the session stops workingInfisical checks the delegation again each time the proxy polls, once every [poll interval](/documentation/platform/agent-vault/proxies#poll-interval) (60 seconds by default). The proxy refuses every request on the session if any of these happen:- An admin removes the delegation, or edits it so it no longer covers the user-- The delegation covered the user only through a group, and the user leaves that group+- The delegation covered the user only through a group, and either the user leaves that group or an admin removes the group from Agent Vault+- An admin removes the user from Agent Vault, which also takes the user out of the delegation- An admin removes the machine identity from Agent Vault, which also deletes its delegation- Someone deletes the machine identity (the session then shows as **Revoked**)diff --git a/frontend/src/components/agent-vault/IdentityDelegationSection.tsx b/frontend/src/components/agent-vault/IdentityDelegationSection.tsxindex e5ad90671b..c32b451f97 100644--- a/frontend/src/components/agent-vault/IdentityDelegationSection.tsx+++ b/frontend/src/components/agent-vault/IdentityDelegationSection.tsx@@ -25,6 +25,7 @@ import {DropdownMenuItem,DropdownMenuTrigger,Empty,+ EmptyContent,EmptyDescription,EmptyHeader,EmptyTitle,@@ -69,8 +70,13 @@ export const IdentityDelegationSection = ({ machineIdentityId, machineIdentityNaconst { hasProjectRole } = useProjectPermission();const isAdmin = hasProjectRole(ProjectMembershipRole.Admin);- const { data, isPending } = useGetAgentVaultDelegation(machineIdentityId, isAdmin);+ const { data, isPending, isError, isFetching, refetch } = useGetAgentVaultDelegation(+ machineIdentityId,+ isAdmin+ );const delegation = data ?? null;+ // A save sends the whole list, so without a successful read it would replace what's there.+ const isLoadError = isError && data === undefined;const setDelegation = useSetAgentVaultDelegation();const deleteDelegation = useDeleteAgentVaultDelegation();@@ -168,6 +174,28 @@ export const IdentityDelegationSection = ({ machineIdentityId, machineIdentityNaconst renderList = () => {if (isPending) return <Skeleton className="h-16 w-full" />;+ if (isLoadError) {+ return (+ <Empty className="border">+ <EmptyHeader>+ <EmptyTitle>Couldn't load the delegation</EmptyTitle>+ <EmptyDescription>+ Reload to see its users and groups before you add or remove any.+ </EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button+ variant="outline"+ size="sm"+ isPending={isFetching}+ onClick={() => refetch().catch(() => {})}+ >+ Reload+ </Button>+ </EmptyContent>+ </Empty>+ );+ }if (!delegation) {return (<Empty className="border">@@ -259,7 +287,7 @@ export const IdentityDelegationSection = ({ machineIdentityId, machineIdentityNaLets this machine identity start sessions on behalf of these users and groups, using eachuser's personal values. It can still start its own sessions.</CardDescription>- {!isPending && (+ {!isPending && !isLoadError && (<CardAction><Button variant="av" onClick={() => setIsAddOpen(true)}><UserPlusIcon />diff --git a/frontend/src/components/agent-vault/MissingAccessBundlesHint.tsx b/frontend/src/components/agent-vault/MissingAccessBundlesHint.tsxindex 240c24336b..289bf674fe 100644--- a/frontend/src/components/agent-vault/MissingAccessBundlesHint.tsx+++ b/frontend/src/components/agent-vault/MissingAccessBundlesHint.tsx@@ -30,26 +30,28 @@ export const MissingAccessBundlesHint = ({ bundles, machineIdentityName, onBehal<span className="underline decoration-dotted underline-offset-2">{label}</span></button></HoverCardTrigger>- <HoverCardContent align="end" className="flex w-80 flex-col gap-2.5">- <p className="text-xs text-muted">- {`Sessions on behalf of ${onBehalfOf} can't use these access bundles, because "${machineIdentityName}" isn't granted them.`}- </p>- <div className="flex flex-wrap gap-1.5">- {bundles.map((bundle) => (- <Badge key={bundle.id} variant="neutral" iconPosition="left" asChild>- <Link- to="/organizations/$orgId/agent-vault/access-bundles/$accessBundleId"- params={{ orgId: currentOrg.id, accessBundleId: bundle.id }}- >- <PackageIcon />- {bundle.name}- </Link>- </Badge>- ))}+ <HoverCardContent align="end">+ <div className="flex flex-col gap-2.5">+ <p className="text-xs text-muted">+ {`Sessions on behalf of ${onBehalfOf} can't use these access bundles, because "${machineIdentityName}" isn't granted them.`}+ </p>+ <div className="flex flex-wrap gap-1.5">+ {bundles.map((bundle) => (+ <Badge key={bundle.id} variant="neutral" iconPosition="left" asChild>+ <Link+ to="/organizations/$orgId/agent-vault/access-bundles/$accessBundleId"+ params={{ orgId: currentOrg.id, accessBundleId: bundle.id }}+ >+ <PackageIcon />+ {bundle.name}+ </Link>+ </Badge>+ ))}+ </div>+ <p className="text-xs text-muted">+ {`To include one, grant it to "${machineIdentityName}" from the bundle's Manage Access.`}+ </p></div>- <p className="text-xs text-muted">- {`To include one, grant it to "${machineIdentityName}" from the bundle's Manage Access.`}- </p></HoverCardContent></HoverCard>);