Csrf bugfixes

This commit is contained in:
Simon Sessingø
2016-11-15 08:46:14 +01:00
parent 9c413a3c53
commit 93562bd758
2 changed files with 18 additions and 1 deletions

View File

@@ -30,6 +30,23 @@ class InputCollection implements \IteratorAggregate {
return $defaultValue;
}
public function getValue($index, $defaultValue = null) {
if(count($this->data)) {
if(isset($this->data[$index])) {
return $this->data[$index]->getValue();
}
foreach($this->data as $key => $value) {
if(strtolower($index) === strtolower($key)) {
return $value->getValue();
}
}
}
return $defaultValue;
}
/**
* @param $index
* @throws \InvalidArgumentException

View File

@@ -54,7 +54,7 @@ class BaseCsrfVerifier implements IMiddleware {
if($request->getMethod() !== 'get' && !$this->skip($request)) {
$token = $request->getInput()->post->findFirst(static::POST_KEY);
$token = $request->getInput()->post->getValue(static::POST_KEY);
// If the token is not posted, check headers for valid x-csrf-token
if($token === null) {