2015년 8월 5일 수요일

[Grails] 리캡차(reCaptcha)


리캡차(reCaptcha)


리캡차(reCAPTCHA)는 웹사이트에 접근을 시도하는 봇을 차단하기 위해 설치되어 있는 이미지에 표시된 문자를 입력해 봇이 이나라는 걸 증명하는 기능이다. 

기존 캡차는 웹 보안성을 높여주긴 하지만, 사용자는 대략 10초간 귀찮음을 무릅쓰고 캡차에서 제시하는 글자를 인식하고 입력해야 한다.

또한, 봇은 해마다 진화하고 있어서, 기존에는 불가능했던 캡차 문자 인식도 돌파해내고 있다.

리캡차는 이에 대한 불편함을 줄이기 위해서 만들어졌다.

리캡차는 "컴퓨터가 아직 비슷하게 생긴 그림을 정교하게 구분할 수 없다” 는 원리를 이용하여 봇을 걸러낸다.

기존 캡처처럼 문자 입력이 필요하지 않아 문자 입력이 까다로운 모바일 단말에서도 손쉽게 봇이 아니라는 걸 증명할 수 있다.










활용예제


구글리캡차 에서 "Get reCAPTCHA" 클릭 후,






등록하면 publicKey 와 privateKey 를 받을 수 있다.



---------------------------------------------------------------------------------------------


conf/BuildConfig.groovy



plugins {


  compile ':recaptcha:1.2.0'


}


---------------------------------------------------------------------------------------------


conf/config.groovy


recaptcha {

        // These keys are generated by the ReCaptcha service

        publicKey = "user public key"
        privateKey = "user private key"

        // Include the noscript tags in the generated captcha

        includeNoScript = true

        // Include the required script tag with the generated captcha

        includeScript = true

        // Set to false to disable the display of captcha

        enabled = true
}

mailhide {


        // Generated by the Mailhide service

        publicKey = "user public key"
        privateKey = "user private key"

}


---------------------------------------------------------------------------------------------

views/domain/create.gsp



<div>

        <label for="captcha">체크박스를 선택해주세요.</label>

        <recaptcha:ifEnabled>

                <recaptcha:recaptcha theme="dark" />
        </recaptcha:ifEnabled>
</div>

---------------------------------------------------------------------------------------------


controllers/DomainController.groovy



RecaptchaService recaptchaService


def save = {


  boolean recaptchaOK = 
recaptchaService.verifyAnswer (session, request.getRemoteAddr(), params)

  if(recaptchaOK){

     // 봇이 아닌 경우, 처리할 내용
  }
}



댓글 없음:

댓글 쓰기