diff --git a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java
index 2fbdc84ad..677bb736d 100644
--- a/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java
+++ b/src/main/java/org/springframework/cheapy/configuration/SecurityConfiguration.java
@@ -20,9 +20,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
* and open the template in the editor.
*/
-/**
- * @author japarejo
- */
+
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@@ -37,19 +35,22 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
http.authorizeRequests().antMatchers("/resources/**", "/webjars/**", "/h2-console/**").permitAll()
.antMatchers(HttpMethod.GET, "/", "/oups").permitAll()
.antMatchers("/users/new").permitAll()
+ .antMatchers("/login/**").anonymous()
.antMatchers("/usuarios/new").permitAll()
.antMatchers("/admin/**").hasAnyAuthority("admin")
.antMatchers("/owners/**").hasAnyAuthority("owner", "admin")
- .antMatchers("/vets/**").authenticated().anyRequest().denyAll()
+ .antMatchers("/vets/**").authenticated().anyRequest().anonymous()
.and().formLogin()
- /* .loginPage("/login") */
- .failureUrl("/login-error").and().logout().logoutSuccessUrl("/");
+ .loginPage("/login")
+ .successForwardUrl("/")
+ .failureUrl("/login?error")
+ .and().logout().logoutUrl("/login?logout");
// Configuración para que funcione la consola de administración
// de la BD H2 (deshabilitar las cabeceras de protección contra
// ataques de tipo csrf y habilitar los framesets si su contenido
// se sirve desde esta misma página.
- http.csrf().ignoringAntMatchers("/h2-console/**");
+ //http.csrf().ignoringAntMatchers("/h2-console/**");
http.headers().frameOptions().sameOrigin();
}
diff --git a/src/main/java/org/springframework/cheapy/system/LoginController.java b/src/main/java/org/springframework/cheapy/system/LoginController.java
new file mode 100644
index 000000000..e0e0fa7a9
--- /dev/null
+++ b/src/main/java/org/springframework/cheapy/system/LoginController.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cheapy.system;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@Controller
+class LoginController {
+
+ @GetMapping("/login")
+ public String login() {
+ return "login";
+ }
+
+
+
+}
diff --git a/src/main/java/org/springframework/cheapy/system/WelcomeController.java b/src/main/java/org/springframework/cheapy/system/WelcomeController.java
index 85782e967..1f3b04637 100644
--- a/src/main/java/org/springframework/cheapy/system/WelcomeController.java
+++ b/src/main/java/org/springframework/cheapy/system/WelcomeController.java
@@ -27,4 +27,6 @@ class WelcomeController {
return "welcome";
}
+
+
}
diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp
new file mode 100644
index 000000000..bf718d6e4
--- /dev/null
+++ b/src/main/webapp/WEB-INF/jsp/login.jsp
@@ -0,0 +1,300 @@
+<%@ page session="false" trimDirectiveWhitespaces="true" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="cheapy" tagdir="/WEB-INF/tags" %>
+<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
+
+
+
+
+
+
+
+
+
+
+