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

ExtendedInMemoryUserDetailsManager.java potential problem #4303

Open
FlyingDutchmanLQY opened this issue Apr 14, 2023 · 1 comment
Open

ExtendedInMemoryUserDetailsManager.java potential problem #4303

FlyingDutchmanLQY opened this issue Apr 14, 2023 · 1 comment

Comments

@FlyingDutchmanLQY
Copy link

activiti-core-common/activiti-spring-identity/src/main/java/org/activiti/core/common/spring/identity/ExtendedInMemoryUserDetailsManager.java

public class ExtendedInMemoryUserDetailsManager extends InMemoryUserDetailsManager {

    private List<String> users = new ArrayList<>();
    private List<String> groups = new ArrayList<>();

    @Override
    public void createUser(UserDetails user) {
        super.createUser(user);
        users.add(user.getUsername());
        groups = user.getAuthorities().stream()
                .filter(x -> (x.getAuthority().contains("GROUP")))
                .map(x -> (x.getAuthority()))
                .collect(Collectors.toList());
    }
     ...
}

This createUser method seems to overwrite the member variable private List<String> groups.
Maybe it should be like below?

groups.addAll(user.getAuthorities().stream()
                .filter(x -> (x.getAuthority().contains("GROUP")))
                .map(x -> (x.getAuthority()))
                .collect(Collectors.toList()));
@FlyingDutchmanLQY FlyingDutchmanLQY changed the title ExtendedInMemoryUserDetailsManager.java seems to have a poti ExtendedInMemoryUserDetailsManager.java potential problem Apr 14, 2023
@balsarori
Copy link
Member

Good catch! Feel free to create a PR to fix that. A test for this case can go here here.

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

No branches or pull requests

2 participants