CI 묻고 답하기

제목 csrf protection 처리는 언제 어데서 누가 해주나효?
글쓴이 세콩 작성시각 2012/02/29 15:01:30
댓글 : 2 추천 : 0 스크랩 : 0 조회수 : 17803   RSS
어제 처음 사용해보았습니닷 ;;

저는 form 에서 post 하는 csrf 히든 value를

컨트롤러에서 받아 인증 작업을 직접해줘야하는건줄 알았는데

아니였습니다.. 두둥!!


테스트해보니 던져주는 값을 알아서 확인하고 인증되면 처리하고,

인증되지 않은경우 자동으로 거부하던데


Input 클래스에서 일까요??


ps. 소스를 까보기전 선질문하는 센스!! -_-;;
 다음글 이중 폴더 안에 컨트롤러를 넣으려고 합니다. (4)
 이전글 사용자 포럼과 관련된 질물 (2)

댓글

세콩 / 2012/02/29 15:11:32 / 추천 0
오래 걸릴줄 알았는데 금방찾았네효 휴휴

자답입니닷

input 클래스에서 CSRF_Protection을 먼저 체크합니닷
// CSRF Protection check
if ($this->_enable_csrf == TRUE)
{
 $this->security->csrf_verify();
}

그다음 security 클래스의 메소드인 csrf_verify() 메서드가 수행!!
 public function csrf_verify()
 {
  // If no POST data exists we will set the CSRF cookie
  if (count($_POST) == 0)
  {
   return $this->csrf_set_cookie();
  }

  // Do the tokens exist in both the _POST and _COOKIE arrays?
  if ( ! isset($_POST[$this->_csrf_token_name]) OR
    ! isset($_COOKIE[$this->_csrf_cookie_name]))
  {
   $this->csrf_show_error();
  }

  // Do the tokens match?
  if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name])
  {
   $this->csrf_show_error();
  }

  // We kill this since we're done and we don't want to
  // polute the _POST array
  unset($_POST[$this->_csrf_token_name]);

  // Nothing should last forever
  unset($_COOKIE[$this->_csrf_cookie_name]);
  $this->_csrf_set_hash();
  $this->csrf_set_cookie();

  log_message('debug', "CSRF token verified ");

  return $this;
 }

이상입니닷.. -_-;;
한대승(불의회상) / 2012/02/29 17:02:49 / 추천 0
좋은 질문과 답변 감사 드립니다. ^^

수고 하셨습니다. 세콩님