Skip to content

Commit 19bbfef

Browse files
authored
Merge pull request #353 from creative-commoners/pulls/3.0/subsites-min-version
FIX Prevent incompatible versions of Subsites from installing alongside MFA 3.0
2 parents 92db931 + c767721 commit 19bbfef

39 files changed

Lines changed: 134 additions & 46 deletions

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"silverstripe/reports": "^3.7",
4040
"squizlabs/php_codesniffer": "^3.0"
4141
},
42+
"conflict": {
43+
"silverstripe/subsites": "<1.4.2"
44+
},
4245
"suggest": {
4346
"silverstripe/totp-authenticator": "Adds a method to authenticate with you phone using a time-based one-time password.",
4447
"silverstripe/webauthn-authenticator": "Adds a method to authenticate with security keys or built-in platform authenticators."

src/Authenticator/LoginForm.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\Authenticator;
46

@@ -179,7 +181,9 @@ public function startRegistration(): HTTPResponse
179181
$sessionMember = $store ? $store->getMember() : null;
180182
$loggedInMember = Member::currentUser();
181183

182-
if (($loggedInMember === null && $sessionMember === null)
184+
if (
185+
($loggedInMember === null
186+
&& $sessionMember === null)
183187
|| !$this->getSudoModeService()->check($this->controller->getSession())
184188
) {
185189
return $this->jsonResponse(
@@ -242,7 +246,9 @@ public function finishRegistration(): HTTPResponse
242246
$sessionMember = $store ? $store->getMember() : null;
243247
$loggedInMember = Member::currentUser();
244248

245-
if (($loggedInMember === null && $sessionMember === null)
249+
if (
250+
($loggedInMember === null
251+
&& $sessionMember === null)
246252
|| !$this->getSudoModeService()->check($this->controller->getSession() ?: new Session([]))
247253
) {
248254
return $this->jsonResponse(
@@ -275,7 +281,9 @@ public function finishRegistration(): HTTPResponse
275281
// required to log in though. The "mustLogin" flag is set at the beginning of the MFA process if they have at
276282
// least one method registered. They should always do that first. In that case we should assert
277283
// "isLoginComplete"
278-
if ((!$mustLogin || $this->isVerificationComplete($store))
284+
if (
285+
(!$mustLogin
286+
|| $this->isVerificationComplete($store))
279287
&& $enforcementManager->hasCompletedRegistration($sessionMember)
280288
) {
281289
$this->doPerformLogin($sessionMember);
@@ -323,8 +331,11 @@ public function startVerification(): HTTPResponse
323331
$request = $this->getRequest();
324332
$store = $this->getStore();
325333
// If we don't have a valid member we shouldn't be here, or if sudo mode is not active yet.
326-
if (!$store || !$store->getMember() ||
327-
!$this->getSudoModeService()->check($this->controller->getSession() ?: new Session([]))) {
334+
if (
335+
!$store
336+
|| !$store->getMember()
337+
|| !$this->getSudoModeService()->check($this->controller->getSession() ?: new Session([]))
338+
) {
328339
return $this->jsonResponse(['message' => 'Forbidden'], 403);
329340
}
330341

@@ -428,7 +439,8 @@ public function redirectAfterSuccessfulLogin()
428439
// This is potentially redundant logic as the member should only be logged in if they've fully registered.
429440
// They're allowed to login if they can skip - so only do assertions if they're not allowed to skip
430441
// We'll also check that they've registered the required MFA details
431-
if (!$enforcementManager->canSkipMFA($member)
442+
if (
443+
!$enforcementManager->canSkipMFA($member)
432444
&& !$enforcementManager->hasCompletedRegistration($member)
433445
) {
434446
$member->logOut();

src/Authenticator/MemberAuthenticator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace SilverStripe\MFA\Authenticator;
34

45
use Controller;

src/BackupCode/Method.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\BackupCode;
46

src/BackupCode/RegisterHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\BackupCode;
46

src/BackupCode/VerifyHandler.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\BackupCode;
46

src/Controller/AdminRegistrationController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\Controller;
46

@@ -185,7 +187,8 @@ public function setDefaultRegisteredMethod(): HTTPResponse
185187
{
186188
$request = $this->getRequest();
187189
// Ensure CSRF and sudo-mode protection
188-
if (!SecurityToken::inst()->checkRequest($request)
190+
if (
191+
!SecurityToken::inst()->checkRequest($request)
189192
|| !$this->getSudoModeService()->check($this->getSession())
190193
) {
191194
return $this->jsonResponse(

src/Exception/InvalidMethodException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace SilverStripe\MFA\Exception;
34

45
use LogicException;

src/Extension/AccountReset/AccountResetHandler.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace SilverStripe\MFA\Extension\AccountReset;
54

65
use Member;

src/Extension/AccountReset/MFAResetExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace SilverStripe\MFA\Extension\AccountReset;
46

0 commit comments

Comments
 (0)