Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ridz1208
Copy link
Collaborator

Brief summary of changes

These changes offer a backwards compatible way of adding Site and Project permissions to the imaging_uploader module.

Since the imaging_uploader may contain uploads which fail validation (for whatever reason) and are thus not associated to a sessionID in the mri_upload table, the files are not technically associated with a site and project. In the current implementation all users with access to the module have access to all uploads which is problematic for institutional instances like CBIG. The changes here include a config setting to enable/disable the use of site/project checking (disabled is the status quo) but also include a permission which can give a user access to only their site's/project's data + any file with no sessionID and thus no site or project. Which should cover all use cases past and future

Note: To all the config setting haters (@driusan) it was my impression from the last meeting we had that there is no near future in which all projects revert to forcing a sessionID in the imaging modules or otherwise fail the insert so I think a config setting is warranted here for other instances to not have overrides for 10+ years

Testing instructions (if applicable)

  1. Set the config setting to false/off/no...
  2. the module should have regular behaviour unaffected by this PR
  3. Set the config setting to true and test with a regular user
  4. make sure user only has access to their site and project uploads AND uploads they make themselves (even if the uploads fail validation and do not have a site and project)
  5. give the user the imaging_uploader_nosessionids permission
  6. make sure the user now has access to their site and project uploads AND uploads they make themselves AND any other upload with no associated site and project

voila

Link(s) to related issue(s)

  • Resolves # (Reference the issue this fixes, if any.)

@ridz1208 ridz1208 added Category: Feature PR or issue that aims to introduce a new feature Category: Security PR or issue that aims to improve security Language: PHP PR or issue that update PHP code Project: C-BIG & ARCHIMEDES Issue or PR related to the C-BIG project Difficulty: Simple PR or issue that should be easy to implement, review, or test Area: Imaging PR or issue related to imaging labels Jan 15, 2025
@ridz1208
Copy link
Collaborator Author

@cmadjar @nicolasbrossard

Assigning both of you to check for redflags.

@nicolasbrossard
Copy link
Contributor

nicolasbrossard commented Jan 17, 2025

Why not have a permission that allows you to have access to ALL uploads (i.e even uploads not from the user's site)? With your new permission definitions, I don't think there can be an imaging uploader super-user when useSiteProjectPermissions is ON.

@ridz1208
Copy link
Collaborator Author

@nicolasbrossard I'm not sure if you are suggesting that functionality on top of what I'm adding or instead of but I'll try to answer it either way.

So yes, you are correct but my goal on CBIG is not to have anyone be superuser in fact I shy away from giving anyone any superuser or all site permissions at all. I think it boils down to the following.

  1. If you are a regular Joe Schmoe and ur using the uploader, you can see things uploaded at your site, for your project AND things you uploaded yourself!
  2. if you are Joe Schmoe's boss, you probably see things uploaded at all your sites and all your projects AND things you uploaded yourself!
  3. If you draw the short stick and you have to fix all of Joe Schmoe's mistakes along with Mickey Mouse's, Donald Duck's, Bugs Bunny's and Fred Flinstone's mistakes. You lucky ducky get imaging_uploader_nosessionids to see all problematic uploads AND you see your own and you see all your sites and projects...

I don't see the all sites usecase anywhere, I think even case #3 (closest to superuser) you would just get the sites and projects you need assigned to you instead of getting some sort of magic all sites permissions because ultimately if you need to debug anything you will also need imaging_browser all sites, access_all_profile, issue tracker all site and a bunch of other all sites... you might as well get all the sites?

Plus, it doesnt even make sense anymore to have all sites because it either needs to include all projects or we need to make a separate all projects permission or an all sites and all projects...

@kongtiaowang
Copy link
Contributor

Sourcing raisinbread/RB_files/RB_ConfigSettings.sql
ERROR 1064 (42000) at line 123: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INTO ConfigSettings (Name, Description, Visible, AllowMultiple, DataType, Parent' at line 1

@ridz1208 ridz1208 added the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Feb 5, 2025
@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch 4 times, most recently from 2c008dd to 5bc7fa1 Compare February 5, 2025 20:02
@ridz1208 ridz1208 added this to the 27.0.0 milestone Feb 13, 2025
@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch from 5bc7fa1 to a346d7c Compare February 19, 2025 17:07
@ridz1208 ridz1208 removed their assignment Feb 19, 2025
@ridz1208
Copy link
Collaborator Author

@nicolasbrossard @cmadjar One issue remains here, can someone upload a scan for a candidate not at their site/project ?

@driusan
Copy link
Collaborator

driusan commented Feb 24, 2025

Two issues--what Rida said, and it has conflicts and can't be merged

@nicolasbrossard
Copy link
Contributor

@ridz1208 @driusan @cmadjar I'll upload a scan for a candidate not at their site/project once this PR has been rebased.

@nicolasbrossard
Copy link
Contributor

All cases were tested on my VM and I could not find a bug. I did fid minor typos (see review). I could not test whether or not a user can upload a scan to a session that is not associated to either a project or a site he's not allowed to use since the imaging uploader was broken at the time of testing, so this test is still pending.

$projectString = implode("','", $user->getProjectIDs());
$username = $user->getUsername();

if ($user->hasPermission('imaging_uploader_nosessionid')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpicking here, but the if/else could be rewritten as:

$where = " WHERE 
            (s.CenterID IN ('$centerString') 
             AND 
             s.ProjectID IN ('$projectString')
            ) OR mu.UploadedBy='$username'";

if ($user->hasPermission('imaging_uploader_nosessionid')) {
    $where .= " OR s.CenterID IS NULL
                         OR s.ProjectID IS NULL";
}                    

3. Set the `useSiteProjectPermissions` (Use Site Project Permissions) Configuration to NO and make sure your
user does NOT have the `imaging_uploader_nosessionid` permission (do not use superuser)
[Manual Testing]
4. Check that when accessing the Imaging Uploader page, the 'Browse' tab displays all the uploads done for all users.
Copy link
Contributor

Choose a reason for hiding this comment

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

Step 4: if the user does not have imaging_uploader_nosessionid, then he/she should not see ALL uploads done for all users (only those that have a session ID).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@nicolasbrossard IF the useImagingSiteProjectPermissions I think the imaging_uploader_nosessionid should not block you from seeing ALL scans. thats done for backwards compatibility (or at least it should be) i.e. projects not expecting a sessionID to always be defined leave the configuration off and are unaffected by the new permissions.

Is this not the functionality you noticed?

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right: if useImagingSiteProjectPermissionsis not No, then you see all scans. Disregard my last comment.

INSERT INTO `ConfigSettings` (`ID`, `Name`, `Description`, `Visible`, `AllowMultiple`, `DataType`, `Parent`, `Label`, `OrderNumber`) VALUES (130,'DownloadPath','Where files are downloaded',1,0,'text',26,'Downloads',4);
INSERT INTO `ConfigSettings` (`ID`, `Name`, `Description`, `Visible`, `AllowMultiple`, `DataType`, `Parent`, `Label`, `OrderNumber`) VALUES (131,'EEGUploadIncomingPath', 'Path to the upload directory for incoming EEG studies', 1, 0, 'text', 26, 'EEG Incoming Directory', 15);
INSERT INTO `ConfigSettings` (`ID`, `Name`, `Description`, `Visible`, `AllowMultiple`, `DataType`, `Parent`, `Label`, `OrderNumber`) VALUES (132,'useDoB','Use DoB (Date of Birth)',1,0,'boolean',1,'Use DoB',12);
INSERT INTO `ConfigSettings` (`ID`, `Name`, `Description`, `Visible`, `AllowMultiple`, `DataType`, `Parent`, `Label`, `OrderNumber`) VALUES (133,'useImagingSiteProjectPermissions','Restricts access to dat based on both sites and project. Allows access to data with no session affiliated using a special permission only',1,0,'boolean',50,'Use Advanced Site Project Permissions',5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo:
access to dat => access to data

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll fix it with the rebase thanks

@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch from a346d7c to ea174fa Compare February 26, 2025 19:57
@nicolasbrossard
Copy link
Contributor

I successfully uploaded a scan for a project/site that I am not allowed to use. Not sure this is a desirable feature...

);
}
// Basic fields have been validated, check user permisions
$session = \TimePoint::singleton($candidate['SessionID']);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not going to work: TimePoint::singleton takes a SessionID as argument.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🤦

@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch 3 times, most recently from f602eb4 to 5ea200a Compare February 27, 2025 01:53
@ridz1208 ridz1208 removed the State: Blocked PR or issue awaiting an external event such as the merge or another PR to proceed label Feb 27, 2025
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

Rebasing too fast maybe? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AAAAAAAAAAAAAAAAA

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch 2 times, most recently from 151db25 to 1a4805f Compare February 27, 2025 02:22
@nicolasbrossard
Copy link
Contributor

With useImagingSiteProjectPermissions turned on and as a user that only has Imaging Uploader: View/Upload Imaging Scans - Own Sites, I cannot upload a scan to a site/project I am not affiliated with. When useImagingSiteProjectPermissions is turned off though, I can. I am assuming that's the intended behaviour so all is good.

@ridz1208
Copy link
Collaborator Author

@nicolasbrossard yes intended behaviour (I tried to clarify that in the test plan) but basically the configuration option is meant to switch beteeen the current way the module works (everyone can do everything) and the institutional way where people can only operate within their sites and projects

@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch 4 times, most recently from dbcf7e8 to 1c0899c Compare February 27, 2025 20:33
The imaging uploader module uses one permission called `imaging_uploader` that
is necessary to have access to the module and gives the user the ability to
upload and browse all scans uploaded to the database.
*In the interest of backwards compatibility, permission behaviour varies slightly
Copy link
Contributor

Choose a reason for hiding this comment

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

Backward compatibility (not backward_s_). There are also other occurrences.


Any of the following permissions grants access to the module.

`imaging_uploader_allsites`:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a good idea to mention somewhere that you always have access to the scans you uploaded.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its in the test plan... not sure where itwould fit in the readme? any sugestions ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would put the comment at the very end of the Module Permission section.

@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch from 1c0899c to e182e80 Compare March 11, 2025 14:57
@ridz1208 ridz1208 force-pushed the imaging_uploader_projectsite branch from e182e80 to cfda90b Compare March 11, 2025 14:59
@driusan driusan merged commit 8071ed9 into aces:main Mar 11, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Imaging PR or issue related to imaging Category: Feature PR or issue that aims to introduce a new feature Category: Security PR or issue that aims to improve security Difficulty: Simple PR or issue that should be easy to implement, review, or test Language: PHP PR or issue that update PHP code Project: C-BIG & ARCHIMEDES Issue or PR related to the C-BIG project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants