use of io.jmix.core.CoreProperties in project jmix by jmix-framework.
the class AnonymousConfigurer method initAnonymous.
protected void initAnonymous(HttpSecurity http) {
try {
ApplicationContext applicationContext = http.getSharedObject(ApplicationContext.class);
CoreProperties coreProperties = applicationContext.getBean(CoreProperties.class);
UserRepository userRepository = applicationContext.getBean(UserRepository.class);
http.anonymous(anonymousConfigurer -> {
anonymousConfigurer.key(coreProperties.getAnonymousAuthenticationTokenKey());
anonymousConfigurer.principal(userRepository.getAnonymousUser());
Collection<? extends GrantedAuthority> anonymousAuthorities = userRepository.getAnonymousUser().getAuthorities();
if (!anonymousAuthorities.isEmpty()) {
anonymousConfigurer.authorities(new ArrayList<>(userRepository.getAnonymousUser().getAuthorities()));
}
});
} catch (Exception e) {
throw new RuntimeException("Error while init security", e);
}
}
Aggregations