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
Tags 8.0.3
No related merge requests found
...@@ -16,7 +16,7 @@ import javax.sql.DataSource; ...@@ -16,7 +16,7 @@ import javax.sql.DataSource;
@Configuration @Configuration
@EnableJpaRepositories("hbp.mip.repositories") @EnableJpaRepositories(basePackages = {"hbp.mip.experiment", "hbp.mip.user"})
public class PersistenceConfiguration { public class PersistenceConfiguration {
@Primary @Primary
...@@ -33,7 +33,8 @@ public class PersistenceConfiguration { ...@@ -33,7 +33,8 @@ public class PersistenceConfiguration {
emfb.setDataSource(portalDataSource()); emfb.setDataSource(portalDataSource());
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
emfb.setJpaVendorAdapter(vendorAdapter); emfb.setJpaVendorAdapter(vendorAdapter);
emfb.setPackagesToScan("hbp.mip.models.DAOs"); emfb.setPackagesToScan("hbp.mip.experiment", "hbp.mip.user");
return emfb; return emfb;
} }
......
...@@ -22,10 +22,7 @@ import org.springframework.security.web.csrf.CookieCsrfTokenRepository; ...@@ -22,10 +22,7 @@ import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler; import org.springframework.security.web.csrf.XorCsrfTokenRequestAttributeHandler;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Collection; import java.util.*;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Configuration @Configuration
...@@ -115,11 +112,16 @@ public class SecurityConfiguration { ...@@ -115,11 +112,16 @@ public class SecurityConfiguration {
@RequiredArgsConstructor @RequiredArgsConstructor
static class GrantedAuthoritiesMapperImpl implements GrantedAuthoritiesMapper { static class GrantedAuthoritiesMapperImpl implements GrantedAuthoritiesMapper {
private static Collection<GrantedAuthority> extractAuthorities(Map<String, Object> claims) { 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) .map(SimpleGrantedAuthority::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override @Override
public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) { public Collection<? extends GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities) {
Set<GrantedAuthority> mappedAuthorities = new HashSet<>(); 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