Im trying to start a spring boot application by integrate spring security, following an example. My problem is how to configure correctly my application, For now, I success login then when I try to acces to any url I had always error 403! And I didn't understand really the problem. This is my securtyConfig:
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/", "/home").permitAll()
.anyRequest().permitAll()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll()
.and()
.csrf();;
}
MvcConfig:
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("home");
registry.addViewController("/").setViewName("login");
registry.addViewController("/hello").setViewName("hello");
registry.addViewController("/login").setViewName("login");
registry.addViewController("/403").setViewName("403");
}
My Login page:
<form action="/home" method="post" class="form-signin">
<p class="text-muted text-center btn-block btn btn-primary btn-rect">
Enter your useame and password
</p>
<input type="text" placeholder="Useame" name="useame" class="form-control" />
<input type="password" placeholder="Password" name="password" class="form-control" />
<button class="btn text-muted text-center btn-danger" type="submit">Sign in</button>
<c:if test="${param.error ne null}">
<div class="alert-danger">Invalid useame and password.</div>
</c:if>
<c:if test="${param.logout ne null}">
<div class="alert-normal">You have been logged out.</div>
</c:if>
<input type="hidden" name="${_csrf.parameterName}"
value="${_csrf.token}" />
</form>
Now after login, when I try to access to any url I had error 403! Example:
<form action="/alo" method = "POST">
<input type="text" name="test"/>
<input type="submit"/>
</form>
The controller:
@RequestMapping(value = "/alo", method = RequestMethod.POST)
public String dashboard() {
System.err.println("PRIN: ");
retu "/";
}
The controller is never been invocat!!
Anyone Has an idea please?
