Merged
Size
L
Change Breakdown
Feature80%
Maintenance20%
#28018feat(core): Add audit logging for expression-based role assignments

Audit logging added for expression-based role assignments

Audit logging added for expression-based role assignments

Expression-based role assignments now emit audit events: admins get full traceability on login-time role resolution including matched rules, previous values, and fallback detection, plus logging for all rule CRUD operations.

Expression-based role assignments in n8n's enterprise SSO provisioning now generate audit logs. When users log in via OIDC, SAML, or LDAP, the system evaluates mapping rules to determine their roles — but until now, there was no record of which rule matched or what roles changed. This PR adds that visibility.

Every login now produces an audit event capturing the matched rule ID and expression for both instance and project roles, whether a fallback was used, and the previous role values for change detection. Removed project access is also tracked. Additionally, all administrative operations on mapping rules — create, move, patch, and delete — emit their own audit events with the acting user, rule type, and changed fields.

The and types carry enriched metadata through the flow. The and methods return rule IDs and expressions alongside role names, which the method uses to build the audit payload.

In the CLI package, the now emits events after each operation, while the handler sends them to the event bus. Four new event names are registered in .

This audit coverage supports security and compliance requirements for organizations using expression-based role mapping — administrators can now trace exactly which rules determined access and audit administrative changes to those rules.

View Original GitHub Description

Summary

Add audit trail coverage for expression-based role mapping during SSO login and for CRUD operations on mapping rules.

Login-time audit (n8n.audit.role-mapping.roles-resolved): Emitted after role resolution, includes the matched rule ID/expression for both instance and project roles, whether fallback was applied, previous role values, change detection, and removed project IDs.

Rule CRUD audit (n8n.audit.role-mapping.rule.created/updated/deleted): Emitted from the controller after each admin operation on mapping rules, capturing the acting user, rule type, and relevant fields.

The RoleResolverService.resolveRoles() now returns enriched metadata (ResolvedInstanceRole/ResolvedProjectRole) with matched rule IDs and expressions, which ProvisioningService uses to build the audit event payload.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/IAM-401

Review / Merge checklist

© 2026 · via Gitpulse