Skip to content

Commit 945e066

Browse files
committed
Use exact match to compare whitelisted domains
1 parent 2c283fc commit 945e066

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

Auth/GoogleAuthProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ public function isAccountCreationAllowed(array $profile)
221221
*/
222222
public function validateDomainRestriction(array $profile, $domains)
223223
{
224-
foreach (explode(',', $domains) as $domain) {
225-
$domain = trim($domain);
224+
if (strpos($profile['email'], '@') === false) {
225+
return false;
226+
}
226227

227-
if (strpos($profile['email'], '@') === false) {
228-
return false;
229-
}
228+
list(, $hostname) = explode('@', $profile['email']);
229+
$hostname = trim($hostname);
230230

231-
list(, $hostname) = explode('@', $profile['email']);
232-
if (strpos($hostname, $domain) === 0) {
231+
foreach (explode(',', $domains) as $domain) {
232+
if ($hostname === trim($domain)) {
233233
return true;
234234
}
235235
}

Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getPluginAuthor()
7171

7272
public function getPluginVersion()
7373
{
74-
return '1.0.5';
74+
return '1.0.6';
7575
}
7676

7777
public function getPluginHomepage()

Test/GoogleAuthTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function testEmailRestrictions()
4040
$this->assertTrue($provider->isAccountCreationAllowed(array('email' => 'me@mydomain.tld')));
4141
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => 'me@my-other-domain.tld')));
4242
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => 'test+mydomain.tld+@example.org')));
43+
$this->assertFalse($provider->isAccountCreationAllowed(array('email' => 'test@mydomain.tld.example.org')));
4344

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

0 commit comments

Comments
 (0)