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

SAK-49716 Scheduled (un)publishing not pinning/removing sites correctly #12350

Merged
merged 4 commits into from
Feb 13, 2024

Conversation

hornersa
Copy link
Contributor

@hornersa hornersa commented Feb 7, 2024

jira: https://sakaiproject.atlassian.net/browse/SAK-49716

I revised PortalServiceImpl.canUserUpdateSite because securityService.unlock-- the basis for that method-- failed to deliver the desired value for students for the scheduled unpublishing test case. Whereas use of site.isAllowed(userId, SiteService.SECURE_UPDATE_SITE) instead provided consistent results for all test cases.

@@ -779,14 +780,29 @@ else if (iconType.equalsIgnoreCase("cl")){
}

private boolean canUserUpdateSite(String userId, String siteId) {
return securityService.unlock(userId, SiteService.SECURE_UPDATE_SITE, siteService.siteReference(siteId));
try {
Copy link
Contributor

@ern ern Feb 8, 2024

Choose a reason for hiding this comment

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

this was the performance killer which is why I changed this to a security service check, it would be preferred to not switch back to the expensive calls?

Copy link
Contributor

Choose a reason for hiding this comment

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

right, you're now loading the entire site, pages, tools, properties, members

Copy link
Contributor Author

@hornersa hornersa Feb 8, 2024

Choose a reason for hiding this comment

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

Oddly, securityService.unlock will return 'true' for student members of a site during scheduled publish events or scheduled unpublish events. This is counter-intuitive especially because securityService.unlock returns false (as expected) during the events of publishing and unpublishing a site manually.

Fortunately, for scheduled publish events, canUserUpdateSite is not as significant a determinant like it is for scheduled unpublish events.

I haven't begun adding debugging code to SakaiSecurity.unlock to assess what's causing that function to return true for student members. If that method is indeed a bug, that would obviously be something to investigate and fix.

However, if that function should be left as is, then one approach (a kind of hack) would be to distinguish scheduled unpublish events (site.unpublish.scheduled) from their manual analog (site.unpublish) in order execute the more performance costly logic only when responding to scheduled unpublish.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

the first thing I think of is the use of a SecurityAdvisor that is set to allow everything .... so during the publishing process it doesn't filter and just says TRUE for everything .... where is the code? my guess is you will find a SecurityAdvisor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the kernel SakaiSecurity.java (approx. line 728) does indeed consult SecurityAdvisor for a few conditions. Empirically it seems to be a factor in returning 'true' for the unlock method during scheduled unpublishing/publishing.

How should I proceed without risking introducing regressions elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

remove all of the SecurityAdvisor use

then you need to run the job as a user. take a look at a job in the jobscheduler directory. just grep for session.setUserEid

then the job will run as a real user (admin user) instead of running with the advisors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Thanks for the clarification.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've now force pushed suggested revisions.

Copy link
Contributor

Choose a reason for hiding this comment

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

nice job. i assume all working well in your testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, yes. For me this passed the test plan in SAK-49716.

@ern ern merged commit 1d09204 into sakaiproject:master Feb 13, 2024
4 checks passed
ern pushed a commit that referenced this pull request Apr 5, 2024
…ly (#12350)

Co-authored-by: Horner, Sean A <hornersa@plu.edu>
Co-authored-by: Sam Ottenhoff <ottenhoff@longsight.com>
(cherry picked from commit 1d09204)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants