N
N
Nightmare0582021-11-30 00:38:53
Java
Nightmare058, 2021-11-30 00:38:53

Why doesn't logout work?

Good day.
Having read the recommended material from the last question, I passed the code and decided to add a logout.
Google told me that logout () will help me with this.
But for some reason, unknown to me, logout does not occur
. I suspect that the point is that I chose the wrong method.

My task is that after the user goes to /logout, there will be an logout and a redirect to the specified page. After checking the work, I found that the redirect after the logout occurs, but I can still access closed resources.
Maybe I'm somehow not cleaning my cookies?
The logout code was taken from the baeldung, mb should have a different deleteCookies value.

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        http.authorizeRequests().antMatchers("/", "/registration").permitAll()
                .anyRequest().authenticated()
                .and()
                .httpBasic()
                .and()
                .sessionManagement().disable();
        http.logout()
                .invalidateHttpSession(true)
                .deleteCookies("JSESSIONID")
                .logoutSuccessUrl("/after_login");
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question