기존에 webSecurityConfigurerAdapter가 굉장히 많은 역할을 해줬다는게 좀 느껴지네요.
Field authenticationManager in kr.co.kshproject.webDemo.interfaces.loginController required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.
에러가나는데 지금 아래와 같이 변경해서 작업중인데 에러가 나는군요 ㅠ webSecurityConfigurerAdapter가 그립네요 ㅎ ㅠ 퇴근하고 공부하는거라 많이 시간이 안나오네요 이번주 주말까지해서 회원가입시 SHA 256이용해서 비밀번호 변경하고 session을 이용해서 웹페이지마다 관리자가 이용하는 페이지 고객이 이용하는 페이지로 만들겁니다.
package kr.co.kshproject.webDemo.Common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.authentication.configuration.GlobalAuthenticationConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Autowired
@Lazy
private AuthenticationProvider myAuthenticationProvider;
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers().permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/Main")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.permitAll();
http.authenticationProvider(myAuthenticationProvider);
return http.build();
}
@Configuration
protected static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
@Autowired
private AuthenticationProvider myAuthenticationProvider;
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(myAuthenticationProvider);
}
}
@Bean
public AuthenticationProvider myAuthenticationProvider() {
return new MyAuthenticationProvider();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
'웹 > Spring vue 웹 개발' 카테고리의 다른 글
spring vue 로그인 완료 (0) | 2023.05.21 |
---|---|
spring vue 로그인 03 -AuthenticationManager (0) | 2023.05.20 |
spring vue 로그인 01 (0) | 2023.05.17 |
spring vue 연동 상품 관리,게시판 관리 어드민 페이지 완료 (0) | 2023.05.16 |
spring vue 연동 상품 관리,게시판 관리 어드민 페이지 05 (1) | 2023.05.15 |