Created
February 8, 2023 13:51
-
-
Save sandeeppagatur/323cf9680320491de016a67e3b5d924f 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
@Configuration | |
public class BasicAuthSecurityConfig { | |
@Bean | |
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | |
http.csrf().disable().authorizeHttpRequests((authorize) -> authorize.requestMatchers(new AntPathRequestMatcher("/url")).hasRole(ROLE).anyRequest().authenticated()) | |
.httpBasic(Customizer.withDefaults()).exceptionHandling() | |
.authenticationEntryPoint(new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED)); | |
return http.build(); | |
} | |
spring.security.user.name= | |
spring.security.user.password= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment