diff --git a/.github/workflows/lint-eslint.yml b/.github/workflows/lint-eslint.yml deleted file mode 100644 index 34f766b..0000000 --- a/.github/workflows/lint-eslint.yml +++ /dev/null @@ -1,47 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later - -name: Lint - -on: - pull_request: - push: - branches: - - main - - master - - stable* - -jobs: - lint: - runs-on: ubuntu-latest - - name: eslint - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.2 - id: versions - with: - fallbackNode: '^12' - fallbackNpm: '^6' - - - name: Set up node $ - uses: actions/setup-node@v3 - with: - node-version: $ - - - name: Set up npm $ - run: npm i -g npm@"$" - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run lint diff --git a/.github/workflows/lint-php-cs.yml b/.github/workflows/lint-php-cs.yml deleted file mode 100644 index 55f08f3..0000000 --- a/.github/workflows/lint-php-cs.yml +++ /dev/null @@ -1,38 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later - -name: Lint - -on: - pull_request: - push: - branches: - - master - - stable* - -jobs: - lint: - runs-on: ubuntu-latest - - name: php-cs - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: "7.4" - coverage: none - - - name: Install dependencies - run: composer i - - - name: Lint - run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 ) - diff --git a/.github/workflows/lint-stylelint.yml b/.github/workflows/lint-stylelint.yml deleted file mode 100644 index c3fcd06..0000000 --- a/.github/workflows/lint-stylelint.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow is provided via the organization template repository -# -# https://github.com/nextcloud/.github -# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later - -name: Lint - -on: - pull_request: - push: - branches: - - master - - stable* - -jobs: - lint: - runs-on: ubuntu-latest - - name: stylelint - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.1 - id: versions - with: - fallbackNode: '^12' - fallbackNpm: '^6' - - - name: Set up node $ - uses: actions/setup-node@v2 - with: - node-version: $ - - - name: Set up npm $ - run: npm i -g npm@"$" - - - name: Install dependencies - run: npm ci - - - name: Lint - run: npm run stylelint diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml deleted file mode 100644 index 11422d0..0000000 --- a/.github/workflows/phpunit-mysql.yml +++ /dev/null @@ -1,117 +0,0 @@ - -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later -name: PHPUnit - -on: - pull_request: - push: - branches: - - master - - stable* - -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - -jobs: - phpunit-mysql: - runs-on: ubuntu-latest - - strategy: - matrix: - php-versions: ['7.4', '8.0', '8.1'] - server-versions: ['master'] - - services: - mysql: - image: mariadb:10.5 - ports: - - 4444:3306/tcp - env: - MYSQL_ROOT_PASSWORD: rootpassword - options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5 - - steps: - - name: Set app env - run: | - # Split and keep last - echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - - - name: Enable ONLY_FULL_GROUP_BY MySQL option - run: | - echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword - echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword - - - name: Checkout server - uses: actions/checkout@v3 - with: - submodules: true - repository: nextcloud/server - ref: ${{ matrix.server-versions }} - - - name: Checkout app - uses: actions/checkout@v3 - with: - path: apps/${{ env.APP_NAME }} - - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql - coverage: none - - - name: Set up PHPUnit - working-directory: apps/${{ env.APP_NAME }} - run: composer i - - - name: Set up Nextcloud - env: - DB_PORT: 4444 - run: | - mkdir data - ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password - ./occ app:enable ${{ env.APP_NAME }} - - - name: Check PHPUnit config file existence - id: check_phpunit - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - - - name: Run Nextcloud - run: php -S localhost:8080 & - - - name: PHPUnit - # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} - - - name: Check PHPUnit integration config file existence - id: check_integration - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - - name: PHPUnit integration - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - summary: - runs-on: ubuntu-latest - needs: phpunit-mysql - - if: always() - - name: phpunit-mysql-summary - - steps: - - name: Summary status - run: if ${{ needs.phpunit-mysql.result != 'success' }}; then exit 1; fi - diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index 79daa6f..b0ccdcd 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -80,23 +80,6 @@ jobs: working-directory: apps/${{ env.APP_NAME }} run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} - - name: Check PHPUnit integration config file existence - id: check_integration - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - - name: Run Nextcloud - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - run: php -S localhost:8080 & - - - name: PHPUnit integration - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} - summary: runs-on: ubuntu-latest needs: phpunit-oci diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml deleted file mode 100644 index 61d8d85..0000000 --- a/.github/workflows/phpunit-pgsql.yml +++ /dev/null @@ -1,116 +0,0 @@ - -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later -name: PHPUnit - -on: - pull_request: - push: - branches: - - master - - stable* - -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - -jobs: - phpunit-pgsql: - runs-on: ubuntu-latest - - strategy: - matrix: - php-versions: ['8.0'] - server-versions: ['master'] - - services: - postgres: - image: postgres - ports: - - 4444:5432/tcp - env: - POSTGRES_USER: root - POSTGRES_PASSWORD: rootpassword - POSTGRES_DB: nextcloud - options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5 - - steps: - - name: Set app env - run: | - # Split and keep last - echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - - - name: Checkout server - uses: actions/checkout@v3 - with: - submodules: true - repository: nextcloud/server - ref: ${{ matrix.server-versions }} - - - name: Checkout app - uses: actions/checkout@v3 - with: - path: apps/${{ env.APP_NAME }} - - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql - coverage: none - - - name: Set up PHPUnit - working-directory: apps/${{ env.APP_NAME }} - run: composer i - - - name: Set up Nextcloud - env: - DB_PORT: 4444 - run: | - mkdir data - ./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password - ./occ app:enable ${{ env.APP_NAME }} - - - name: Check PHPUnit config file existence - id: check_phpunit - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - - - name: PHPUnit - # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} - - - name: Check PHPUnit integration config file existence - id: check_integration - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - - name: Run Nextcloud - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - run: php -S localhost:8080 & - - - name: PHPUnit integration - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - summary: - runs-on: ubuntu-latest - needs: phpunit-pgsql - - if: always() - - name: phpunit-pgsql-summary - - steps: - - name: Summary status - run: if ${{ needs.phpunit-pgsql.result != 'success' }}; then exit 1; fi - diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml deleted file mode 100644 index c72fdde..0000000 --- a/.github/workflows/phpunit-sqlite.yml +++ /dev/null @@ -1,105 +0,0 @@ - -# SPDX-FileCopyrightText: Nextcloud contributors -# SPDX-License-Identifier: AGPL-3.0-or-later -name: PHPUnit - -on: - pull_request: - push: - branches: - - master - - stable* - -env: - # Location of the phpunit.xml and phpunit.integration.xml files - PHPUNIT_CONFIG: ./tests/phpunit.xml - PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml - -jobs: - phpunit-sqlite: - runs-on: ubuntu-latest - - strategy: - matrix: - php-versions: ['8.0'] - server-versions: ['master'] - - steps: - - name: Set app env - run: | - # Split and keep last - echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV - - - name: Checkout server - uses: actions/checkout@v3 - with: - submodules: true - repository: nextcloud/server - ref: ${{ matrix.server-versions }} - - - name: Checkout app - uses: actions/checkout@v3 - with: - path: apps/${{ env.APP_NAME }} - - - name: Set up php ${{ matrix.php-versions }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - tools: phpunit - extensions: mbstring, iconv, fileinfo, intl, sqlite, pdo_sqlite - coverage: none - - - name: Set up PHPUnit - working-directory: apps/${{ env.APP_NAME }} - run: composer i - - - name: Set up Nextcloud - env: - DB_PORT: 4444 - run: | - mkdir data - ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password - ./occ app:enable ${{ env.APP_NAME }} - - - name: Check PHPUnit config file existence - id: check_phpunit - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }} - - - name: PHPUnit - # Only run if phpunit config file exists - if: steps.check_phpunit.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }} - - - name: Check PHPUnit integration config file existence - id: check_integration - uses: andstor/file-existence-action@v1 - with: - files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - - name: Run Nextcloud - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - run: php -S localhost:8080 & - - - name: PHPUnit integration - # Only run if phpunit integration config file exists - if: steps.check_integration.outputs.files_exists == 'true' - working-directory: apps/${{ env.APP_NAME }} - run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }} - - summary: - runs-on: ubuntu-latest - needs: phpunit-sqlite - - if: always() - - name: phpunit-sqlite-summary - - steps: - - name: Summary status - run: if ${{ needs.phpunit-sqlite.result != 'success' }}; then exit 1; fi - diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml deleted file mode 100644 index 11c46d3..0000000 --- a/.github/workflows/reuse.yml +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. -# -# SPDX-License-Identifier: CC0-1.0 - -name: REUSE Compliance Check - -on: [push, pull_request] - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: REUSE Compliance Check - uses: fsfe/reuse-action@v1 \ No newline at end of file diff --git a/.reuse/dep5 b/.reuse/dep5 deleted file mode 100644 index 92f858c..0000000 --- a/.reuse/dep5 +++ /dev/null @@ -1,12 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: MFA Zones -Upstream-Contact: Pondersource -Source: https://github.com/nextcloud/profiler - -Files: package-lock.json package.json composer.json composer.lock -Copyright: Pondersource -License: AGPL-3.0-or-later - -Files: l10n/*.js l10n/*.json -Copyright: Nextcloud translators -License: AGPL-3.0-or-later diff --git a/.reuse/info.xml b/.reuse/info.xml deleted file mode 100644 index ba322af..0000000 --- a/.reuse/info.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - mfazones - MFA Zones - https://github.com/pondersource/mfazones - - 0.0.1 - agpl - Pondersource - mfazones - files - security - https://github.com/pondersource/mfazones/issues - - - files_accesscontrol - - diff --git a/README.md b/README.md index 08e1d9c..1cceb92 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ + + # MFA Zones Nextcloud App This is a Nextcloud app that enables file owners and administrators to restrict access to files and folders based on whether or not a logged-in user has passed MFA (multi-factor authentication) verification. diff --git a/appinfo/info.xml b/appinfo/info.xml index 15e98e8..10e631f 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -19,7 +19,6 @@ See the [README](https://github.com/pondersource/mfazones/blob/main/README.md) f security https://github.com/pondersource/mfazones/issues - - files_accesscontrol + diff --git a/appinfo/routes.php b/appinfo/routes.php index 9c8ac60..687b007 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -1,4 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + return [ 'routes' => [ ['name' => 'mfazones#get', 'url' => '/get', 'verb' => 'GET'], diff --git a/css/tabview.css b/css/tabview.css index 58233ab..2fc2866 100644 --- a/css/tabview.css +++ b/css/tabview.css @@ -1,3 +1,5 @@ +/* SPDX-FileCopyrightText: Pondersource */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ #mfazoneTabView table { margin-left: .5em; } diff --git a/js/plugin.js b/js/plugin.js index 368520f..0562e7f 100644 --- a/js/plugin.js +++ b/js/plugin.js @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Pondersource +// SPDX-License-Identifier: AGPL-3.0-or-later var mfazoneFileListPlugin = { attach: function(fileList) { // if (fileList.id === 'trashbin' || fileList.id === 'files.public') { diff --git a/js/tabview.js b/js/tabview.js index 0899ee4..3fd88e2 100644 --- a/js/tabview.js +++ b/js/tabview.js @@ -1,3 +1,5 @@ +// SPDX-FileCopyrightText: Pondersource +// SPDX-License-Identifier: AGPL-3.0-or-later (function () { const MfaZoneTabView = OCA.Files.DetailTabView.extend({ id: 'mfazoneTabView', @@ -85,6 +87,13 @@         Enforce MFA requirement +
+
+
+
+

+ +
`; const $htmlDisabled = ` @@ -158,6 +167,13 @@         Enforce MFA requirement +
+
+
+
+

+ +
`; const accessUrl = OC.generateUrl('/apps/mfazones/access'), @@ -198,6 +214,14 @@ success: function (response) { self.document.getElementById('checkbox-radio-switch-mfa') .checked = response.status; + console.log(response.mfa_passed); + if (!response.mfa_passed){ + context.$el.find('#enable-2fa-button') + .click(context.showDialog); + } else { + context.$el.find('#need-mfa') + .hide(); + } if (enabled) { context.$el.find('#checkbox-radio-switch-mfa') .click(context.boxChecked); @@ -211,6 +235,11 @@ }, }); }, + showDialog: function () { + if (confirm('You must enable two factor authentication to use MFAZone app. Do you want to enable 2FA?')) { + window.location.href = '../../settings/user/security'; + } + }, boxChecked: function () { const checkBox = this; const setUrl = OC.generateUrl('/apps/mfazones/set'), @@ -243,4 +272,4 @@ }); OCA.mfazones = OCA.mfazones || {}; OCA.mfazones.MfaZoneTabView = MfaZoneTabView; -})(); \ No newline at end of file +})(); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php old mode 100644 new mode 100755 index a57fba5..f1bf6b0 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -12,6 +12,8 @@ use Psr\Log\LoggerInterface; use Doctrine\DBAL\Exception; use OCA\WorkflowEngine\Helper\ScopeContext; +use OCA\Files\Event\LoadAdditionalScriptsEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\WorkflowEngine\IManager; use OCP\IDBConnection; @@ -40,14 +42,32 @@ public function __construct() { $container = $this->getContainer(); $server = $container->getServer(); - $eventDispatcher = $server->getEventDispatcher(); + $eventDispatcher = $this->getContainer()->get(IEventDispatcher::class); + + $eventDispatcher->addListener( + BeforeUserLoggedInEvent::class, + function ($event) { + // Check if the user has MFA verified + $twoFactorManager = \OC::$server->get(TwoFactorManager::class); + $userManager = \OC::$server->get(IUserManager::class); + $user = $userManager->get($event->getUsername()); + $hasMfaEnabled = $twoFactorManager->isTwoFactorAuthenticated($user); + // Redirect users to enable MFA if not already enabled and have 2FA provider + if (!$hasMfaEnabled) { + $providerSet = $twoFactorManager->getProviderSet($user); + if(!empty($loginProviders) && !$providerSet->isProviderMissing()){ + $twoFactorManager->prepareTwoFactorLogin($user, false); + } + } + } + ); $this->systemTagManager = $this->getContainer()->get(ISystemTagManager::class); $this->manager = $this->getContainer()->get(Manager::class); $this->logger = $this->getContainer()->get(LoggerInterface::class); $this->connection = $this->getContainer()->get(IDBConnection::class); - $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() { + $eventDispatcher->addListener(LoadAdditionalScriptsEvent::class, function() { \OCP\Util::addStyle(self::APP_ID, 'tabview' ); \OCP\Util::addScript(self::APP_ID, 'tabview' ); \OCP\Util::addScript(self::APP_ID, 'plugin' ); diff --git a/lib/Controller/MfazonesController.php b/lib/Controller/MfazonesController.php index 6b65d94..dd1a321 100755 --- a/lib/Controller/MfazonesController.php +++ b/lib/Controller/MfazonesController.php @@ -1,4 +1,6 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later namespace OCA\mfazones\Controller; @@ -67,28 +69,32 @@ public function __construct( $this->systemTagManager = $systemTagManager; } + private function isMfaVerified(){ + $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'; + } + return $mfaVerified === '1'; + } + public function hasAccess($source) { try { - $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'; - } - + $mfaVerified = $this->isMfaVerified(); $isAdmin = $this->groupManager->isAdmin($this->userId); $userRoot = $this->rootFolder->getUserFolder($this->userId); try { $node = $userRoot->get($source); - $hasAccess = $isAdmin || ($node->getOwner()->getUID() === $this->userId && $mfaVerified === '1'); + $hasAccess = $isAdmin || ($node->getOwner()->getUID() === $this->userId && $mfaVerified); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'mfazones']); $hasAccess = false; @@ -121,7 +127,8 @@ public function get($source) return new JSONResponse( array( - 'status' => $result + 'status' => $result, + 'mfa_passed' => $this->isMfaVerified() ) ); diff --git a/lib/Service/MfazonesService.php b/lib/Service/MfazonesService.php deleted file mode 100644 index 7b9646b..0000000 --- a/lib/Service/MfazonesService.php +++ /dev/null @@ -1,18 +0,0 @@ - -// SPDX-License-Identifier: AGPL-3.0-or-later - -namespace OCA\mfazones\Service; - -use Exception; - -use OCP\AppFramework\Db\DoesNotExistException; -use OCP\AppFramework\Db\MultipleObjectsReturnedException; - - -class MfazonesService { - - public function __construct() { - } -} diff --git a/lib/Setting/MfaZoneSettings.php b/lib/Setting/MfaZoneSettings.php index 1cd2cf2..1b9e4d2 100644 --- a/lib/Setting/MfaZoneSettings.php +++ b/lib/Setting/MfaZoneSettings.php @@ -1,5 +1,8 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later + declare(strict_types=1); namespace OCA\MfaZone\Settings; diff --git a/src/App.vue b/src/App.vue deleted file mode 100644 index 03d6838..0000000 --- a/src/App.vue +++ /dev/null @@ -1,241 +0,0 @@ -