Skip to content

Commit

Permalink
Use exact match to compare whitelisted domains
Browse files Browse the repository at this point in the history
  • Loading branch information
fguillot committed Dec 1, 2017
1 parent 2c283fc commit 945e066
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Auth/GoogleAuthProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ public function isAccountCreationAllowed(array $profile)
*/
public function validateDomainRestriction(array $profile, $domains)
{
foreach (explode(',', $domains) as $domain) {
$domain = trim($domain);
if (strpos($profile['email'], '@') === false) {
return false;
}

if (strpos($profile['email'], '@') === false) {
return false;
}
list(, $hostname) = explode('@', $profile['email']);
$hostname = trim($hostname);

list(, $hostname) = explode('@', $profile['email']);
if (strpos($hostname, $domain) === 0) {
foreach (explode(',', $domains) as $domain) {
if ($hostname === trim($domain)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '1.0.5';
return '1.0.6';
}

public function getPluginHomepage()
Expand Down
1 change: 1 addition & 0 deletions Test/GoogleAuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function testEmailRestrictions()
$this->assertTrue($provider->isAccountCreationAllowed(array('email' => '[email protected]')));
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => '[email protected]')));
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => '[email protected]')));
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => '[email protected]')));

$this->assertTrue($this->container['configModel']->save(array('google_account_creation' => '1', 'google_email_domains' => 'example.org, example.com')));
$this->container['memoryCache']->flush();
Expand Down

0 comments on commit 945e066

Please sign in to comment.