src/CsrfProtection.php
public function validateHeaders(WebRequest $request)
    {
        $settings = CsrfSettings::singleton();

        $headersValid = false;

        $referrerDomain = $this->getHost($request->header("Referer", ""));

        if ($referrerDomain != "") {
            if ($referrerDomain == $settings->domain){
                $headersValid = true;
            }
        } else {
            if ($this->getHost($request->header("Origin")) == $settings->domain) {
                $headersValid = true;
            }
        }

        if (!$headersValid){
            throw new CsrfViolationException();
        }
    }
public function validateHeaders(WebRequest $request)
    {
        $settings = CsrfSettings::singleton();

        $headersValid = false;

        $referrerDomain = $this->getHost($request->header("Referer", ""));

        if ($referrerDomain != "") {
            if ($referrerDomain == $settings->domain){
                $headersValid = true;
            }
        } else {
            if ($this->getHost($request->header("Origin")) == $settings->domain) {
                $headersValid = true;
            }
        }

        if (!$headersValid){
            throw new CsrfViolationException();
        }
    }
public function validateHeaders ( WebRequest $ request ) { $ settings = CsrfSettings :: singleton ( ) ; $ headersValid = false ; $ referrerDomain = $ this -> getHost ( $ request -> header ( "Referer" , "" ) ) ; if ( $ referrerDomain != "" ) { if ( $ referrerDomain == $ settings -> domain ) { $ headersValid = true ; } } else { if ( $ this -> getHost ( $ request -> header ( "Origin" ) ) == $ settings -> domain ) { $ headersValid = true ; } } if ( ! $ headersValid ) { throw new CsrfViolationException ( ) ; } }
Validates that a request headers meets CSRF requirements.

@param WebRequest $request
@throws CsrfViolationException Thrown if the request does not validate on headers.
Validates that a request headers meets CSRF requirements .