forked from michielbdejong/server
-
Notifications
You must be signed in to change notification settings - Fork 1
Add mfa verified check to workflow engine. solved #26 #240
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
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ad4d43c
Add mfa verified check to workflow engine. solved #26
mrvahedi68 9bbd178
finalized execution tests
mrvahedi68 ba18a5c
format code
mrvahedi68 8e7a3fc
bugfix inside mfa check
mrvahedi68 c22401d
Merge branch 'master' into mrg/master
mrvahedi68 fb19c17
Update devcontainer.json
mrvahedi68 3a3b06b
rollback devcontainer changes
mrvahedi68 75d5ccf
add js build files
mrvahedi68 7442c71
fix psalm warnings
mrvahedi68 754959a
fix psalm warnings
mrvahedi68 16fc4bb
resolve review threads
mrvahedi68 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,101 @@ | ||
| <?php | ||
| /** | ||
| * @copyright Copyright (c) 2016 Joas Schilling <[email protected]> | ||
| * | ||
| * @author Arthur Schiwon <[email protected]> | ||
| * @author Christoph Wurst <[email protected]> | ||
| * @author Joas Schilling <[email protected]> | ||
| * @author Julius Härtl <[email protected]> | ||
| * @author Richard Steinmetz <[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 OCA\WorkflowEngine\Entity\File; | ||
| use OCP\Files\Cache\ICache; | ||
| use OCP\IL10N; | ||
| use OCP\WorkflowEngine\ICheck; | ||
| use OCP\WorkflowEngine\IFileCheck; | ||
| use OC\Files\Storage\Wrapper\Wrapper; | ||
| use OCP\ISession; | ||
|
|
||
| /** @psalm-suppress PropertyNotSetInConstructor */ | ||
| class MfaVerified implements ICheck, IFileCheck { | ||
|
||
| use TFileCheck; | ||
|
|
||
| /** @var IL10N */ | ||
| protected $l; | ||
|
|
||
| /** @var ISession */ | ||
| protected $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 = $this->session->get('user_saml.samlUserData')["mfa_verified"][0]; | ||
| if (strtolower($value) == 'true') { | ||
| 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'])) { | ||
| throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1); | ||
| } | ||
|
|
||
| if (!in_array($value, ['true', 'false'])) { | ||
| throw new \UnexpectedValueException($this->l->t('The given value is invalid, must be one of ("true", "false")'), 1); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @param string $path | ||
| * @return string | ||
| */ | ||
| protected function dirname(string $path): string { | ||
| $dir = dirname($path); | ||
| return $dir === '.' ? '' : $dir; | ||
| } | ||
|
|
||
| public function supportedEntities(): array { | ||
| return [ File::class ]; | ||
| } | ||
|
|
||
| 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
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.