好的,我找到了解决方案:我需要手动添加一个 securityListener。之前startFlow
:
setFlowExecutionListener(getSecurityListener(new String[] {"ROLE_ADMIN_FAKE"}));
在哪里
private FlowExecutionListener getSecurityListener(String[] roles) {
List<GrantedAuthority> result = new ArrayList<>();
for (String role: roles) {
SimpleGrantedAuthority authority = new SimpleGrantedAuthority(role);
result.add(authority);
}
Authentication auth = new PreAuthenticatedAuthenticationToken("Igor", "", result);
SecurityContextHolder.getContext().setAuthentication(auth);
return new SecurityFlowExecutionListener();
}