Changing the default security configuration

김가빈·2023년 7월 27일
0

springsecurity

목록 보기
3/23
  • if you make spring boot project with security, default is security on
  • Because formLogin method in default springsecurity filter
  • we use security filterchain optional by overriding SequrityFilterChain

How to make Optional sequrityFilterChain

  • myAccount, myBalance, myLoans, myCards need login and notices, contact is public

  • and remove componentscan annotation
    • if you use componentscan annotation spring boot scan all component and apply sequrityFilterChain whatever it's authentication is

How to deny all request

		http.authorizeHttpRequests((requests) -> requests
				.anyRequest().denyAll())
				.formLogin(Customizer.withDefaults())
				.httpBasic(Customizer.withDefaults());
				
		return http.build();
  • and then you can see this page

Hot to accept all request

http.authorizeHttpRequests((requests) -> requests
				.anyRequest().permitAll())
				.formLogin(Customizer.withDefaults())
				.httpBasic(Customizer.withDefaults());
				
		return http.build();
profile
신입 웹개발자입니다.

0개의 댓글