# Custom IDM configuration

**URL:** <https://forum.flowable.org/t/custom-idm-configuration/6498>\
**Category:** Flowable Engine\
**Created:** [August 5, 2020, 6:14pm UTC](https://forum.flowable.org/t/custom-idm-configuration/6498 "2020-08-05T18:14:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjmac](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@tjmac](https://forum.flowable.org/u/tjmac)\
**Post date:** [August 5, 2020, 6:14pm UTC](https://forum.flowable.org/t/custom-idm-configuration/6498/1 "2020-08-05T18:14:31Z")

</div>

For some reason or another it seems like the custom implementation of idm has stopped working. I really dont see what is wrong as it has worked in past and is similar to the LDAP example.

Here is Engine configuration:

```
@Component
class FlowableConfigurationConfigurer implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
    @Override
    void configure(SpringProcessEngineConfiguration engineConfiguration) {
        //IDM Service
        engineConfiguration.setIdmEngineConfigurator(new CustomIdentityConfigurator())
    }
}

class CustomIdentityConfigurator extends IdmEngineConfigurator {
    @Override
    public void configure(AbstractEngineConfiguration engineConfiguration) {
        super.configure(engineConfiguration)
        getIdmEngineConfiguration(engineConfiguration)
                .setIdmIdentityService(new CustomIdentityService());
    }

    protected static IdmEngineConfiguration getIdmEngineConfiguration(AbstractEngineConfiguration engineConfiguration) {
        return (IdmEngineConfiguration) engineConfiguration.getEngineConfigurations().
                get(EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG);
    }
}

@Service
class CustomIdentityService extends IdmIdentityServiceImpl {
    @Override
    GroupQuery createGroupQuery() {
        new CustomGroupQuery()
    }
}

class CustomGroupQuery extends GroupQueryImpl {
    @Override
    long executeCount(CommandContext commandContext) {
        return executeQuery().size()
    }
    @Override
    List<Group> executeList(CommandContext commandContext) {
        return executeQuery()
    }
    static List<Group> executeQuery() {
        log.info("Gettting authorities for user: ${SecurityContextHolder.getContext().getAuthentication().getPrincipal()}")
        def groups = []
        def authorities = SecurityContextHolder.getContext().getAuthentication().authorities
        authorities.each {
            GrantedAuthority grantedAuthority ->
                log.debug("authority: ${grantedAuthority.authority}")
                groups.add(new GroupEntityImpl(id: grantedAuthority.authority))
        }
        groups
    }
}

```

The configure method is be called and the engineConfiguration.setIdmEngineConfigurator(new CustomIdentityConfigurator()) is being executed. But the it never fires the CustomGroupQuery as I was expecting when working with taskService. The executeQuery method at one time was being called when getting task, but now I cannot figure out why it is not.

---

<div class="post-metadata">

**Author:** ![tjmac](https://avatars.discourse-cdn.com/v4/letter/t/bc8723/32.png) [@tjmac](https://forum.flowable.org/u/tjmac)\
**Post date:** [August 6, 2020, 6:37pm UTC](https://forum.flowable.org/t/custom-idm-configuration/6498/2 "2020-08-06T18:37:40Z")

</div>

I was expecting that the CustomGroupQuery to be executed when the following API is called:

```
def tasksQuery = taskService.createTaskQuery().
        includeProcessVariables().
        includeTaskLocalVariables().taskCandidateOrAssigned(SecurityContextHolder.getContext().getAuthentication().name)
```

---

<div class="post-metadata">

**Author:** ![amporsim](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@amporsim](https://forum.flowable.org/u/amporsim)\
**Post date:** [August 7, 2020, 6:33am UTC](https://forum.flowable.org/t/custom-idm-configuration/6498/3 "2020-08-07T06:33:04Z")

</div>

Hi @tjmac

Your `CustomGroupdQuery` is not called, because the Groups of the passed User Id are fetched directly within SQL query.

Have a look here:

> <https://github.com/flowable/flowable-engine/blob/master/modules/flowable-task-service/src/main/resources/org/flowable/task/service/db/mapping/entity/Task.xml#L1017>

Regards,  
Simon
