Skip to content
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

Add "MFA Verified" check to workflowengine #39471

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7b2e541
Merge pull request #160 from nextcloud/master
mrvahedi68 Apr 25, 2023
fd70879
Merge pull request #293 from michielbdejong/master
mrvahedi68 Apr 25, 2023
dffb571
Merge pull request #312 from nextcloud/master
mrvahedi68 Jun 19, 2023
d576c96
Merge branch 'nextcloud:master' into master
mrvahedi68 Jun 26, 2023
0f0d0f1
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 9, 2023
7110544
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 9, 2023
a6d431e
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 10, 2023
6cac3c0
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 10, 2023
0f3be90
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 14, 2023
3ae0491
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 14, 2023
bae48ad
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 16, 2023
aa9b32f
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 16, 2023
037bbc2
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 18, 2023
c88cbbd
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 18, 2023
fb5841f
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 18, 2023
eefa759
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 18, 2023
7ea7f9e
add MFA check to workflow
mrvahedi68 Jul 18, 2023
6466ceb
rebuild assets
mrvahedi68 Jul 18, 2023
eccf0e1
fix lint error
mrvahedi68 Jul 18, 2023
ad38523
Merge branch 'nextcloud:master' into master
mrvahedi68 Jul 19, 2023
a0d4e45
Merge branch 'michielbdejong:master' into master
mrvahedi68 Jul 19, 2023
2977c0f
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 19, 2023
6c353f0
rebuild assets
mrvahedi68 Jul 19, 2023
9782968
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 21, 2023
c716f8e
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 24, 2023
a808def
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 26, 2023
e206efd
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 30, 2023
cdd894e
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Jul 31, 2023
6300588
Merge branch 'nextcloud:master' into master
mrvahedi68 Aug 3, 2023
7a89553
Merge branch 'michielbdejong:master' into master
mrvahedi68 Aug 3, 2023
ffd0c23
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Aug 3, 2023
ded18c9
rebuild assets
mrvahedi68 Aug 3, 2023
50984e4
Merge branch 'master' into mrv/mfa-check-final
mrvahedi68 Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'OCA\\WorkflowEngine\\Check\\RequestURL' => $baseDir . '/../lib/Check/RequestURL.php',
'OCA\\WorkflowEngine\\Check\\RequestUserAgent' => $baseDir . '/../lib/Check/RequestUserAgent.php',
'OCA\\WorkflowEngine\\Check\\TFileCheck' => $baseDir . '/../lib/Check/TFileCheck.php',
'OCA\\WorkflowEngine\\Check\\MfaVerified' => $baseDir . '/../lib/Check/MfaVerified.php',
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => $baseDir . '/../lib/Check/UserGroupMembership.php',
'OCA\\WorkflowEngine\\Command\\Index' => $baseDir . '/../lib/Command/Index.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => $baseDir . '/../lib/Controller/AWorkflowController.php',
Expand Down
1 change: 1 addition & 0 deletions apps/workflowengine/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ComposerStaticInitWorkflowEngine
'OCA\\WorkflowEngine\\Check\\RequestUserAgent' => __DIR__ . '/..' . '/../lib/Check/RequestUserAgent.php',
'OCA\\WorkflowEngine\\Check\\TFileCheck' => __DIR__ . '/..' . '/../lib/Check/TFileCheck.php',
'OCA\\WorkflowEngine\\Check\\UserGroupMembership' => __DIR__ . '/..' . '/../lib/Check/UserGroupMembership.php',
'OCA\\WorkflowEngine\\Check\\MfaVerified' => __DIR__ . '/..' . '/../lib/Check/MfaVerified.php',
'OCA\\WorkflowEngine\\Command\\Index' => __DIR__ . '/..' . '/../lib/Command/Index.php',
'OCA\\WorkflowEngine\\Controller\\AWorkflowController' => __DIR__ . '/..' . '/../lib/Controller/AWorkflowController.php',
'OCA\\WorkflowEngine\\Controller\\GlobalWorkflowsController' => __DIR__ . '/..' . '/../lib/Controller/GlobalWorkflowsController.php',
Expand Down
95 changes: 95 additions & 0 deletions apps/workflowengine/lib/Check/MfaVerified.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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 OCP\IL10N;
use OCP\WorkflowEngine\ICheck;
use OCP\ISession;

/** @psalm-suppress PropertyNotSetInConstructor */
class MfaVerified implements ICheck{

/** @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 = '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;
}
}
9 changes: 9 additions & 0 deletions apps/workflowengine/lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCA\WorkflowEngine\Check\FileName;
use OCA\WorkflowEngine\Check\FileSize;
use OCA\WorkflowEngine\Check\FileSystemTags;
use OCA\WorkflowEngine\Check\MfaVerified;
use OCA\WorkflowEngine\Check\RequestRemoteAddress;
use OCA\WorkflowEngine\Check\RequestTime;
use OCA\WorkflowEngine\Check\RequestURL;
Expand Down Expand Up @@ -486,6 +487,13 @@ public function deleteOperation($id, ScopeContext $scopeContext) {
return $result;
}

/**
* @param string $entity
* @param array $events
* @param IOperation $operation
* @return void
* @throws \UnexpectedValueException
*/
protected function validateEvents(string $entity, array $events, IOperation $operation) {
try {
/** @var IEntity $instance */
Expand Down Expand Up @@ -769,6 +777,7 @@ protected function getBuildInChecks(): array {
$this->container->query(FileName::class),
$this->container->query(FileSize::class),
$this->container->query(FileSystemTags::class),
$this->container->query(MfaVerified::class),

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IContainer::query has been marked as deprecated
$this->container->query(RequestRemoteAddress::class),
$this->container->query(RequestTime::class),
$this->container->query(RequestURL::class),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>
<!-- Only to remove the default input -->
</div>
</template>
11 changes: 11 additions & 0 deletions apps/workflowengine/src/components/Checks/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { stringValidator, validateIPv4, validateIPv6 } from '../../helpers/validators.js'
import FileMimeType from './FileMimeType.vue'
import FileSystemTag from './FileSystemTag.vue'
import MfaVerifiedValue from './MfaVerifiedValue.vue'

const stringOrRegexOperators = () => {
return [
Expand Down Expand Up @@ -100,6 +101,16 @@ const FileChecks = [
],
component: FileSystemTag,
},

{
class: 'OCA\\WorkflowEngine\\Check\\MfaVerified',
name: t('workflowengine', 'multi-factor authentication'),
operators: [
{ operator: 'is', name: t('workflowengine', 'is verified') },
{ operator: '!is', name: t('workflowengine', 'is not verified') },
],
component: MfaVerifiedValue,
},
]

export default FileChecks
4 changes: 2 additions & 2 deletions dist/workflowengine-workflowengine.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/workflowengine-workflowengine.js.map

Large diffs are not rendered by default.