Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Share Unit): Teacher owner loses authoring permission #212

Conversation

geoffreykwan
Copy link
Member

@geoffreykwan geoffreykwan commented Feb 21, 2023

Changes

Added @Transactional in these locations

  • Add shared teacher to project
  • Remove shared teacher from project
  • Add shared teacher permission to project
  • Remove shared teacher permission from project
  • Add shared teacher to run
  • Remove shared teacher from run
  • Add shared teacher permission to run
  • Remove shared teacher permission from run

Test

We haven't found a reliable way to reproduce the problem so this is an attempt to fix the problem. Here is how to attempt to reproduce the problem.

Sign in as a teacher

Go to the Unit Library
Add and remove shared teachers
Add and remove shared teacher permissions

Go to the Class Schedule
Add and remove shared teachers
Add and remove shared teacher permissions

Make sure the teacher owner can still make changes to the unit

Here is how you can check the permissions in the database

Log in to the local Docker MySQL database

docker run -it --network wise-docker-dev_default --rm mysql:8 mysql -hwise-mysql -uroot -p wise_database

Run this query to look up permissions for a project (replace <project id> with your project id)

select * from acl_object_identity where object_id_class=1 and object_id_identity=<project id>;

Remember the id from the result and then run this query (replace <id from previous query>)

select * from acl_entry where acl_object_identity=<id from previous query>;

Run this query to look up permissions for a run (replace <run id> with your run id)

select * from acl_object_identity where object_id_class=2 and object_id_identity=<run id>;

Remember the id from the result and then run this query (replace <id from previous query>)

select * from acl_entry where acl_object_identity=<id from previous query>;

Here's an example of looking up the permissions for project id 25. Notice in the result of the first query, the id is 72 so we use 72 in the second query. The result of the second query shows that sid 1 has permission mask 16 (full access) and sid 22 has mask 1 (read) and 2 (write) permissions. Basically you want to make sure the teacher owner mask 16 row does not get deleted.

mysql> select * from acl_object_identity where object_id_class=1 and object_id_identity=25;
+----+--------------------+------------------------+----------------------------------------+---------+-----------------+-----------+---------------+
| id | object_id_identity | object_id_identity_num | entries_inheriting                     | OPTLOCK | object_id_class | owner_sid | parent_object |
+----+--------------------+------------------------+----------------------------------------+---------+-----------------+-----------+---------------+
| 72 |                 25 |                   NULL | 0x01                                   |    NULL |               1 |         1 |          NULL |
+----+--------------------+------------------------+----------------------------------------+---------+-----------------+-----------+---------------+
1 row in set (0.00 sec)

mysql> select * from acl_entry where acl_object_identity=72;
+------+-----------+------------------------------+------------------------------+--------------------+------+---------+-----+---------------------+
| id   | ace_order | audit_failure                | audit_success                | granting           | mask | OPTLOCK | sid | acl_object_identity |
+------+-----------+------------------------------+------------------------------+--------------------+------+---------+-----+---------------------+
| 2025 |         0 | 0x00                         | 0x00                         | 0x01               |   16 |    NULL |   1 |                  72 |
| 2026 |         1 | 0x00                         | 0x00                         | 0x01               |    1 |    NULL |  22 |                  72 |
| 2027 |         2 | 0x00                         | 0x00                         | 0x01               |    2 |    NULL |  22 |                  72 |
+------+-----------+------------------------------+------------------------------+--------------------+------+---------+-----+---------------------+
3 rows in set (0.00 sec)

To look up who an sid refers to you can use this query (replace <sid>)

select * from acl_sid where id=<sid>;

Here is an example where you can see the username in the sid column.

mysql> select * from acl_sid where id=1;
+----+-----------+-----+---------+
| id | principal | sid | OPTLOCK |
+----+-----------+-----+---------+
|  1 |         1 | gk  |    NULL |
+----+-----------+-----+---------+
1 row in set (0.00 sec)

Closes #211

We haven't found a reliable way to reproduce the problem so this is an
attempt to fix the problem.

#211
@geoffreykwan geoffreykwan self-assigned this Feb 21, 2023
@geoffreykwan geoffreykwan marked this pull request as ready for review February 21, 2023 19:14
Copy link
Member

@hirokiterashima hirokiterashima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@geoffreykwan geoffreykwan merged commit 918da9d into develop Feb 26, 2023
@geoffreykwan
Copy link
Member Author

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

fix(Share Unit): Teacher owner loses authoring permission
2 participants