There is no PasswordEncoder mapped for the id "null"

KimHyunKi·2020년 8월 8일
0

Error

목록 보기
3/5

Spring Security로 로그인/회원가입 기능 구현 중 비밀번호를 다르게 입력해서 로그인 할 때 메세지가 뜨도록 설정했는데 어느 날 시도했는데 오류가 발생했다.

해결법 : 스프링 시큐리티 버전이 5.0 version 이후 버전은 비밀번호를 입력할때 아이디 값과 같이 입력이 되야한다고 하는거 같다. 앞에 {id} 값이나 {noop}값을 추가해줘야 한다.

UserDetalis Interface를 구현한 class를 수정해준다.

@SuppressWarnings("serial")
public class UserDetailsImp implements UserDetails{
	
	private String ID;
	private String Password;
	private String Name;
	private String Authority;
	private boolean Enabled;
	
//	계정이 갖고 있는 권한을 리턴
	@Override 
	public Collection<? extends GrantedAuthority> getAuthorities() {
		ArrayList<GrantedAuthority> auth = new ArrayList<GrantedAuthority>();
		auth.add(new SimpleGrantedAuthority(Authority));
		return auth;
	}

	@Override
	public String getPassword() {
		return "{noop}"+Password; <<< {noop}추가
	}
profile
Developer

0개의 댓글