timestamp status 999 error none message no message available

Status

I'm making an app with Spring boot. Implement the authentication function with Spring-security.

problem

When you press submit to perform the authentication process, the login form will transition to the page where the title error occurred. (The title error was displayed in JSON.)

Cause

Occurs when there is no permission for the URL to be transitioned in the authentication process. When authentication fails, it transitions to / login-error, but it occurred because there is no permission to access / login-error.

Solution

@Override
    protected void configure(HttpSecurity http) throws Exception {
        
        http
        	.authorizeRequests()  //Authorization settings
            	.antMatchers("/", "/find", "/login", "/signup", "/error", "/login-error").permitAll() //All user permissions
            	.anyRequest().authenticated()  //Access is not permitted in all other cases without authentication
            	.and()
            .formLogin()  //Login settings
            	.loginPage("/login")   
            	.loginProcessingUrl("/login")   
            	.usernameParameter("username")	
            	.passwordParameter("password")  
            	.failureUrl("/login-error")      //URL when authentication fails
            	.defaultSuccessUrl("/")     //Transition destination when authentication is successful
            	.and()
            .logout()	//Logout settings
            	.logoutRequestMatcher(new AntPathRequestMatcher("/logout**"))       //Logout processing path
            	.logoutSuccessUrl("/")                                        //Path when logout is completed
            	.permitAll();
        
    }

Recommended Posts

timestamp status 999 error none message no message available
About No Method Error