CSRF
  • Namespace
  • Class
  • Tree

Namespaces

  • PHP
  • Riimu
    • Kit
      • CSRF
        • Source
        • Storage

Classes

  • Riimu\Kit\CSRF\CSRFHandler
  • Riimu\Kit\CSRF\NonceValidator
  • Riimu\Kit\CSRF\SingleToken
  • Riimu\Kit\CSRF\Source\HeaderSource
  • Riimu\Kit\CSRF\Source\PostSource
  • Riimu\Kit\CSRF\Storage\CookieStorage
  • Riimu\Kit\CSRF\Storage\SessionStorage

Interfaces

  • Riimu\Kit\CSRF\Source\TokenSource
  • Riimu\Kit\CSRF\Storage\TokenStorage

Exceptions

  • Riimu\Kit\CSRF\InvalidCSRFTokenException
  • Riimu\Kit\CSRF\Storage\TokenStorageException
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 
<?php

namespace Riimu\Kit\CSRF\Source;

/**
 * Looks for the token in the $_POST global array variable.
 * @author Riikka Kalliomäki <riikka.kalliomaki@gmail.com>
 * @copyright Copyright (c) 2014, Riikka Kalliomäki
 * @license http://opensource.org/licenses/mit-license.php MIT License
 */
class PostSource implements TokenSource
{
    /** @var string Name of the input field for the CSRF token */
    private $fieldName;

    /**
     * Creates a new instance of PostSource.
     * @param string $fieldName Name of the input field in $_POST
     */
    public function __construct($fieldName = 'csrf_token')
    {
        $this->fieldName = $fieldName;
    }

    public function getRequestToken()
    {
        if (!isset($_POST[$this->fieldName])) {
            return false;
        }

        return $_POST[$this->fieldName];
    }
}
CSRF API documentation generated by ApiGen