Push Publishing: Push users does not update its user role Id
As of 3.6.0, we allow Push Publish of users between environments. However, if the user has been created with the same Id (either manually or migrated from Active Directory), not all its attributes are updated once it's pushed from the Sender environment.
Expected Behavior
If the user has been created manually, with the same id/email address on both endpoints, the User Role should have the same Id once we attempt to push the User from Sender side.
Current Behavior
If we push the user, all User Attributes are pushed except the User Role definition.
Known Workarounds
- Delete the user in Prod via UI.
- Push the User.
Steps to Reproduce
-
Set up a Push Publishing Environment
- One Sender Endpoint.
- One Receiver Endpoint.
-
Change the Authentication Method to User ID on both Endpoints.
-
On each endpoint, create an user with the same Id. For testing purposes, these are the user's attributes:
- User Id: eesupport.
- First Name: Support.
- Last Name: User
- Email Address: [email protected]
-
Inspect the data on cms_role table and see the new user's role definition
Sender (before Push)
360dist=# select id, role_name, role_key from cms_role where role_key = 'eesupport';
id | role_name | role_key
--------------------------------------+-------------------+-----------------
0f1b5413-39a3-443a-99ba-5eebf06c4a76 | Support User | eesupport
(1 row)
Receiver (before Push)
360receiver=# select id, role_name, role_key from cms_role where role_key = 'eesupport';
id | role_name | role_key
--------------------------------------+-------------------+-----------------
d0ec07cf-6732-4f4f-b1ad-46a4b5c88873 | Support User | eesupport
(1 row)
- Push the User to Receiver Environment.
- Check the same data after the push is done
Sender (After push)
360dist=# select id, role_name, role_key from cms_role where role_key = 'eesupport';
id | role_name | role_key
--------------------------------------+-------------------+-----------------
0f1b5413-39a3-443a-99ba-5eebf06c4a76 | Support User | eesupport
(1 row)
Receiver (After push)
360receiver=# select id, role_name, role_key from cms_role where role_key = 'eesupport';
id | role_name | role_key
--------------------------------------+-------------------+-----------------
d0ec07cf-6732-4f4f-b1ad-46a4b5c88873 | Support User | eesupport
(1 row)
Context
For clients who have set up LDAP authentication on both Sender and Receiver endpoints, it's normal that a user can have access to both endpoints. Upon first login, the 4 steps described for reproducing this issue may happen, so these users' roles will have different Ids. Problem happens once these users are tied to Workflow Schemes and the contents are pushed. Despite the user exists, the Assigned To value from the related Workflow Task of the content being pushed is not found, however, the User actually exists. The bundle with the User information already includes the User Role definition, but it's not taken into account once the push is done.
Related to https://github.com/dotCMS/core/issues/9767 Reported by client on dotCMS 3.5.1. https://my.dotcms.com/tickets/detail.dot?id=117feff5-738c-4bb9-a16d-87cc604796bd
Your Environment
- dotCMS version 3.5.1 and 3.6.0.
- Java 8
- Postgres 9.4.1
Nice hunting Jose. This is a good issue to get fixed.
PR: https://github.com/dotCMS/core/pull/9993
This issue has been fixed by introducing a new feature: integrity-checker for roles on push-publishing configuration. On integrity-checker, a role is considered in conflict when it exists on both ends (sender and receiver) with "same name", same role_key but a different role_id:
- As part of the "name" comparison, the analysis takes into account the role parent names so "same name" also means same parent names.
- A mismatch in "role_id" may be detected at different levels of a role hierarchy.
Furthermore, all roles descending from a role in conflict (directly or indirectly) will also be in conflict because their db_fqn will need to be updated.
Fix needs work. I followed Steps to Reproduce Configured sender and receiver.
- Sender: MySQL 5.6.23
- Receiver: Postgres 9.3.5
Went to Integrity Checker> Roles tab Clicked "Fix at Remote Node” and unfortunately is not resolving the conflicts Error logs in sender side: https://gist.github.com/shaydotcms/f59ee26fafd36f2772eab6a541719e82#file-error-in-sender-side Error logs in receiver side: https://gist.github.com/shaydotcms/f59ee26fafd36f2772eab6a541719e82#file-error-in-receiver-side
I verified with @agomez-dotcms and it could be a constraint related with Postgres because when I configure the sender and receiver viceversa (Sender: Postgres 9.3.5 / Receiver: MySQL 5.6.23), "Fix at Remote Node” does resolve the conflicts but "Fix at Local Node” do not.
PR: https://github.com/dotCMS/core/pull/10067
The previously reported issue is now addressed/fixed by PR above (https://github.com/dotCMS/core/pull/10067). As initially diagnosed, root cause of problem was related to a unique integrity constraint present in Postgres over column "cms_role.db_fqn":
- As further diagnostics, problem would also be reproducible against H2, Oracle and MS-SQL because equivalent unique integrity constraint is present in all DB types except My-SQL.
- Coincidentally, functionality for Roles Integrity Checker was initially developed/tested against MySQL and that's why it was not caught as part of initial implementation.
Good catch, Shay! Having you testing "Push Publishing -> Integrity Checker" in a cross DB platform -way has let us fix in advance an issue that was present against most of the DBs.
The PR consists not only in the actual fix to prevent the unique constraint integrity violation but it also introduces the constraint missing in MySQL in order to synchronize DB schemas and remove the different behavior / disparity when testing against MySQL and remaining types of DB.
Passed QA. Tested issue in latest master-3.7, MySQL 5.6.23 (sender), Postgres 9.3.5 (receiver), Firefox v45.0.1, Chrome v54.0.2840.87
- Created a user with same user id and email address in both sender and receiver using different servers
- Verified fix conflict using "Fix at Remote Node" and "Fix at Local Node"
- Created a parent role (parent role 1) in both sender and receiver: conflicts fixed successfully
- Created a child role (child role 1) inside parent role (parent role 1) in both sender and receiver: conflicts fixed successfully
- Created a child role inside Intranet, Publisher / Legal and System roles in both sender and receiver: conflicts fixed successfully
- Created 10 parent roles in both sender and receiver: conflicts fixed successfully
- Created 10 children roles in both sender and receiver: conflicts fixed successfully
- Edited parent role in both sender and receiver and ran Integrity Checker: no conflicts
- Edited child role in both sender and receiver and ran Integrity Checker: no conflicts
documented: http://auth.dotcms.com/docs/latest/integrity-checker#IntegrityChecker