|
|
@ -3,6 +3,8 @@ package mx.gob.jumapacelaya.api; |
|
|
|
import com.vaadin.flow.spring.security.VaadinWebSecurity; |
|
|
|
import mx.gob.jumapacelaya.services.UserService; |
|
|
|
import mx.gob.jumapacelaya.views.login.LoginView; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
@ -11,6 +13,7 @@ import org.springframework.http.HttpMethod; |
|
|
|
import org.springframework.ldap.core.support.LdapContextSource; |
|
|
|
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
|
|
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.builders.WebSecurity; |
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
|
|
|
import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider; |
|
|
|
import org.springframework.security.web.util.matcher.AntPathRequestMatcher; |
|
|
@ -18,14 +21,21 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher; |
|
|
|
@EnableWebSecurity |
|
|
|
@Configuration |
|
|
|
public class SecurityConfig extends VaadinWebSecurity { |
|
|
|
private static final Logger log = LoggerFactory.getLogger(SecurityConfig.class); |
|
|
|
|
|
|
|
private UserService userService; |
|
|
|
|
|
|
|
|
|
|
|
public void setUserService(UserService userService) { |
|
|
|
this.userService = userService; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void configure(WebSecurity web) throws Exception { |
|
|
|
// Customize your WebSecurity configuration. |
|
|
|
super.configure(web); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected void configure(HttpSecurity http) throws Exception { |
|
|
|
http.authorizeHttpRequests(auth -> auth |
|
|
@ -39,14 +49,16 @@ public class SecurityConfig extends VaadinWebSecurity { |
|
|
|
) |
|
|
|
.formLogin(formLogin -> formLogin |
|
|
|
.loginPage("/login") |
|
|
|
.successHandler((request, response, authentication) -> { |
|
|
|
String username = authentication.getName(); |
|
|
|
/*.successHandler((request, response, authentication) -> { |
|
|
|
//String username = authentication.getName(); |
|
|
|
log.debug("Configure:loginSuccess: {}", authentication.getName()); |
|
|
|
if (userService.getAuthenticatedRedmineUser() == null) { |
|
|
|
log.debug("Configure:getAuthenticatedRedmineUser Error: {}", authentication.getName()); |
|
|
|
response.sendRedirect("/login"); |
|
|
|
} else { |
|
|
|
response.sendRedirect(""); |
|
|
|
} |
|
|
|
}) |
|
|
|
} //else { |
|
|
|
//response.sendRedirect(""); |
|
|
|
//} |
|
|
|
})*/ |
|
|
|
.failureUrl("/login?error=true") // Corrigiendo la URL de fallo |
|
|
|
); |
|
|
|
super.configure(http); |
|
|
|