Skip to content

Commit

Permalink
AppAPI: allowed to bypass Two-Factor
Browse files Browse the repository at this point in the history
  • Loading branch information
bigcat88 committed Dec 25, 2023
1 parent 17cb5da commit f096201
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/Middleware/TwoFactorMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ public function beforeController($controller, $methodName) {
if ($this->userSession->isLoggedIn()) {
$user = $this->userSession->getUser();

if ($this->session->exists('app_password') || $this->twoFactorManager->isTwoFactorAuthenticated($user)) {
if ($this->session->exists('app_password')
|| $this->session->exists('app_api')
|| $this->twoFactorManager->isTwoFactorAuthenticated($user)) {

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OC\Authentication\TwoFactorAuth\Manager::isTwoFactorAuthenticated cannot be null, possibly null value provided

$this->checkTwoFactor($controller, $methodName, $user);
} elseif ($controller instanceof TwoFactorChallengeController) {
// Allow access to the two-factor controllers only if two-factor authentication
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Authentication/TwoFactorAuth/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function needsSecondFactor(IUser $user = null): bool {
}

// If we are authenticated using an app password skip all this
if ($this->session->exists('app_password')) {
if ($this->session->exists('app_password') || $this->session->get('app_api') === true) {
return false;
}

Expand Down

0 comments on commit f096201

Please sign in to comment.