Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.moviesandbooksrecommendationsservice.security;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.security.config.Customizer;
- import org.springframework.security.config.annotation.web.builders.HttpSecurity;
- import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
- import org.springframework.security.web.SecurityFilterChain;
- @Configuration
- @EnableWebSecurity
- public class SecurityConfig {
- @Bean
- public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
- http
- .authorizeHttpRequests(auth -> auth
- .requestMatchers("/secure/**").authenticated()
- .anyRequest().permitAll()
- )
- .oauth2Login(Customizer.withDefaults())
- .logout(logout -> logout
- .logoutUrl("/logout")
- .logoutSuccessUrl("/main")
- .invalidateHttpSession(true)
- );
- return http.build();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement