Symfony\Component\Form\FormConfiguration::getDefaultCsrfSecret PHP Method

getDefaultCsrfSecret() public static method

Returns the default CSRF secret
public static getDefaultCsrfSecret ( ) : string
return string
    static public function getDefaultCsrfSecret()
    {
        return self::$defaultCsrfSecret;
    }

Usage Example

Beispiel #1
0
 /**
  * Enables CSRF protection for this form.
  */
 public function enableCsrfProtection($csrfFieldName = null, $csrfSecret = null)
 {
     if (!$this->isCsrfProtected()) {
         if (null === $csrfFieldName) {
             $csrfFieldName = FormConfiguration::getDefaultCsrfFieldName();
         }
         if (null === $csrfSecret) {
             if (FormConfiguration::getDefaultCsrfSecret() !== null) {
                 $csrfSecret = FormConfiguration::getDefaultCsrfSecret();
             } else {
                 $csrfSecret = md5(__FILE__ . php_uname());
             }
         }
         $field = new HiddenField($csrfFieldName, array('property_path' => null));
         $field->setData($this->generateCsrfToken($csrfSecret));
         $this->add($field);
         $this->csrfFieldName = $csrfFieldName;
         $this->csrfSecret = $csrfSecret;
     }
 }