Spring Security 기반 인증/인가, JWT 발급/검증, 로그인 감사(audit), 계정 잠금, 비밀번호 재설정 토큰을 제공하는 모듈이다. JPA/JDBC 영속성 구현과 REST 컨트롤러를 포함하며, 스타터에서 자동 구성된다.

3.1 시작하기

3.1.1 의존성 추가

studio-platform-starter-security 를 의존성에 추가하면 쉽게 사용할 수 있다. JPA 을 사용하는 경우 의존성을 spring-boot-starter-data-jpa 로 변경한다. studio-platform-security 는 기본적으로 studio-platform-user 구현을 사용하여 spring-boot-starter-security 를 커스터마이징 하고 있다.

dependencies {
    implementation("studio.one.starter:studio-platform-starter")
    implementation("studio.one.starter:studio-platform-starter-user")
    **implementation("studio.one.starter:studio-platform-starter-security")**
    implementation("org.springframework.boot:spring-boot-starter-validation") 
    implementation("org.springframework.boot:spring-boot-starter-aop")
    implementation("org.springframework.boot:spring-boot-starter-web")  
    implementation("org.springframework.boot:spring-boot-starter-data-jdbc")  
    implementation("org.springframework.boot:spring-boot-starter-security")
}

3.1.2 활성화 하기

  studio:
	  security:
	    enabled: true

다음 모듈들이 자동 활성화 된다. (스프링 시큐리티 표준에 구현)

3.2 Security 설정 가이드

Security 설정은 인증/인가 및 보안 정책(JWT, Form Login, Logout, CORS, PasswordEncoder, Permit)을 설정 기반으로 제어할 수 있게 한다. 환경(DEV/STG/PROD) 또는 고객사별로 인증 방식과 정책을 바꿔야 할 때코드 변경을 최소화하는 것이 목적이다. application.yml 에 저장된studio.security.* 설정은 SecurityProperties 로 바인딩된다.

3.2.1 PasswordEncoder 설정(password-encoder.*)

비밀번호 알고리즘 선택 및 알고리즘 별 파라미터를 제공한다. 기본 알고리즘은 BCRYPT이다. 이 설정을 통하여 사용자 도메인의 ApplicationUserService 는 비밀번호를 처리를 설정에 따라 자동 생성된 PasswrodEncoder 을 사용하여 처리하게 된다.

Key Default 설명
password-encoder.algorithm BCRYPT 사용 알고리즘 (BCRYPT, PBKDF2, SHA256, CUSTOM)
password-encoder.secret null 공통/선택 옵션(알고리즘별 사용)
password-encoder.iterations null PBKDF2 반복 횟수(양수)
password-encoder.hash-width null PBKDF2 해시 폭(양수)
password-encoder.bcrypt-strength null BCrypt 강도(최소 4, 일반적으로 10 권장)
password-encoder.pbkdf2-algo PBKDF2WithHmacSHA256 PBKDF2 HMAC 알고리즘
password-encoder.custom null 확장 포인트(커스텀 인코더 설정용)
studio:
	security:
	  enabled: true 
		password-encoder:
			algorithm: BCRYPT
			bcrypt-strength: 10