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

LBAC-10 Added exception for Daemon thread user to access the methods covered with AOP Advices #13

Merged
merged 1 commit into from Jul 12, 2018

Conversation

Projects
None yet
2 participants
@suthagar23
Copy link
Member

suthagar23 commented Jul 11, 2018

Description

Added 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.

Ticket

Ticket : https://issues.openmrs.org/browse/LBAC-10

@@ -52,37 +52,37 @@ public Advice getAdvice() {

private class PatientSearchAdvise implements MethodInterceptor {
public Object invoke(MethodInvocation invocation) throws Throwable {
Integer sessionLocationId = Context.getUserContext().getLocationId();
String locationAttributeUuid = Context.getAdministrationService().getGlobalProperty(LocationBasedAccessConstants.LOCATION_ATTRIBUTE_GLOBAL_PROPERTY_NAME);
Object object = invocation.proceed();

This comment has been minimized.

@dkayiwa

dkayiwa Jul 11, 2018

Member

To avoid all these formatting changes, can't you just return object if daemon user? Then the rest of the code stays as is.

This comment has been minimized.

@suthagar23

suthagar23 Jul 12, 2018

Author Member

The actual problem occurred at this point,
Integer sessionLocationId = Context.getUserContext().getLocationId();
daemon doesn't have any Location attribute. So that, I have cheked it before this line.

This comment has been minimized.

@dkayiwa

dkayiwa Jul 12, 2018

Member

Did you understand my comment?

This comment has been minimized.

@suthagar23

suthagar23 Jul 12, 2018

Author Member

Yes got it @dkayiwa and Fixed

@@ -13,4 +13,5 @@
public class LocationBasedAccessConstants {

public static final String LOCATION_ATTRIBUTE_GLOBAL_PROPERTY_NAME = "locationbasedaccess.locationAttributeUuid";
public static final String DAEMON_USER_UUID = "A4F30A1B-5EB9-11DF-A648-37A07F9C90FB";

This comment has been minimized.

@dkayiwa

dkayiwa Jul 12, 2018

Member

Instead of duplicating this which is already in the Daemon class, can't we just use Daemon.isDaemonUser()?

This comment has been minimized.

@suthagar23

suthagar23 Jul 12, 2018

Author Member

In the Daemon class, it was protected. So Can't use in outside.
In AppUI and EMRAPI also, we have defined this as a separate constant.

This comment has been minimized.

@dkayiwa

dkayiwa Jul 12, 2018

Member

Did you understand my alternative suggestion?

This comment has been minimized.

@suthagar23

suthagar23 Jul 12, 2018

Author Member

Ya Ya, Got it now and changed the code.

This comment has been minimized.

@dkayiwa

dkayiwa Jul 12, 2018

Member

Have you tested again to confirm that all is well?

Suthagar23
LBAC-10 Added exception for Daemon thread user to access the methods …
…covered with AOP Advices

LBAC-10 Added exception for Daemon thread user to access the methods covered with AOP Advices

@suthagar23 suthagar23 force-pushed the LBAC-10 branch from 1c62658 to a03e293 Jul 12, 2018

@dkayiwa dkayiwa merged commit dc1f254 into master Jul 12, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@suthagar23 suthagar23 deleted the LBAC-10 branch Aug 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.