1
0
forked from baron/baron-sso
Files
baron-sso/docs/complete-password-reset-refactor.md
2026-01-27 22:58:49 +09:00

2.8 KiB

+# CompletePasswordReset 리팩터 전략 (IDP 추상화 전환) 2 + 3 +## 현 상황 4 +- AuthHandler.CompletePasswordReset가 Descope 전용 흐름을 포함: 5 + - Descope 비밀번호 정책 검사 6 + - Descope Management API SetActivePassword 호출 7 + - IDP Provider 추상화는 마지막에만 호출 8 +- 목표: IDP Provider 기반으로 통일하고, Descope 정책 검사는 Descope 선택 시에만 적용. 9 + 10 +## 단계별 패치 전략 (쿼터/앵커 분할) 11 +1) 전역 준비: 함수 시작부에 providerName := "unknown"; if h.IdpProvider != nil { providerName = h.I dpProvider.Name() } 이미 추가됨. 12 +2) 비밀번호 정책 블록 분리 13 + - 현재 Descope 정책 블록을 그대로 두고, 먼저 작은 단위로 변환: 14 + - 블록 상단 주석을 // Validate password complexity (Descope only)로 교체. 15 + - 블록 전체를 if providerName == "Descope" && h.DescopeClient != nil { ... }로 감싸기. 16 + - 특수문자 [\W_] 등 이스케이프가 많으므로, 치환 시 작은 범위의 문장/줄 단위로 교체. 17 +3) Descope SetActivePassword 제거 및 공통 UpdateUserPassword 호출 18 + - Attempting to update password via Descope Auth API 주석부터 Descope 전용 호출을 삭제. 19 + - 그 위치에 공통 경로 추가: 20 + go 21 + ale.Log(..., slog.String("idp", providerName)) 22 + if h.IdpProvider == nil { ... 500 ... } 23 + if err := h.IdpProvider.UpdateUserPassword(...); err != nil { ... 500 ... } 24 + 25 +4) 앵커 선택 26 + - 삭제 앵커: "Attempting to update password via Descope Auth API" 줄과 그 아래 Descope 클 라이언트 nil 체 크 ~ SetActivePassword 오류 처리 블록. 27 + - 유지 앵커: 상단의 Redis 토큰 삭제/성공 응답 부분은 그대로. 28 +5) 검증 29 + - gofmt -w backend/internal/handler/auth_handler.go 30 + - rg "Descope Client is nil" backend/internal/handler/auth_handler.go → 없어야 함. 31 + - rg "UpdateUserPassword" backend/internal/handler/auth_handler.go → 공통 경로만 남는지 확인. 32 + 33 +## 테스트 계획 34 +- 단위 테스트: IDP Provider를 모킹해 CompletePasswordReset를 직접 호출하는 테스트 추가 권장 (추후 작업). 현재는 수동 검증 예정. 35 +- 수동 확인: 빌드(go test ./... 불가하면 최소 gofmt 및 go test ./internal/service -run TestUpdateUserPassw ord 재확인). 36 + 37 +## 적용 순서 (패치 실행용) 38 +1) 정책 블록 if 래핑 + 주석 변경. 39 +2) Descope API 호출 블록 제거 후 공통 IDP 호출 삽입. 40 +3) gofmt 및 로그/앵커 검사.