Skip to content

TRUNK-6203: Global properties access should be privileged#43

Merged
dkayiwa merged 2 commits into
masterfrom
TRUNK-6203
Aug 5, 2024
Merged

TRUNK-6203: Global properties access should be privileged#43
dkayiwa merged 2 commits into
masterfrom
TRUNK-6203

Conversation

@wikumChamith

Copy link
Copy Markdown
Member

Description of what I changed

After openmrs/openmrs-core#4601, users must possess the 'Get Global Properties' privilege to access global properties. This grants it as a proxy privilege so users can access essential pages, such as the login page.

Issue I worked on

see https://openmrs.atlassian.net/browse/TRUNK-6203

Checklist: I completed these to help reviewers :)

  • My IDE is configured to follow the code style of this project.

    No? Unsure? -> configure your IDE, format the code and add the changes with git add . && git commit --amend

  • [] I have added tests to cover my changes. (If you refactored
    existing code that was well tested you do not have to add tests)

    No? -> write tests and add them to this commit git add . && git commit --amend

  • I ran mvn clean package right before creating this pull request and
    added all formatting changes to my commit.

    No? -> execute above command

  • All new and existing tests passed.

    No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.

  • My pull request is based on the latest changes of the master branch.

    No? Unsure? -> execute command git pull --rebase upstream master

@wikumChamith
wikumChamith force-pushed the TRUNK-6203 branch 2 times, most recently from 24fc2d6 to c339410 Compare July 30, 2024 07:06
Context.removeProxyPrivilege("Get Global Properties");
}

if (globalProperty.equalsIgnoreCase("true")) {

@dkayiwa dkayiwa Jul 30, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if globalProperty is returned as null?

if (Context.getAdministrationService().getGlobalProperty(AddressHierarchyConstants.GLOBAL_PROP_INITIALIZE_ADDRESS_HIERARCHY_CACHE_ON_STARTUP).equalsIgnoreCase("true")) {
String globalProperty = "";
try {
Context.addProxyPrivilege("Get Global Properties");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't we have a constant for the privilege?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'll have to update the platform version. However, it is giving me a lot of errors.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Which version did you upgrade it to? Can i look at the errors?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thinking about this again, it does not look good to do this from here because this can be called from different contexts. Can we do it from where the call originates?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I updated the PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I tried updating the platform version to 1.11.6. I am seeing multiple test errors similar to this:

[ERROR] getChildAddressHierarchyEntries_shouldGetChildAddressHierarchyEntries(org.openmrs.module.addresshierarchy.AddressHierarchyServiceTest)  Time elapsed: 0.164 s  <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/home/wikum/Documents/Code/OpenMRS/openmrs-module-addresshierarchy/api/target/classes/org/openmrs/module/addresshierarchy/i18n/DisabledI18nCache.class]; nested exception is java.lang.ArrayIndexOutOfBoundsException: 1
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1

@dkayiwa
dkayiwa merged commit f98ce16 into master Aug 5, 2024
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.

2 participants