Skip to content

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

fix(agent-vault): one delegation key, longer user names, clearer Identity cell

Scott Wilsonb1320d014d65
diff --git a/backend/e2e-test/routes/v1/agent-vault.spec.ts b/backend/e2e-test/routes/v1/agent-vault.spec.ts
index 803cbd1bbb..4571bf3382 100644
--- a/backend/e2e-test/routes/v1/agent-vault.spec.ts
+++ b/backend/e2e-test/routes/v1/agent-vault.spec.ts
@@ -5040,6 +5040,53 @@ describe("Agent Vault V1 Router", async () => {
}
});
+ test("a session can be started for a user whose full name is longer than 255 characters", async () => {
+ const projectId = await getProjectId();
+ const bundle = await createAccessBundle(`obo-long-name-${Date.now()}`);
+ const bot = await createMemberIdentity(`obo-long-name-bot-${Date.now()}`);
+ const alice = await createAgentVaultUser("obo-long-name-alice", projectId);
+ try {
+ // Each half fits its own 255-character column; the snapshot holds both together.
+ await testDb("users")
+ .where({ id: alice.userId })
+ .update({ firstName: "A".repeat(200), lastName: "N".repeat(200) });
+ await grantBundle(bundle.id, { userIds: [alice.userId], machineIdentityIds: [bot.id] });
+ await delegate(bot, { scope: "selected", userIds: [alice.userId] });
+
+ const minted = await mintFor(bot, { userId: alice.userId }, bundle.name);
+ expect(minted.statusCode, minted.payload).toBe(200);
+ const row = await testDb("agent_vault_sessions").where({ id: minted.json().session.id }).first();
+ expect(row.onBehalfOfUserName).toHaveLength(401);
+ } finally {
+ await bot.cleanup();
+ await deleteUsers([alice.userId]);
+ }
+ });
+
+ test("the database keeps a session on a user's behalf a machine identity's", async () => {
+ const projectId = await getProjectId();
+ const bundle = await createAccessBundle(`obo-check-${Date.now()}`);
+ const bot = await createMemberIdentity(`obo-check-bot-${Date.now()}`);
+ const alice = await createAgentVaultUser("obo-check-alice", projectId);
+ try {
+ await grantBundle(bundle.id, { userIds: [alice.userId], machineIdentityIds: [bot.id] });
+ await delegate(bot, { scope: "selected", userIds: [alice.userId] });
+ const minted = await mintFor(bot, { userId: alice.userId }, bundle.name);
+ expect(minted.statusCode).toBe(200);
+ const session = () => testDb("agent_vault_sessions").where({ id: minted.json().session.id as string });
+
+ const check = /agent_vault_sessions_on_behalf_of_check/;
+ await expect(session().update({ actorType: null })).rejects.toThrow(check);
+ await expect(session().update({ actorType: "user", userId: alice.userId, identityId: null })).rejects.toThrow(
+ check
+ );
+ await expect(session().update({ onBehalfOfUserName: null })).rejects.toThrow(check);
+ } finally {
+ await bot.cleanup();
+ await deleteUsers([alice.userId]);
+ }
+ });
+
test("a revoke that finds the session's user just deleted reports the session as it is now", async () => {
const bundle = await createAccessBundle(`obo-revoke-race-${Date.now()}`);
const bot = await createMemberIdentity(`obo-revoke-race-bot-${Date.now()}`);
@@ -5191,6 +5238,29 @@ describe("Agent Vault V1 Router", async () => {
}
});
+ test("two requests creating an identity's first delegation at once both land", async () => {
+ const projectId = await getProjectId();
+ const bot = await createMemberIdentity(`obo-first-race-${Date.now()}`);
+ const alice = await createAgentVaultUser("obo-first-race-alice", projectId);
+ const bob = await createAgentVaultUser("obo-first-race-bob", projectId);
+ const subjectsUrl = `${delegationUrl(bot.id)}/subjects`;
+ try {
+ // Neither write finds a delegation, so both insert one and collide on the row. A save and an add, then two adds.
+ for await (const round of Array.from({ length: 20 }, (_, index) => index)) {
+ const first =
+ round % 2 === 0
+ ? inject("PUT", delegationUrl(bot.id), { scope: "selected", userIds: [alice.userId] })
+ : inject("POST", subjectsUrl, { userIds: [alice.userId] });
+ const results = await Promise.all([first, inject("POST", subjectsUrl, { userIds: [bob.userId] })]);
+ expect([round, ...results.map((res) => res.statusCode)]).toEqual([round, 200, 200]);
+ expect((await inject("DELETE", delegationUrl(bot.id))).statusCode).toBe(200);
+ }
+ } finally {
+ await bot.cleanup();
+ await deleteUsers([alice.userId, bob.userId]);
+ }
+ });
+
test("users and groups are added and taken out one change at a time", async () => {
const projectId = await getProjectId();
const bot = await createMemberIdentity(`obo-subjects-bot-${Date.now()}`);
diff --git a/backend/src/db/migrations/20261019120000_agent-vault-delegations.ts b/backend/src/db/migrations/20261019120000_agent-vault-delegations.ts
index 8b957f2bfc..522ca1342d 100644
--- a/backend/src/db/migrations/20261019120000_agent-vault-delegations.ts
+++ b/backend/src/db/migrations/20261019120000_agent-vault-delegations.ts
@@ -13,17 +13,18 @@ export async function up(knex: Knex): Promise<void> {
await knex.schema.alterTable(TableName.AgentVaultSession, (t) => {
t.uuid("onBehalfOfUserId");
t.foreign("onBehalfOfUserId").references("id").inTable(TableName.Users).onDelete("SET NULL");
- t.string("onBehalfOfUserName", 255);
+ // Built from the first and last name, which can each be 255 characters.
+ t.text("onBehalfOfUserName");
t.string("onBehalfOfUserEmail", 255);
});
await knex.raw(
`CREATE INDEX agent_vault_session_by_on_behalf_of_user ON ?? ("onBehalfOfUserId") WHERE "onBehalfOfUserId" IS NOT NULL`,
[TableName.AgentVaultSession]
);
- // An on-behalf-of session is always a machine identity's, and an id is never stored without the name. actorType can
- // be NULL on rows the previous release writes during a rolling deploy.
+ // An on-behalf-of session is always a machine identity's, and an id is never stored without the name. actorType is
+ // tested for NULL too: a comparison with NULL is unknown, which a CHECK lets through.
await knex.raw(
- `ALTER TABLE ?? ADD CONSTRAINT ?? CHECK (("onBehalfOfUserName" IS NULL OR ("userId" IS NULL AND ("actorType" IS NULL OR "actorType" = 'machineIdentity'))) AND ("onBehalfOfUserId" IS NULL OR "onBehalfOfUserName" IS NOT NULL))`,
+ `ALTER TABLE ?? ADD CONSTRAINT ?? CHECK (("onBehalfOfUserName" IS NULL OR ("userId" IS NULL AND "actorType" IS NOT NULL AND "actorType" = 'machineIdentity')) AND ("onBehalfOfUserId" IS NULL OR "onBehalfOfUserName" IS NOT NULL))`,
[TableName.AgentVaultSession, SESSION_ON_BEHALF_OF_CHECK]
);
}
@@ -51,8 +52,10 @@ export async function up(knex: Knex): Promise<void> {
t.timestamps(true, true, true);
- // identityId leads, so the index also serves the identity foreign key's cascade.
- t.unique(["identityId", "projectId"]);
+ // Lookups by identity and project. Unique through membershipId, since an identity has one membership per project; a
+ // second unique key would make two first saves at once clash on the key ON CONFLICT doesn't name. identityId
+ // leads, so the index also serves the identity foreign key's cascade.
+ t.index(["identityId", "projectId"]);
});
await knex.raw(
diff --git a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-session-skill-router.ts b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-session-skill-router.ts
index 1d78314481..bbd2814969 100644
--- a/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-session-skill-router.ts
+++ b/backend/src/ee/routes/v1/agent-vault-routers/agent-vault-session-skill-router.ts
@@ -71,9 +71,10 @@ export const registerAgentVaultSessionSkillRouter = async (server: FastifyZodPro
});
}
- const { skills, session, ownerUser, orgId } = await server.services.agentVaultProxy.getSessionSkills({
- sessionToken: authorization.data
- });
+ const { skills, session, ownerUser, onBehalfOfUser, orgId } =
+ await server.services.agentVaultProxy.getSessionSkills({
+ sessionToken: authorization.data
+ });
const actor = sessionOwnerActor(session, ownerUser);
if (skills.length > 0) {
@@ -95,7 +96,12 @@ export const registerAgentVaultSessionSkillRouter = async (server: FastifyZodPro
skillName: skill.name,
version: skill.version,
sha256: skill.sha256
- }))
+ })),
+ ...(onBehalfOfUser && {
+ ...(onBehalfOfUser.id && { onBehalfOfUserId: onBehalfOfUser.id }),
+ onBehalfOfUserName: onBehalfOfUser.username,
+ ...(onBehalfOfUser.email && { onBehalfOfUserEmail: onBehalfOfUser.email })
+ })
}
}
});
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.ts
index 7e13619d91..5d103fc5ce 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
@@ -60,8 +60,8 @@ export const agentVaultDelegationDALFactory = (db: TDbClient) => {
try {
const [row] = (await tx(TableName.AgentVaultDelegation)
.insert({ projectId, identityId, membershipId, scope })
- .onConflict(["identityId", "projectId"])
- .merge({ membershipId, scope })
+ .onConflict("membershipId")
+ .merge({ scope })
.returning("*")) as TAgentVaultDelegations[];
return row;
} catch (error) {
@@ -78,7 +78,7 @@ export const agentVaultDelegationDALFactory = (db: TDbClient) => {
try {
await tx(TableName.AgentVaultDelegation)
.insert({ projectId, identityId, membershipId, scope: AgentVaultDelegationScope.Selected })
- .onConflict(["identityId", "projectId"])
+ .onConflict("membershipId")
.ignore();
} catch (error) {
throw new DatabaseError({ error, name: "Create Agent Vault delegation" });
diff --git a/backend/src/ee/services/agent-vault-delegation/agent-vault-on-behalf-of-fns.ts b/backend/src/ee/services/agent-vault-delegation/agent-vault-on-behalf-of-fns.ts
index d9409d54ef..e71504c1c0 100644
--- a/backend/src/ee/services/agent-vault-delegation/agent-vault-on-behalf-of-fns.ts
+++ b/backend/src/ee/services/agent-vault-delegation/agent-vault-on-behalf-of-fns.ts
@@ -97,15 +97,16 @@ export const resolveOnBehalfOfUser = async (
}
throw error;
}
+ // Read, the check resolve repeats: the identity starts the session, so the user only needs a live Agent Vault role.
// Not thrown through CASL: the denial would be recorded against the identity making the request.
if (
!reachability.permission.can(
- ProjectPermissionAgentVaultSessionActions.Create,
+ ProjectPermissionAgentVaultSessionActions.Read,
ProjectPermissionSub.AgentVaultSessions
)
) {
throw new ForbiddenRequestError({
- message: `'${identifier}' can't start Agent Vault sessions, so no session can be started on their behalf.`
+ message: `'${identifier}' doesn't have an active Agent Vault role, so no session can be started on their behalf. An Agent Vault admin can give them one under Access Control.`
});
}
diff --git a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.test.ts b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.test.ts
index 50b62e6b51..84e3c28e5b 100644
--- a/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.test.ts
+++ b/backend/src/ee/services/agent-vault-proxy/agent-vault-proxy-service.test.ts
@@ -5,7 +5,7 @@ import {
ProjectPermissionAgentVaultSessionActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
-import { ConflictError, UnauthorizedError } from "@app/lib/errors";
+import { ConflictError, ForbiddenRequestError, UnauthorizedError } from "@app/lib/errors";
import { ObjectStorageType } from "@app/services/object-storage/object-storage-types";
import { AGENT_VAULT_SERVICE_MOVED_MESSAGE } from "../agent-vault-oauth/agent-vault-oauth-service";
@@ -299,22 +299,31 @@ describe("resolve's lazy refresh", () => {
describe("resolve for a session on a user's behalf", () => {
const USER_ID = "user-1";
const IDENTITY_ID = "identity-1";
- type TActorSetup = { isAdmin?: boolean; grants?: string[]; isActive?: boolean };
+ type TActorSetup = {
+ isAdmin?: boolean;
+ grants?: string[];
+ isActive?: boolean;
+ canRead?: boolean;
+ isMember?: boolean;
+ };
// Each actor gets its own org status, role and bundle grants, and resolve's reach is read off the bundles it asks for.
const setupOnBehalfOf = ({
user = {},
identity = {},
delegationCoversUser = true,
- isUserDeleted = false
+ isUserDeleted = false,
+ rows = []
}: {
user?: TActorSetup;
identity?: TActorSetup;
delegationCoversUser?: boolean;
isUserDeleted?: boolean;
+ rows?: TResolveServiceRow[];
}) => {
const actor = (actorId: string) => (actorId === IDENTITY_ID ? identity : user);
- const findResolvableServices = vi.fn(async () => [] as TResolveServiceRow[]);
+ const findResolvableServices = vi.fn(async () => rows);
+ const findPersonalValues = vi.fn(async () => []);
const service = agentVaultProxyServiceFactory({
agentVaultProxyDAL: {
findByIdWithOrg: async () => ({ projectId: PROJECT_ID, orgId: "org-1", pollInterval: 60 })
@@ -323,7 +332,7 @@ describe("resolve for a session on a user's behalf", () => {
agentVaultServiceCustomHeaderDAL: { findByServiceIds: async () => [] },
agentVaultServiceSubstitutionDAL: { findByServiceIds: async () => [] },
agentVaultVariableDAL: { findValuesForResolve: async () => [] },
- agentVaultPersonalValueDAL: { findForResolve: async () => [] },
+ agentVaultPersonalValueDAL: { findForResolve: findPersonalValues },
agentVaultSessionDAL: {
findByTokenHash: async () =>
({
@@ -355,17 +364,23 @@ describe("resolve for a session on a user's behalf", () => {
({ isActive: actor(actorId).isActive ?? true }) as never
},
permissionService: {
- getProjectPermission: async ({ actorId }: { actorId: string }) =>
- ({
- permission: createMongoAbility([
- {
- action: ProjectPermissionAgentVaultSessionActions.Read,
- subject: ProjectPermissionSub.AgentVaultSessions
- }
- ]),
+ getProjectPermission: async ({ actorId }: { actorId: string }) => {
+ if (actor(actorId).isMember === false) {
+ throw new ForbiddenRequestError({
+ name: "ProjectMembershipNotFound",
+ message: "Not a member of the project"
+ });
+ }
+ const read = {
+ action: ProjectPermissionAgentVaultSessionActions.Read,
+ subject: ProjectPermissionSub.AgentVaultSessions
+ };
+ return {
+ permission: createMongoAbility(actor(actorId).canRead === false ? [] : [read]),
hasRole: () => Boolean(actor(actorId).isAdmin),
memberships: []
- }) as never
+ } as never;
+ }
},
kmsService: {
createCipherPairWithDataKey: async () =>
@@ -384,7 +399,7 @@ describe("resolve for a session on a user's behalf", () => {
service.resolveSession({ proxyId: "proxy-1", orgId: "org-1", sessionToken: "token", hasSessionLogKey: false });
const reachedBundles = () =>
(findResolvableServices.mock.calls[0] as unknown as [{ accessBundleIds: string[] | null }])[0].accessBundleIds;
- return { resolve, reachedBundles };
+ return { resolve, reachedBundles, findPersonalValues };
};
test("a non-admin user's reach is narrowed to the bundles the identity reaches too", async () => {
@@ -426,4 +441,34 @@ describe("resolve for a session on a user's behalf", () => {
const { resolve } = setupOnBehalfOf({ identity: { isAdmin: true }, isUserDeleted: true });
await expect(resolve()).rejects.toThrow(UnauthorizedError);
});
+
+ test("a user without Read on sessions is a 401", async () => {
+ const { resolve } = setupOnBehalfOf({ user: { grants: ["bundle-a"], canRead: false } });
+ await expect(resolve()).rejects.toThrow(UnauthorizedError);
+ });
+
+ // A 403 reads to the proxy as "Infisical is unreachable", which would keep the agent running through its grace window.
+ test("a user no longer in Agent Vault is a 401, not a 403", async () => {
+ const { resolve } = setupOnBehalfOf({ user: { isMember: false } });
+ await expect(resolve()).rejects.toThrow(UnauthorizedError);
+ });
+
+ test("personal values are looked up for the user, never the identity", async () => {
+ const { resolve, findPersonalValues } = setupOnBehalfOf({
+ user: { isAdmin: true },
+ identity: { isAdmin: true },
+ rows: [
+ serviceRow({
+ type: AgentVaultServiceType.Http,
+ hostPattern: "api.example.com",
+ credentialType: AgentVaultCredentialType.Bearer,
+ credentialConfig: { headerName: "Authorization", headerPrefix: "Bearer" },
+ encryptedCredential: Buffer.from(JSON.stringify({ value: "" })),
+ memberProvidedFields: ["credential-value"]
+ })
+ ]
+ });
+ await resolve();
+ expect(findPersonalValues).toHaveBeenCalledWith({ serviceIds: [SERVICE_ID], owner: { userId: USER_ID } });
+ });
});
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.ts
index 2046fad832..28e1fb41dc 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
@@ -1127,7 +1127,20 @@ export const agentVaultProxyServiceFactory = ({
: { username: session.actorEmail ?? session.actorName, email: session.actorEmail ?? null };
}
- return { skills, session, ownerUser, orgId: project.orgId };
+ // The user a session acts for is named the same way, so the audit event can say whose session it was.
+ let onBehalfOfUser: { id: string | null; username: string; email: string | null } | null = null;
+ if (session.onBehalfOfUserName != null) {
+ const user = session.onBehalfOfUserId ? await userDAL.findById(session.onBehalfOfUserId) : undefined;
+ onBehalfOfUser = user
+ ? { id: user.id, username: user.username, email: user.email ?? null }
+ : {
+ id: null,
+ username: session.onBehalfOfUserEmail ?? session.onBehalfOfUserName,
+ email: session.onBehalfOfUserEmail ?? null
+ };
+ }
+
+ return { skills, session, ownerUser, onBehalfOfUser, orgId: project.orgId };
};
return {
diff --git a/backend/src/ee/services/agent-vault/AGENTS.md b/backend/src/ee/services/agent-vault/AGENTS.md
index 3553392567..06bfe9bbb0 100644
--- a/backend/src/ee/services/agent-vault/AGENTS.md
+++ b/backend/src/ee/services/agent-vault/AGENTS.md
@@ -165,8 +165,9 @@ is one `agent_vault_delegations` row per identity, with a scope of `all-members`
- **Mint runs `getProjectPermission` for the user, then once more for the caller.** The permission service leaves
the last actor it ran for in the request context, where the audit log reads the caller's permission metadata. The
second call is memoized, so it costs no query; dropping it attributes the user's metadata to the identity.
-- **The user's session permission is checked with `can()`, not thrown through CASL**, since a CASL denial would be
- recorded against the identity making the request.
+- **The user's Read on sessions is checked with `can()`, not thrown through CASL**, at mint as on every resolve: the
+ identity starts the session, so the user only needs a live Agent Vault role. A CASL denial would be recorded against
+ the identity making the request.
- **TTL defaults to 1h, with no maximum for now**: the user didn't start the session and may not know it exists, so a
cap probably belongs here too, but any TTL is allowed for now, `never` included. The route's `ttl` is optional rather
than defaulted because the default depends on `onBehalfOf`.
@@ -339,9 +340,9 @@ An admin can leave a credential field to each member: the bearer token, or eithe
`credential-username` a username). Custom header and substitution values can't be member-provided yet. The personal
value tables already carry the reference tables' target columns, but adding them still needs the service's check
constraint and the API's field enum widened. Each actor saves their own **personal values** for the service, one row
-per field, and a session uses the values of whoever it belongs to. Every actor, admins included, also keeps
-**personal variables**, rows of `agent_vault_variables` with an owner, that only their own personal values can
-reference.
+per field, and a session uses the values of whoever it belongs to, or on a user's behalf that user's. Every actor,
+admins included, also keeps **personal variables**, rows of `agent_vault_variables` with an owner, that only their own
+personal values can reference.
- **`memberProvidedFields` is NULL, never `{}`, for a credential the admin sets in full**, like `allowedMethods`. The
service's sealed secret holds only the admin's fields, so a bearer token left to members stores no secret at all
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index 82c9fe6120..c655405413 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -6829,6 +6829,10 @@ interface AgentVaultSkillsDeliveredEvent {
accessBundleId: string;
accessBundleName: string;
skills: { skillId: string; skillName: string; version: number; sha256: string }[];
+ // Set when the machine identity in the actor started the session on this user's behalf.
+ onBehalfOfUserId?: string;
+ onBehalfOfUserName?: string;
+ onBehalfOfUserEmail?: string;
};
}
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 57baaf28eb..f8169f3b53 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -4685,9 +4685,9 @@ export const AGENT_VAULT = {
referenceCustomHeaderId: "The custom header whose value uses the variable.",
referenceSubstitutionId: "The substitution whose value uses the variable.",
bearerMemberProvidedFields:
- "Leave the token to each member: send `credential-value` here and no `value`. Every member sets their own, and a session uses the token of whoever it belongs to. Omit on update to keep the current setting; send an empty list to set the token yourself again, which then needs a `value`. Changing this clears every member's saved values for the service.",
+ "Leave the token to each member: send `credential-value` here and no `value`. Every member sets their own, and a session uses the token of the member who started it. A session a machine identity started on behalf of a user uses that user's token instead. Omit on update to keep the current setting; send an empty list to set the token yourself again, which then needs a `value`. Changing this clears every member's saved values for the service.",
basicMemberProvidedFields:
- "The halves of the basic credential each member sets for themselves: `credential-username`, `credential-value` (the password) or both. Send no value for a half listed here. A session uses the values of whoever it belongs to. Omit on update to keep the current setting. Adding a half keeps what members saved, and taking one back deletes only that half's values. Changing the credential type deletes every member's values for the service.",
+ "The halves of the basic credential each member sets for themselves: `credential-username`, `credential-value` (the password) or both. Send no value for a half listed here. A session uses the values of the member who started it. A session a machine identity started on behalf of a user uses that user's values instead. Omit on update to keep the current setting. Adding a half keeps what members saved, and taking one back deletes only that half's values. Changing the credential type deletes every member's values for the service.",
memberProvidedFields:
"The credential fields each member sets for themselves: credential-value (a bearer token or a basic password) and credential-username. Empty when the admin sets the whole credential."
},
diff --git a/docs/documentation/platform/agent-vault/http-apis.mdx b/docs/documentation/platform/agent-vault/http-apis.mdx
index 9e799f2e54..052a5610f5 100644
--- a/docs/documentation/platform/agent-vault/http-apis.mdx
+++ b/docs/documentation/platform/agent-vault/http-apis.mdx
@@ -66,7 +66,7 @@ For **Bearer** and **Basic** services, if the agent's request already carries a
## Member-provided values
-By default, you set the whole credential and every session uses it. If each member should call the API with their own token or login, such as a personal API key, you can make that part of the credential member provided. Each member then [sets a personal value](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values), and a session uses the personal value of the member who created the session.
+By default, you set the whole credential and every session uses it. If each member should call the API with their own token or login, such as a personal API key, you can make that part of the credential member provided. Each member then [sets a personal value](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values), and a session uses the personal value of the member who created it. If a machine identity creates the session [on behalf of a user](/documentation/platform/agent-vault/sessions-on-behalf-of-users), the session uses that user's personal value instead.
You can make these credential fields member provided:
diff --git a/docs/documentation/platform/agent-vault/proxies.mdx b/docs/documentation/platform/agent-vault/proxies.mdx
index 7da9e934c6..ec3d9c212e 100644
--- a/docs/documentation/platform/agent-vault/proxies.mdx
+++ b/docs/documentation/platform/agent-vault/proxies.mdx
@@ -185,7 +185,7 @@ The proxy also returns a 403 for:
- A request to a port the service's [host pattern](/documentation/platform/agent-vault/http-apis#host-patterns) doesn't name, such as `example.com:8443` for a service on `example.com`, which only covers port `443`
- A request that breaks the service's [method or path rules](/documentation/platform/agent-vault/http-apis#methods-and-paths), under either traffic policy
-- A request to a service that needs the session owner's [personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values), before they set them up
+- A request to a service whose [personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values) aren't set up yet for the session's owner, or, for a session [on behalf of a user](/documentation/platform/agent-vault/sessions-on-behalf-of-users), for that user
### Exceptions
diff --git a/docs/documentation/platform/agent-vault/sessions-cli.mdx b/docs/documentation/platform/agent-vault/sessions-cli.mdx
index 4361af6cc9..495c5c1d60 100644
--- a/docs/documentation/platform/agent-vault/sessions-cli.mdx
+++ b/docs/documentation/platform/agent-vault/sessions-cli.mdx
@@ -180,7 +180,7 @@ After the agent runs, go to **Sessions** in Agent Vault and select **All Session
If the agent's requests start failing with a 403 from the proxy, such as `CONNECT tunnel failed, response 403`, the session expired before the agent finished. Set a longer `--ttl`.
</Accordion>
<Accordion title="Requests to a service fail with &quot;needs your personal values&quot;">
- The service [takes part of its credential from each member](/documentation/platform/agent-vault/http-apis#member-provided-values), and whoever the session belongs to hasn't set up their personal values for it yet. A user sets them up under **Access Bundles**: select the bundle named in the message, then [set up the personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values). A machine identity sets them up with [the set personal values endpoint](/api-reference/endpoints/agent-vault-services/set-personal-values). Once they're saved, the proxy picks them up within one [poll interval](/documentation/platform/agent-vault/proxies#poll-interval).
+ The service [takes part of its credential from each member](/documentation/platform/agent-vault/http-apis#member-provided-values), and whoever the session belongs to hasn't set up their personal values for it yet. For a session a machine identity started [on behalf of a user](/documentation/platform/agent-vault/sessions-on-behalf-of-users), that's the user. A user sets them up under **Access Bundles**: select the bundle named in the message, then [set up the personal values](/documentation/platform/agent-vault/access-bundles#set-up-your-personal-values). A machine identity sets them up with [the set personal values endpoint](/api-reference/endpoints/agent-vault-services/set-personal-values). Once they're saved, the proxy picks them up within one [poll interval](/documentation/platform/agent-vault/proxies#poll-interval).
</Accordion>
<Accordion title="A session stays Active after the agent stopped">
The CLI couldn't revoke the session, for example because the machine shut down or the process was killed with `SIGKILL`. [Revoke the session](/documentation/platform/agent-vault/sessions#revoke-a-session) on the **Sessions** page, or let it expire at the end of its `--ttl`.
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.mdx
index 311e53f1d8..52496067e5 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
@@ -129,10 +129,11 @@ Infisical checks the delegation again each time the proxy polls, once every [pol
- 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 either the user leaves that group or the group is removed from Agent Vault
- The user is removed from Agent Vault or from your organization, which also takes the user out of the delegation
+- The user or the machine identity is deactivated in your organization
- An admin removes the machine identity from Agent Vault, which also deletes its delegation
- Someone deletes the machine identity or the user (the session then shows as **Revoked**)
-If an admin sets up the delegation again, or adds the user back to it, the session works again. To end a session for good, [revoke it](/documentation/platform/agent-vault/sessions#revoke-a-session).
+If an admin sets up the delegation again, adds the user back to it, or reactivates the user or the machine identity, the session works again. To end a session for good, [revoke it](/documentation/platform/agent-vault/sessions#revoke-a-session).
If the user or the machine identity can no longer use the access bundle, the session stops getting credentials for the bundle, as [Access changes](/documentation/platform/agent-vault/sessions#access-changes) describes.
diff --git a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
index a3066639f1..e64db44ee2 100644
--- a/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
+++ b/frontend/src/components/agent-vault/service-sheet/CredentialFields.tsx
@@ -305,7 +305,8 @@ const MemberProvidedToggle = ({
<li>Off: you set the {label.toLowerCase()} here, and every session uses it.</li>
<li>
On: each member sets their own from the access bundle page, and a session uses the{" "}
- {label.toLowerCase()} of whoever started it.
+ {label.toLowerCase()} of whoever started it, or of the user it was started on behalf
+ of.
</li>
</ul>
<a
diff --git a/frontend/src/pages/agent-vault/AgentVaultSessionsPage/components/SessionIdentity.tsx b/frontend/src/pages/agent-vault/AgentVaultSessionsPage/components/SessionIdentity.tsx
index fed124f42c..db9ca9c2dc 100644
--- a/frontend/src/pages/agent-vault/AgentVaultSessionsPage/components/SessionIdentity.tsx
+++ b/frontend/src/pages/agent-vault/AgentVaultSessionsPage/components/SessionIdentity.tsx
@@ -2,63 +2,54 @@ import { ReactElement } from "react";
import { BotIcon, UserIcon } from "lucide-react";
import { memberDisplayName, memberSubtitle } from "@app/components/agent-vault/MemberName";
-import { Badge, Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
-import { AgentVaultMemberType, TAgentVaultSession } from "@app/hooks/api/agentVault";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@app/components/v3";
+import {
+ AgentVaultMemberType,
+ TAgentVaultSession,
+ TAgentVaultSessionActor
+} from "@app/hooks/api/agentVault";
-// Deleting the machine identity or the user it acts for ends the session, so the cell names whichever was deleted.
-const describeDeleted = ({ actor, onBehalfOf }: TAgentVaultSession) => {
- const names = [
- actor.id === null ? memberDisplayName(actor) : null,
- onBehalfOf && onBehalfOf.id === null ? memberDisplayName(onBehalfOf) : null
- ].filter((name): name is string => name !== null);
- if (!names.length) return null;
- return `${names.map((name) => `"${name}"`).join(" and ")} ${names.length === 1 ? "was" : "were"} deleted`;
+const withTooltip = (trigger: ReactElement, content: string) => (
+ <Tooltip>
+ <TooltipTrigger asChild>{trigger}</TooltipTrigger>
+ <TooltipContent>{content}</TooltipContent>
+ </Tooltip>
+);
+
+// Whichever of the two was deleted is the part that says so, so the row never reads as if the other one is gone.
+const describe = (actor: TAgentVaultSessionActor) => {
+ const name = memberDisplayName(actor);
+ if (actor.id === null) return `"${name}" was deleted`;
+ if (actor.type === AgentVaultMemberType.MachineIdentity) return `${actor.id} (machine identity)`;
+ const subtitle = memberSubtitle(actor);
+ return name === subtitle ? subtitle : `${name} (${subtitle})`;
};
export const SessionIdentity = ({ session }: { session: TAgentVaultSession }) => {
const { actor, onBehalfOf } = session;
+ const ActorIcon = actor.type === AgentVaultMemberType.MachineIdentity ? BotIcon : UserIcon;
- if (actor.type === AgentVaultMemberType.User) {
- return (
- <Tooltip>
- <TooltipTrigger asChild>
- <div className="flex w-fit items-center gap-2">
- <UserIcon className="size-4 text-muted" />
- {memberDisplayName(actor)}
- </div>
- </TooltipTrigger>
- <TooltipContent>{memberSubtitle(actor)}</TooltipContent>
- </Tooltip>
- );
- }
-
- const deleted = describeDeleted(session);
- const explained = (trigger: ReactElement) =>
- deleted ? (
- <Tooltip>
- <TooltipTrigger asChild>{trigger}</TooltipTrigger>
- <TooltipContent>{deleted}</TooltipContent>
- </Tooltip>
- ) : (
- trigger
- );
-
+ // Two lines tall even without the on-behalf-of line, so every row of the table is the same height.
return (
- <div className="flex w-fit items-center gap-2">
- <BotIcon className="size-4 text-muted" />
- {onBehalfOf ? memberDisplayName(actor) : explained(<span>{memberDisplayName(actor)}</span>)}
- {onBehalfOf &&
- explained(
- <Badge
- variant="neutral"
- iconPosition="left"
- isTruncatable
- className={deleted ? "max-w-60 text-muted" : "max-w-60"}
- >
- <UserIcon />
- <span>On Behalf Of {memberDisplayName(onBehalfOf)}</span>
- </Badge>
- )}
+ <div className="flex min-h-9 items-center">
+ <div className="flex w-fit items-start gap-2">
+ <ActorIcon className="mt-0.5 size-4 shrink-0 text-muted" />
+ <div className="max-w-72 min-w-0">
+ {withTooltip(
+ <div className="w-fit max-w-full truncate">{memberDisplayName(actor)}</div>,
+ actor.type === AgentVaultMemberType.User && actor.id !== null
+ ? memberSubtitle(actor)
+ : describe(actor)
+ )}
+ {onBehalfOf &&
+ withTooltip(
+ <div className="w-fit max-w-full truncate text-xs leading-4 text-muted">
+ On behalf of {memberDisplayName(onBehalfOf)}
+ </div>,
+ describe(onBehalfOf)
+ )}
+ </div>
+ </div>
</div>
);
};