summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Simonin <vincent.simonin@stockway.pro>2012-09-07 17:02:54 +0200
committerSebastiaan Stok <s.stok@rollerscapes.net>2012-11-15 16:42:01 +0100
commit4ca21e13afc5abe62fc0e72f89b25c250b1036b3 (patch)
treed2c9024c199dc986b08e0f33376867a82c75c775
parent1c0e9255855cec9605df0f21ee4f7906b2b00276 (diff)
downloadsymfony-security-4ca21e13afc5abe62fc0e72f89b25c250b1036b3.zip
symfony-security-4ca21e13afc5abe62fc0e72f89b25c250b1036b3.tar.gz
symfony-security-4ca21e13afc5abe62fc0e72f89b25c250b1036b3.tar.bz2
[Security] Fixed digest authentication
Digest authentication fail if digest parameters contains `=` character or `, ` string.
-rw-r--r--Http/Firewall/DigestAuthenticationListener.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/Http/Firewall/DigestAuthenticationListener.php b/Http/Firewall/DigestAuthenticationListener.php
index 5c529da..8567a00 100644
--- a/Http/Firewall/DigestAuthenticationListener.php
+++ b/Http/Firewall/DigestAuthenticationListener.php
@@ -141,11 +141,12 @@ class DigestData
public function __construct($header)
{
$this->header = $header;
- $parts = preg_split('/, /', $header);
+ preg_match_all('/(\w+)=("([^"]+)"|([^\s,$]+))/', $header, $matches, PREG_SET_ORDER);
$this->elements = array();
- foreach ($parts as $part) {
- list($key, $value) = explode('=', $part);
- $this->elements[$key] = '"' === $value[0] ? substr($value, 1, -1) : $value;
+ foreach ($matches as $match) {
+ if (isset($match[1]) && isset($match[3])) {
+ $this->elements[$match[1]] = isset($match[4]) ? $match[4] : $match[3];
+ }
}
}
@@ -188,7 +189,7 @@ class DigestData
$this->nonceExpiryTime = $nonceTokens[0];
if (md5($this->nonceExpiryTime.':'.$entryPointKey) !== $nonceTokens[1]) {
- new BadCredentialsException(sprintf('Nonce token compromised "%s".', $nonceAsPlainText));
+ throw new BadCredentialsException(sprintf('Nonce token compromised "%s".', $nonceAsPlainText));
}
}