-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(build.gradle): 비밀번호 암호화 알고리즘을 위한 의존성 추가 * feat(PasswordEncoderConfig): 비밀번호 암호화 알고리즘 스프링 Bean 등록 * feat(PasswordConverter): `@Converter`를 사용한 비밀번호 암호화 로직 추가 * test(AttendeeEncryptedPasswordFixture): 암호화된 비밀번호 Fixture 추가 * feat(AttendeeService): 비밀번호 암호화 추가로 인한 주요 Service 로직 수정 * refactor(AttendeePassword): 직관적인 메서드명으로 변경 * refactor(AttendeePassword): 불필요한 어노테이션 삭제 * test(AttendeeEncryptedPasswordFixture): 리플렉션 설정 변경 후 패키지 이 * refactor(AttendeePassword): Converter 문제 발생으로 인한 암호화 로직 리팩토링 * refactor(AttendeePassword): 생성자 내 PasswordEncoder 제거
- Loading branch information
Showing
18 changed files
with
211 additions
and
102 deletions.
There are no files selected for viewing
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
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/kr/momo/config/PasswordEncoderConfig.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kr.momo.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
@Configuration | ||
public class PasswordEncoderConfig { | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8(); | ||
} | ||
} |
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
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
25 changes: 25 additions & 0 deletions
25
backend/src/main/java/kr/momo/domain/attendee/AttendeeRawPassword.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package kr.momo.domain.attendee; | ||
|
||
import java.util.regex.Pattern; | ||
import kr.momo.exception.MomoException; | ||
import kr.momo.exception.code.AttendeeErrorCode; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
public record AttendeeRawPassword(String password) { | ||
|
||
private static final Pattern PASSWORD_PATTERN = Pattern.compile("^\\d{4}+$"); | ||
|
||
public AttendeeRawPassword { | ||
validatePassword(password); | ||
} | ||
|
||
private void validatePassword(String password) { | ||
if (password == null || !PASSWORD_PATTERN.matcher(password).matches()) { | ||
throw new MomoException(AttendeeErrorCode.INVALID_PASSWORD_FORMAT); | ||
} | ||
} | ||
|
||
public AttendeePassword encodePassword(PasswordEncoder passwordEncoder) { | ||
return new AttendeePassword(passwordEncoder.encode(password)); | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.