Custom Identity Provider

Hi,
I have gone through HttpBasicAuthenticationProvider class. This is extracting the user name and password and check that againt default IdentityService. I want to customize this implementation. I have customized the HttpBasicAuthenticationProvider to read the "AUTHORIZATION header and extract the details against that. At this Stage I want to execute the “isAuthenticated” against my custome identity provider (public class SpringSecurityReadOnlyIdentityServiceProvider extends DbReadOnlyIdentityServiceProvider), which overrides checkPassword method.

The question I have is, how do I need to tell to camunda to use my IdentityServiceProvider. ( In other words, How can I register my own IdentityServiceProvider).

Regards,
Subbu

You can just set your own implementation on the ProcessEngineConfigurationImpl … if you are using the spring-boot-starter, the easiest approach is to provie a custom Bean for a CamundaProcessEngineConfiguration and do so in the preInit() method.

Hi @jangalinski,
I will try this and will update.

Hi @jangalinski,
I still confused on what to do inside the preInit() method. Could you please help me?

You have to define a Bean and set your Id provider

@Bean
public CamundaProcessEngineConfiguration customIdProvider(YourIdentityService identityService) {

    return new CamundaProcessEngineConfiguration(){
    @Override
    public void preInit(SpringProcessEngineConfiguration config) {
       config.setIdentityService(identityService);
    }
   }
}

this will replace the camunda default IDService with your own impl.

Just to be sure, the bean are suppose to be in a @Configuration class right?

I still got error message:

Could not autowire. No beans of ‘YourIdentityService’ type found.

I implemented the YourIdentityService class with ReadOnlyIdentityProvider like the documentation stated.

public class YourIdentityProvider implements ReadOnlyIdentityProvider {
    // methods implementation
}

By the way, are you sure putting the preInit method inside the customIdProvider method (I don’t know if method inside method could work)

Thanks in advance


UPDATE: found alternative configuration using IdentityProviderSessionFactory in this old forum


UPDATE2: tried to implement using IdentityProviderSessionFactory here, but still have issue(s)


UPDATE3: forgot to register YourIdentityService as a bean, but still got an error message

setIdentityService (org.camunda.bpm.engine.IdentityService) in ProcessEngineConfigurationImpl cannot be applied to (YourIdentityProvider)

*in my IDE, the CamundaProcessEngineConfiguration needs to implement preInit() method with ProcessEngineConfigurationImpl argument (actually the SpringProcessEngineConfiguration extends the ProcessEngineConfigurationImpl class)