Hallo Leute, Ich arbeite mit Spring Boot Security und möchte ein einloggen Formular schreiben. Die Formular für einloggen funktioniert aber ich habe keine Ahnung, wie man ausloggen herstellen kann. Ich arbeite mit Java als Controller und Thymeleaf kommt auch noch dazu. Für ausloggen was soll ich machen?
Ich lasse meine Konfiguration für einloggen Form auch hier.
Ich lasse meine Konfiguration für einloggen Form auch hier.
Java:
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password(passwordEncoder().encode("user")).roles("USER").and()
.withUser("admin").password(passwordEncoder().encode("admin")).roles("ADMIN");
}
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers("/admin/**").hasRole("ADMIN").antMatchers("/anonymous*")
.anonymous().antMatchers("/login*").permitAll().anyRequest().authenticated().and().formLogin()
.defaultSuccessUrl("/homepage.html").and().logout().logoutUrl("/perform_logout")
.deleteCookies("JSESSIONID");
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}