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] Fix user role restriction. #35533

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

Closed
wants to merge 5 commits into from
Closed
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
Prev Previous commit
Update user role restriction test cases.
  • Loading branch information
gorshkov-ag committed Feb 13, 2020
commit 9de09f0cfbfed2af1f7ae0a63597171615a51ac3
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public function getSalt()
$token = new SwitchUserToken($impersonated, 'bar', 'provider-key', ['ROLE_USER', 'ROLE_PREVIOUS_ADMIN'], $originalToken);
$token->setUser($impersonated);
$this->assertTrue($token->isAuthenticated());
}

public function testRestrictUserRolesDoesNotDeauthenticate()
{
$impersonator = new class() implements UserInterface {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to create a separate unit for this

public function getUsername()
{
Expand Down Expand Up @@ -112,6 +115,37 @@ public function getSalt()
$token = new SwitchUserToken($impersonator, 'foo', 'provider-key', ['ROLE_ADMIN', 'ROLE_PREVIOUS_ADMIN'], $originalToken);
$token->setUser($impersonator);
$this->assertTrue($token->isAuthenticated());
}

public function testAddUserRolesDeauthenticate()
{
$impersonator = new class() implements UserInterface {
public function getUsername()
{
return 'impersonator';
}

public function getPassword()
{
return null;
}

public function eraseCredentials()
{
}

public function getRoles()
{
return ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH'];
}

public function getSalt()
{
return null;
}
};

$originalToken = new UsernamePasswordToken($impersonator, 'foo', 'provider-key', ['ROLE_USER', 'ROLE_ADMIN', 'ROLE_ALLOWED_TO_SWITCH']);

$token = new SwitchUserToken($impersonator, 'foo', 'provider-key', ['ROLE_TEST', 'ROLE_PREVIOUS_ADMIN'], $originalToken);
$token->setUser($impersonator);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.