based on this topic seems like I found the issue but I really don't know how to solve it.
I have the following configuration for the WebSecurityConfigurerAdapter because I am working with JWT security flow like in this page The problem is on the configuration side and not the built itself.
The configuration is like this:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/login").permitAll()
.antMatchers("/register/**").permitAll()
.antMatchers("/").permitAll()
.anyRequest().authenticated();
http.addFilterBefore(authenticationJwtTokenFilter(), UsernamePasswordAuthenticationFilter.class);
}
Unfortunately it doesn't let me access the homepage. If I do .antMatchers("/**").permitAll()
It will work fine.
When I access http://localhost:8080 I get:
2021-04-26 23:09:42.517 ERROR 10160 --- [nio-8080-exec-4] c.a.d.security.jwt.AuthEntryPointJwt : Unauthorized error: Full authentication is required to access this resource
This comes out form the unauthorizedHandler
but in the configuration the .antMatchers("/").permitAll()
is supposed to let me access the index but not.
If I go for example with .antMatchers("/**").permitAll()
It let me acess the page, but overall It will break the security flow.