回答編集履歴
2
update
answer
CHANGED
@@ -36,4 +36,6 @@
|
|
36
36
|
}
|
37
37
|
|
38
38
|
}
|
39
|
-
```
|
39
|
+
```
|
40
|
+
|
41
|
+
- [とっても簡単なCSRF対策](http://qiita.com/mpyw/items/8f8989f8575159ce95fc)
|
1
updated
answer
CHANGED
@@ -26,11 +26,11 @@
|
|
26
26
|
return hash(self::HASH_ALGO, session_id() . $salt);
|
27
27
|
}
|
28
28
|
|
29
|
-
public static function validate($token, $throw =
|
29
|
+
public static function validate($token, $throw = false)
|
30
30
|
{
|
31
31
|
$success = self::generate() === $token;
|
32
32
|
if (!$success && $throw) {
|
33
|
-
throw new \RuntimeException('CSRF validation failed.');
|
33
|
+
throw new \RuntimeException('CSRF validation failed.', 400);
|
34
34
|
}
|
35
35
|
return $success;
|
36
36
|
}
|