-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add "MFA Verified" check to workflowengine #40235
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
michielbdejong
wants to merge
5
commits into
nextcloud:master
from
pondersource:mrv/mfa-check-rebased
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c078e9
add MFA check to workflow
mrvahedi68 02604be
make build-js-production
michielbdejong 6c821f1
apply suggested changes
mrvahedi68 52a8791
Fix copyright and authors
michielbdejong 74c1204
Update apps/workflowengine/lib/Manager.php
michielbdejong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| <?php | ||
| /** | ||
| * @copyright Copyright (c) 2023 MohammadReza Vahedi <[email protected]> | ||
| * | ||
| * @author MohammadReza Vahedi <<[email protected]> | ||
| * @author Michiel de Jong <[email protected]> | ||
| * | ||
| * @license GNU AGPL version 3 or any later version | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU Affero General Public License as | ||
| * published by the Free Software Foundation, either version 3 of the | ||
| * License, or (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Affero General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Affero General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| * | ||
| */ | ||
| namespace OCA\WorkflowEngine\Check; | ||
|
|
||
| use OCP\IL10N; | ||
| use OCP\WorkflowEngine\ICheck; | ||
| use OCP\ISession; | ||
|
|
||
| class MfaVerified implements ICheck{ | ||
| protected IL10N $l; | ||
| protected ISession $session; | ||
|
|
||
| /** | ||
| * @param IL10N $l | ||
| * @param ISession $session | ||
| */ | ||
| public function __construct(IL10N $l, ISession $session) { | ||
| $this->l = $l; | ||
| $this->session = $session; | ||
| } | ||
|
|
||
| /** | ||
| * @param string $operator | ||
| * @param string $value | ||
| * @return bool | ||
| */ | ||
| public function executeCheck($operator, $value): bool { | ||
| $mfaVerified = '0'; | ||
| if (!empty($this->session->get('globalScale.userData'))) { | ||
| $attr = $this->session->get('globalScale.userData')["userData"]; | ||
| $mfaVerified = $attr["mfaVerified"]; | ||
| } | ||
| if (!empty($this->session->get('user_saml.samlUserData'))) { | ||
| $attr = $this->session->get('user_saml.samlUserData'); | ||
| $mfaVerified = $attr["mfa_verified"][0]; | ||
| } | ||
| if (!empty($this->session->get("two_factor_auth_passed"))){ | ||
| $mfaVerified = '1'; | ||
| } | ||
|
|
||
| if ($operator === 'is') { | ||
| return $mfaVerified === '1'; // checking whether the current user is MFA-verified | ||
| } else { | ||
| return $mfaVerified !== '1'; // checking whether the current user is not MFA-verified | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param string $operator | ||
| * @param string $value | ||
| * @throws \UnexpectedValueException | ||
| */ | ||
| public function validateCheck($operator, $value): void { | ||
| if (!in_array($operator, ['is', '!is'])) { | ||
| throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); | ||
| } | ||
| } | ||
|
|
||
| public function supportedEntities(): array { | ||
| return []; | ||
| } | ||
|
|
||
| public function isAvailableForScope(int $scope): bool { | ||
| return true; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
apps/workflowengine/src/components/Checks/MfaVerifiedValue.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <template> | ||
| <div> | ||
| <!-- Only to remove the default input --> | ||
| </div> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.