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

Permission Performance Optimizations #2341

Merged
merged 2 commits into from
Feb 14, 2024
Merged

Permission Performance Optimizations #2341

merged 2 commits into from
Feb 14, 2024

Conversation

chrisknoll
Copy link
Collaborator

Implemented permission lookup to bypass hibernate.
Moved PermissionsDTO to PermissionManager
Removed GSON to use the app-wide ObjectMapper from Jackson

Required for OHDSI/Atlas#2912.

Moved PermissionsDTO to PermissionManager
Removed GSON to use the app-wide ObjectMapper from Jackson
Copy link
Collaborator

@anthonysena anthonysena left a comment

Choose a reason for hiding this comment

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

Looks good from review on the Atlas WG call - just one comment for review to make sure we've removed the com.google.code.gson reference.

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
Copy link
Collaborator

Choose a reason for hiding this comment

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

com.google.gson was removed from pom.xml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was partially addressed: there is a gson import related to google http client, somehow related to GoogleBigQuery. The confusion is: there's a install-file goal to include httpclient-gson, but then also a maven dependency to the same library, but different version. Probably redundant or something was missed, but we should minimize install-file goals as they complicate the build process. Will not address in this PR.

@chrisknoll chrisknoll merged commit f258186 into master Feb 14, 2024
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the perms-optimize branch February 14, 2024 00:21
@@ -305,7 +328,51 @@ public Set<PermissionEntity> getUserPermissions(UserEntity user) {

return permissions;
}

public PermissionsDTO queryUserPermissions(final String login) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@chrisknoll should getUserPermissions be deprecated in favor of this method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Depends:
the getuserPermissions is returning PermissionEntity...which is the JPA Entity Bean that represents the row of data in the DB, and fetchign permissions this way involves getting the roles from the user, iterating through each role and adding each permission from those roles into a final Set of PermissionEntity. The use of Set de-dupes permissions across roles.

queryUserPermissions provides more of a 'view' of distinct permissions associated with a user bypassing the JPA interface of sweeping through roles. It also structures the result to be 'indexed' such that you can quickly navigate to specific permissions that begin with a certain term.

The inputs to each of these are a bit different too: the former wants a ID or UserEntity, the latter works off of a login, and this is just based on the use-case of when you'd use one or the other. When we get to the point that we can clean up the API/object model in the 3.x release we can normalize and simplify a lot of this to a more simple, straight forward implementation.

@@ -114,6 +116,8 @@ public User getCurrentUser() throws Exception {
user.login = currentUser.getLogin();
user.name = currentUser.getName();
user.permissions = convertPermissions(permissions);
user.permissionIdx = authorizer.queryUserPermissions(currentUser.getLogin()).permissions;
Copy link
Contributor

Choose a reason for hiding this comment

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

does this mean user.permissions will no longer be needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's unclear. When I added the code, I was concerned with not breaking backwards compatibility. While I did do a search on where the user.permissions field was referenced, it doesn't find those uses by downstream apps like Atlas (ie: the value is populated, returned to Atlas via webAPI call, so removing it will break it there).

When we move into the 3.0 WebAPI changes, ( #2354) we can be more aggressive about removing obsolete/unused code.

@anthonysena anthonysena added this to the v2.15 milestone May 28, 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.

3 participants