Skip to content
Snippets Groups Projects
Unverified Commit 59ca41fe authored by K.Filippopolitis's avatar K.Filippopolitis Committed by GitHub
Browse files

Fixed a bug on the authorization of the users. (#76)

parent 783bfe1e
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ import javax.sql.DataSource;
@Configuration
@EnableJpaRepositories("hbp.mip.repositories")
@EnableJpaRepositories(basePackages = {"hbp.mip.experiment", "hbp.mip.user"})
public class PersistenceConfiguration {
@Primary
......@@ -33,7 +33,8 @@ public class PersistenceConfiguration {
emfb.setDataSource(portalDataSource());
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
emfb.setJpaVendorAdapter(vendorAdapter);
emfb.setPackagesToScan("hbp.mip.models.DAOs");
emfb.setPackagesToScan("hbp.mip.experiment", "hbp.mip.user");
return emfb;
}
......
......@@ -22,10 +22,7 @@ import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Configuration
......@@ -115,11 +112,16 @@ public class SecurityConfiguration {
@RequiredArgsConstructor
static class GrantedAuthoritiesMapperImpl implements GrantedAuthoritiesMapper {
private static Collection<GrantedAuthority> extractAuthorities(Map<String, Object> claims) {
return ((Collection<String>) claims.get("authorities")).stream()
Collection<String> authorities = (Collection<String>) claims.get("authorities");
if (authorities == null) {
return Collections.emptyList(); // or throw a more informative exception if appropriate
}
return authorities.stream()
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toList());
}
@Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
Set<GrantedAuthority> mappedAuthorities = new HashSet<>();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment