PHP Класс ParagonIE\AntiCSRF\AntiCSRF

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . ****************************************************************************** The MIT License (MIT) Copyright (c) 2015 Paragon Initiative Enterprises Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. If you would like to use this library under different terms, please contact Resonant Core to inquire about a license exemption.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$post Injected; defaults to references to superglobals
$server
$session

Защищенные свойства (Protected)

Свойство Тип Описание
$expire_old boolean
$formIndex string
$formToken string
$hashAlgo string
$hmac_ip boolean
$recycle_after integer
$sessionIndex string

Открытые методы

Метод Описание
__construct ( array &$post = null, array &$session = null, array &$server = null ) NULL is not a valid array type
getFormIndex ( ) : string
getFormToken ( ) : string
getSessionIndex ( ) : string
getTokenArray ( string $lockTo = '' ) : array Retrieve a token array for unit testing endpoints
insertToken ( string $lockTo = '', boolean $echo = true ) : string Insert a CSRF token to a form
reconfigure ( array $options = [] ) : self Use this to change the configuration settings.
validateRequest ( ) : boolean Validate a request based on $this->session and $this->post data

Защищенные методы

Метод Описание
generateToken ( string $lockTo ) : array Generate, store, and return the index and token
noHTML ( string $untrusted ) : string Wrapper for htmlentities()
recycleTokens ( ) : self Enforce an upper limit on the number of tokens stored in session state by removing the oldest tokens first.

Описание методов

__construct() публичный Метод

NULL is not a valid array type
public __construct ( array &$post = null, array &$session = null, array &$server = null )
$post array
$session array
$server array

generateToken() защищенный Метод

Generate, store, and return the index and token
protected generateToken ( string $lockTo ) : array
$lockTo string What URI endpoint this is valid for
Результат array

getFormIndex() публичный Метод

public getFormIndex ( ) : string
Результат string

getFormToken() публичный Метод

public getFormToken ( ) : string
Результат string

getSessionIndex() публичный Метод

public getSessionIndex ( ) : string
Результат string

getTokenArray() публичный Метод

Retrieve a token array for unit testing endpoints
public getTokenArray ( string $lockTo = '' ) : array
$lockTo string
Результат array

insertToken() публичный Метод

Insert a CSRF token to a form
public insertToken ( string $lockTo = '', boolean $echo = true ) : string
$lockTo string This CSRF token is only valid for this HTTP request endpoint
$echo boolean if true, echo instead of returning
Результат string

noHTML() защищенный статический Метод

Wrapper for htmlentities()
protected static noHTML ( string $untrusted ) : string
$untrusted string
Результат string

reconfigure() публичный Метод

Only use this if you know what you are doing.
public reconfigure ( array $options = [] ) : self
$options array
Результат self

recycleTokens() защищенный Метод

Enforce an upper limit on the number of tokens stored in session state by removing the oldest tokens first.
protected recycleTokens ( ) : self
Результат self

validateRequest() публичный Метод

Validate a request based on $this->session and $this->post data
public validateRequest ( ) : boolean
Результат boolean

Описание свойств

$expire_old защищенное свойство

protected bool $expire_old
Результат boolean

$formIndex защищенное свойство

protected string $formIndex
Результат string

$formToken защищенное свойство

protected string $formToken
Результат string

$hashAlgo защищенное свойство

protected string $hashAlgo
Результат string

$hmac_ip защищенное свойство

protected bool $hmac_ip
Результат boolean

$post публичное свойство

Injected; defaults to references to superglobals
public $post

$recycle_after защищенное свойство

protected int $recycle_after
Результат integer

$server публичное свойство

public $server

$session публичное свойство

public $session

$sessionIndex защищенное свойство

protected string $sessionIndex
Результат string