[LBAC-10] Failed to get the location property from the Daemon thread user Created: 2018-07-11  Updated: 2018-07-15  Resolved: 2018-07-15

Status: Closed
Project: Location Based Access Control
Component/s: None
Affects Version/s: None
Fix Version/s: 0.1.0

Type: Bug Priority: Should
Reporter: Suthagar Kailayapathy Assignee: Suthagar Kailayapathy
Resolution: Fixed Votes: 0
Labels: gsoc2018
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Complexity: Low
Daniel Kayiwa, Suthagar Kailayapathy
Designated Committer: Suthagar Kailayapathy


Location based access control fetches the session location from the UserContext of the logged in user. 

There are some listeners(i.e : PatientViewedEventListener) which are running in the background as the Daemon threads. So when a method (i.e : getPatientByUuid()) calls from that Daemon thread, it uses a daemon user to access the authenticated properties

Talk Discussion: https://talk.openmrs.org/t/could-not-fetch-the-usercontext-for-a-getpatientbyuuid-call-from-emrapi-module/18917


Dev Notes. 

Location based control module should provide an exception for the daemon thread user since that user doesn't have any location property itself and it is common for all system.

Comment by Suthagar Kailayapathy [ 2018-07-11 ]

Daniel Kayiwa I added an exception for Daemon thread to access the methods which are covered by AOP Advices in Location based access control. Then the daemon thread user will not have any restrictions to access the objects from different locations.

Please review this PR : https://github.com/openmrs/openmrs-module-locationbasedaccess/pull/13


Comment by Daniel Kayiwa [ 2018-07-11 ]

Added some comments on github.

Comment by Suthagar Kailayapathy [ 2018-07-12 ]

Added a comment for the review.

Comment by Daniel Kayiwa [ 2018-07-12 ]

Merged at https://github.com/openmrs/openmrs-module-locationbasedaccess/commit/dc1f2548225252ed3356e967bee0e402c2f4d8a6
Thanks Suthagar Kailayapathy

Comment by Suthagar Kailayapathy [ 2018-07-13 ]

Need some fix to check the Context.getAutheicatedUser() for null object.

Comment by Suthagar Kailayapathy [ 2018-07-13 ]

Please review this PR : https://github.com/openmrs/openmrs-module-locationbasedaccess/pull/16

Comment by Daniel Kayiwa [ 2018-07-15 ]

Merged at https://github.com/openmrs/openmrs-module-locationbasedaccess/commit/a388581be98c75a8fd5884c888d5bb2372ad9327
Thanks Suthagar Kailayapathy

Generated at Tue Feb 19 16:23:53 UTC 2019 using Jira 7.13.1#713001-sha1:5e06076c2d215a6f699b7e5c90ab2fae7ba5a1ce.