Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Security Fixes #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
3 commits merged into from
Feb 27, 2011
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Security] Copy token attributes when auth providers create a new tok…
…en from another

PreAuthenticatedAuthenticationProvider and UserAuthenticationProvider tend to copy a token instead of modifying it during their authenticate() methods, which is probably a good idea if the token might be immutable. Ensure that the token's attributes get copied along with everything else.
  • Loading branch information
jmikola committed Feb 23, 2011
commit 5113886f34b4d6224a28ebefb5e71515e291d1a9
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public function authenticate(TokenInterface $token)

$this->accountChecker->checkPostAuth($user);

return new PreAuthenticatedToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles());
$authenticatedToken = new PreAuthenticatedToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles());
$authenticatedToken->setAttributes($token->getAttributes());

return $authenticatedToken;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function authenticate(TokenInterface $token)
$this->checkAuthentication($user, $token);
$this->accountChecker->checkPostAuth($user);

return new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles());
$authenticatedToken = new UsernamePasswordToken($user, $token->getCredentials(), $this->providerKey, $user->getRoles());
$authenticatedToken->setAttributes($token->getAttributes());

return $authenticatedToken;
} catch (UsernameNotFoundException $notFound) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials', 0, $notFound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function testAuthenticate()
$this->assertEquals('pass', $token->getCredentials());
$this->assertEquals('key', $token->getProviderKey());
$this->assertEquals(array(), $token->getRoles());
$this->assertEquals(array('foo' => 'bar'), $token->getAttributes(), '->authenticate() copies token attributes');
$this->assertSame($user, $token->getUser());
}

Expand Down Expand Up @@ -103,6 +104,8 @@ protected function getSupportedToken($user = false, $credentials = false)
->will($this->returnValue('key'))
;

$token->setAttributes(array('foo' => 'bar'));

return $token;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public function testAuthenticate()
$this->assertSame($user, $authToken->getUser());
$this->assertEquals(array(new Role('ROLE_FOO')), $authToken->getRoles());
$this->assertEquals('foo', $authToken->getCredentials());
$this->assertEquals(array('foo' => 'bar'), $authToken->getAttributes(), '->authenticate() copies token attributes');
}

protected function getSupportedToken()
Expand All @@ -168,6 +169,8 @@ protected function getSupportedToken()
->will($this->returnValue('key'))
;

$mock->setAttributes(array('foo' => 'bar'));

return $mock;
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.