This commit is contained in:
parent
ff2db18f0a
commit
16a9a91790
@ -4,6 +4,7 @@ import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.views.LoginView;
|
||||
import com.vaadin.flow.spring.security.VaadinWebSecurity;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@ -24,6 +25,8 @@ import java.util.Collection;
|
||||
@EnableWebSecurity
|
||||
@Configuration
|
||||
public class SecurityConfig extends VaadinWebSecurity {
|
||||
@Value("${spring.ldap.url}")
|
||||
private String ldapUrl;
|
||||
|
||||
@Override
|
||||
protected void configure(final HttpSecurity http) throws Exception {
|
||||
@ -47,10 +50,10 @@ public class SecurityConfig extends VaadinWebSecurity {
|
||||
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManager(final UserDetailsContextMapper userDetailsContextMapper) {
|
||||
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
|
||||
"ldap://localhost:8389/dc=primefactorsolutions,dc=com");
|
||||
final DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(
|
||||
String.format("%s/dc=primefactorsolutions,dc=com", ldapUrl));
|
||||
contextSource.setCacheEnvironmentProperties(false);
|
||||
LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
|
||||
final LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource);
|
||||
factory.setUserDnPatterns("uid={0},ou=users");
|
||||
factory.setUserDetailsContextMapper(userDetailsContextMapper);
|
||||
|
||||
|
2
src/main/resources/application-test.properties
Normal file
2
src/main/resources/application-test.properties
Normal file
@ -0,0 +1,2 @@
|
||||
spring.ldap.url=ldap://localhost:8391
|
||||
spring.ldap.embedded.port=8391
|
@ -14,21 +14,19 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
import com.github.mvysny.kaributesting.v10.MockVaadin;
|
||||
import com.github.mvysny.kaributesting.v10.Routes;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles(value = "test")
|
||||
public class AbstractAppTests {
|
||||
private static final Routes routes = new Routes().autoDiscoverViews("com.primefactorsolutions");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user