Skip to content

Commit

Permalink
Merge pull request #60 from OpusCapita/PROC-21713
Browse files Browse the repository at this point in the history
PROC-21713 - Slow getUserAuthorities execution when many delegations …
  • Loading branch information
jacekniezgoda-oc authored Oct 28, 2024
2 parents 4c6cb6d + 02b673e commit c68364a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
5 changes: 1 addition & 4 deletions grails-app/controllers/GrailsFlowSecureController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ abstract class GrailsFlowSecureController {
* @return
*/
protected def getUserAuthorities(def session) {
def users = securityHelper.getUsers(session)
def userRoles = securityHelper.getUserRoles(session)
def userGroups = securityHelper.getUserGroups(session)
return AuthoritiesUtils.getAuthorities(users, userRoles, userGroups)
return securityHelper.getUserAuthorities(session)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ import org.quartz.SimpleTrigger

import java.util.concurrent.Future

import static org.quartz.TriggerKey.*;
import java.util.concurrent.ThreadFactory
import com.jcatalog.grailsflow.status.ProcessStatusEnum
import com.jcatalog.grailsflow.status.NodeStatusEnum
import com.jcatalog.grailsflow.engine.execution.ExecutionResultEnum
import com.jcatalog.grailsflow.model.definition.ProcessNodeDef
import com.jcatalog.grailsflow.engine.concurrent.ProcessNotifier
import com.jcatalog.grailsflow.model.definition.ProcessDef
import org.quartz.Trigger
import org.quartz.TriggerBuilder
import org.quartz.JobDataMap
import com.jcatalog.grailsflow.cluster.GrailsflowLock

/**
* Process Manager service is an engine that deals with processes:
Expand Down Expand Up @@ -801,7 +798,7 @@ class ProcessManagerService implements InitializingBean {
log.debug("Node execution was interrupted!")
return ExecutionResultEnum.INTERRUPTED_BY_KILLING.value()
} else {
log.error("Node execution throwed exception", e)
log.error("Node execution thrown exception", e)
}

ProcessNodeException exception = new ProcessNodeException(e)
Expand Down Expand Up @@ -1701,11 +1698,7 @@ class ProcessManagerService implements InitializingBean {
}

Collection<String> getUserAuthorities() {
Collection<String> users = securityHelper.getUsers()
Collection<String> userRoles = securityHelper.getUserRoles()
Collection<String> userGroups = securityHelper.getUserGroups()

return AuthoritiesUtils.getAuthorities(users, userRoles, userGroups)
return securityHelper.getUserAuthorities(null)
}

boolean hasUserAccessToProcessNode(ProcessNode processNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GrailsflowSecurityHelper implements SecurityHelper {
* @return "grailsflow"
*/
String getUser(def session) {
return "grailsflow";
return "grailsflow"
}

/**
Expand All @@ -49,7 +49,7 @@ class GrailsflowSecurityHelper implements SecurityHelper {
* @param session
* @return
*/
List<String> getUsers(Object session) {
List<String> getUsers(def session) {
return [getUser(session)]
}

Expand All @@ -60,7 +60,7 @@ class GrailsflowSecurityHelper implements SecurityHelper {
*/
List<String> getUserRoles(def session) {
def roles = ["GRAILSFLOW"]
return (List<String>)roles;
return (List<String>)roles
}

/**
Expand All @@ -70,7 +70,20 @@ class GrailsflowSecurityHelper implements SecurityHelper {
*/
List<String> getUserGroups(def session) {
def groups = ["Grailsflow"]
return (List<String>)groups;
return (List<String>)groups
}

/**
* Always return authorities of "GRAILSFLOW" user, "GRAILSFLOW" role and "Grailsflow" group.
* @param session
* @return authorities
*/
List<String> getUserAuthorities(def session) {
return AuthoritiesUtils.getAuthorities(
getUsers(session),
getUserRoles(session),
getUserGroups(session)
)
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ interface SecurityHelper {
*/
List<String> getUserGroups(def session)

/**
* Returns the authorities list for logged user.
*
* @param session
*
* @return list of authorities
*/
List<String> getUserAuthorities(def session)

/**
* Checks if a user has access to process node if it doesn't belong to the assignee list of this process node
* @param ProcessNode
Expand Down

0 comments on commit c68364a

Please sign in to comment.