Skip to content

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

feat(pam-account): include connect-target in Access role conditions

bernie-g6271885c0079
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index b5bb0c2794..d836958b98 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -843,19 +843,20 @@ export const pamAccountServiceFactory = ({
const accountMeta = await pamAccountDAL.findMetadataByAccountIds([account.id]);
- // For domain accounts the subject scopes to {domainName, domainType} (matching
- // create/list/etc). Using {resourceName, resourceType} would let a role keyed on
- // a single resource authorize every domain account, and a role keyed on the
- // domain wouldn't match because the field would be undefined.
+ // On Access, resourceName/resourceType match the connect-target (the
+ // Windows host the credentials are used against), and for domain
+ // accounts domainName/domainType additionally scope to the parent.
+ // Other actions (create/read/update/delete) keep resourceName as the
+ // account's parent, which is undefined for domain accounts.
const domain = isDomainAccount && account.domainId ? await pamDomainDAL.findById(account.domainId) : null;
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionPamAccountActions.Access,
subject(ProjectPermissionSub.PamAccounts, {
accountName: account.name,
- ...(isDomainAccount && domain
- ? { domainName: domain.name, domainType: domain.domainType }
- : { resourceName: resource.name, resourceType: resource.resourceType }),
+ resourceName: resource.name,
+ resourceType: resource.resourceType,
+ ...(isDomainAccount && domain && { domainName: domain.name, domainType: domain.domainType }),
metadata: accountMeta[account.id] || []
})
);
diff --git a/docs/documentation/platform/pam/product-reference/access-policies.mdx b/docs/documentation/platform/pam/product-reference/access-policies.mdx
index be3b5c3cf4..1e4996f91b 100644
--- a/docs/documentation/platform/pam/product-reference/access-policies.mdx
+++ b/docs/documentation/platform/pam/product-reference/access-policies.mdx
@@ -116,6 +116,17 @@ Once all required approvals for all steps are obtained, access is automatically
When a request is rejected, the workflow ends and no access is granted.
+## Role-based Permission Conditions
+
+In addition to approval policies, project roles can scope PAM-account access using CASL conditions (Project > Access Control > Roles > edit role > PAM Accounts).
+
+The `resourceName` and `resourceType` conditions behave slightly differently depending on the action:
+
+- **Access action**: both conditions match the resource the user is connecting *through*. For local accounts this is the same resource the account belongs to. For domain accounts (Active Directory) it is the Windows host the credentials are being used against, not the account's domain parent.
+- **All other actions** (read, create, update, delete): both conditions match the resource the account belongs to. Domain accounts have no owning resource, so these conditions don't apply to them for non-Access actions; use `domainName` / `domainType` to scope domain accounts instead.
+
+`domainName` and `domainType` match the account's domain parent in every action, and are only set for domain accounts.
+
## FAQ
<AccordionGroup>
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
index e0c0da1f68..3c7157c1b3 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/PamAccountPermissionConditions.tsx
@@ -32,12 +32,14 @@ export const PamAccountPermissionConditions = ({ position = 0, isDisabled }: Pro
{
value: "resourceName",
label: "Resource Name",
- description: "Name of the PAM resource this account belongs to"
+ description:
+ "PAM resource the account belongs to. On Access, also matches the resource being connected through — for domain accounts this is the Windows host the credentials are used against, not the account's domain parent."
},
{
value: "resourceType",
label: "Resource Type",
- description: "PAM resource type (e.g. postgres, mysql, ssh)"
+ description:
+ "PAM resource type (e.g. postgres, mysql, ssh). On Access for domain accounts, this is the connect-target resource's type rather than the account's domain type."
},
{
value: "domainName",