Google OTP 사용 샘플 소스
2차 인증 용도로 Google OTP를 사용하기 위해서 샘플 코드를 작성해 보았습니다.
https://github.com/dev4u-korea/SpringBoot-GoogleOTP
GitHub - dev4u-korea/SpringBoot-GoogleOTP
Contribute to dev4u-korea/SpringBoot-GoogleOTP development by creating an account on GitHub.
github.com
스프링 부트 기반으로 만들었습니다.
Google OTP API Usage
STEP 1. OTP ACCOUNT GENERATE
http://localhost:8080/api/otp/genAccount?userName={user name}&hostName={host name}
ex) http://localhost:8080/api/otp/genAccount?userName=dev4u&hostName=dev4u.co.kr
STEP 2. Show QR Image
http://localhost:8080/api/otp/getQrImage??userName={user name}&hostName={host name}&encodedKey={Step 1 Retrun value}
STEP 3. Auth By OTP NO
http://localhost:8080/api/otp/authOtpNo?otpNo={Google Authenticator}&encodedKey={Step 1 Retrun value}
ex) http://localhost:8080/api/otp/authOtpNo?otpNo=123456&encodedKey=LGKNF63HGZ5XANGS
"STEP 1" 을 통해서 OTP 계정을 만들고, "STEP 2" 를 통해서 얻은 QR코드를 Google Authenticator 에 등록한 후에
"STEP 3" 를 통해서 OTP 번호가 맞는지 검증하도록 만들었습니다.
샘플 소스라서 각 단계에서 필요한 정보를 파라미터로 받게 만들었는데, 데이터베이스로 관리하면 더욱 심플하겠죠.
아래 무중력고기님의 소스를 참고하여 구현한 프로젝트 입니다.
ttps://zero-gravity.tistory.com/221