Created
November 29, 2023 09:25
-
-
Save vladdedita/8cce068d8ab107b684adc83262bf7cc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean | |
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | |
http | |
.authorizeHttpRequests((authz) -> authz | |
.requestMatchers("/login", "/register") | |
.permitAll() // Login and register endpoints are accessible to allf | |
.anyRequest() | |
.authenticated() // Any other requests require authentication | |
) | |
.httpBasic(withDefaults()); // Enables basic authentication with default settings | |
return http.build(); // Builds and returns the security filter chain | |
} | |
@Bean | |
public WebSecurityCustomizer webSecurityCustomizer() { | |
return (web) -> web.ignoring() | |
.requestMatchers("/css/**", "/js/**", "/images/**"); // Ignores requests to static resources | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment