Post Spring Security in the Camunda Engine, what would cancel?

I was able to successfully integrate Spring Security with Camunda IdentityService . My goal is to share a common authentication area between them, because we have a spring-boot web application in which camunda also runs. In our Spring application, Security must exclusively control single-mode auth, acting as a read-only Camunda client.

We plan to associate business processes with users, and these users must authenticate from Spring Security.

My question is, what should I exactly implement / override?

My current code is as follows:

import org.camunda.bpm.engine.impl.identity.db.DbReadOnlyIdentityServiceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.AuthenticationException;
import org.springframework.stereotype.Component;

/**
 * Wires Camunda {@link org.camunda.bpm.engine.IdentityService} with Spring Security.
 * TODO check if other method overrides are needed
 */
@Component
public class SpringSecurityReadOnlyIdentityServiceProvider extends DbReadOnlyIdentityServiceProvider {

    @Autowired
    private AuthenticationManager authenticationManager;

    /**
     * Checks if username and password is valid.
     *
     * @param userId   Username
     * @param password Password
     * @return True if authentication succeeded
     */
    @Override
    public boolean checkPassword(String userId, String password) {
        try {
            authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(userId, password));
        } catch (AuthenticationException e) {
            return false;
        }
        return true;
    }
}

( ), , .

Spring . ? . , , ReadOnlyIdentityProvider WritableIdentityProvider, , . DbReadOnlyIdentityServiceProvider.

!

+4

Source: https://habr.com/ru/post/1669931/


All Articles