반응형

내 github 에 있는 프로젝트들중 예전에 만들었던 건데 내용좀 다시 볼겸 수정을 하고 있었다. 

사실, 간단한거 빼고는 잘 작동을 안하는것 같다.

 

그래서 이번에 라이브러리 버전 업데이트 좀 할겸 소스를 수정을 했다.

 

Spring Boot 버전도 최신 버전으로 수정을 하고 Security 버전도 수정을 했다. 그리고 나서 간단히 로그인을 해보려고 하니 다음과 같은 에러가 발생했다.

 

There is no PasswordEncoder mapped for the id "null"

 

음.. ?

찾아보니 Spring Security 버전이 올라가면서 PasswordEncoder가 변경되면서 발생한 에러였다. 

The general format for a password is:

{id}encodedPassword

Such that id is an identifier used to look up which PasswordEncoder should be used and encodedPassword is the original encoded password for the selected PasswordEncoder. The id must be at the beginning of the password, start with { and end with }. If the id cannot be found, the id will be null. For example, the following might be a list of passwords encoded using different id. All of the original passwords are "password".

(출처 : https://spring.io/blog/2017/11/01/spring-security-5-0-0-rc1-released)

 

그래서 방법은 다음과 같다. (내가 가지고 있는 소스 기준이다. )

 

1. DB 에 password 값을 변경한다. 

 

생성되는 password 값에 "{noop}" 을 붙여서 저장을 한다. 

 

2. UserDetail 서비스를 새로 구현 하였다면 password 부분을 수정해준다. 

    public CustomUserDetails(Account account) {
        this.username = account.getLoginId();
        this.password = "{noop}" + account.getPassword();
    }

 

1번이나 2번이나 결과적으로 password 값 앞에 "{id}" 값을 넣어주면 된다는 의미이다.

 

728x90
반응형

+ Recent posts