From 545c72becb31bc26e198671215a9c1f47e759509 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Mon, 12 Jan 2026 12:27:09 +0100 Subject: [PATCH] chore: remove non working and legacy OAuth2 auth schema Signed-off-by: Ferdinand Thiessen --- apps/files_external/appinfo/routes.php | 5 - apps/files_external/js/oauth2.js | 108 ------------------ .../lib/AppInfo/Application.php | 4 - .../lib/Controller/AjaxController.php | 9 -- .../lib/Lib/Auth/OAuth2/OAuth2.php | 37 ------ 5 files changed, 163 deletions(-) delete mode 100644 apps/files_external/js/oauth2.js delete mode 100644 apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php diff --git a/apps/files_external/appinfo/routes.php b/apps/files_external/appinfo/routes.php index fb695eafefe..348c6f9d69e 100644 --- a/apps/files_external/appinfo/routes.php +++ b/apps/files_external/appinfo/routes.php @@ -18,11 +18,6 @@ return [ 'url' => '/ajax/applicable', 'verb' => 'GET', ], - [ - 'name' => 'Ajax#oauth2Callback', - 'url' => '/ajax/oauth2.php', - 'verb' => 'GET', - ], [ 'name' => 'Ajax#getSshKeys', 'url' => '/ajax/public_key.php', diff --git a/apps/files_external/js/oauth2.js b/apps/files_external/js/oauth2.js deleted file mode 100644 index 5fefc59e560..00000000000 --- a/apps/files_external/js/oauth2.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-FileCopyrightText: 2016 ownCloud, Inc. - * SPDX-License-Identifier: AGPL-3.0-only - */ -window.addEventListener('DOMContentLoaded', function() { - /** - * - * @param $tr - */ - function displayGranted($tr) { - $tr.find('.configuration input.auth-param').attr('disabled', 'disabled').addClass('disabled-success') - } - - OCA.Files_External.Settings.mountConfig.whenSelectAuthMechanism(function($tr, authMechanism, scheme, onCompletion) { - if (authMechanism === 'oauth2::oauth2') { - const config = $tr.find('.configuration') - config.append($(document.createElement('input')) - .addClass('button auth-param') - .attr('type', 'button') - .attr('value', t('files_external', 'Grant access')) - .attr('name', 'oauth2_grant')) - - onCompletion.then(function() { - const configured = $tr.find('[data-parameter="configured"]') - if ($(configured).val() == 'true') { - displayGranted($tr) - } else { - const client_id = $tr.find('.configuration [data-parameter="client_id"]').val() - const client_secret = $tr.find('.configuration [data-parameter="client_secret"]') - .val() - if (client_id != '' && client_secret != '') { - const params = {} - window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) { - params[key] = value - }) - if (params.code !== undefined) { - const token = $tr.find('.configuration [data-parameter="token"]') - const statusSpan = $tr.find('.status span') - statusSpan.removeClass() - statusSpan.addClass('waiting') - $.post( - OC.filePath('files_external', 'ajax', 'oauth2.php'), - { - step: 2, - client_id, - client_secret, - redirect: location.protocol + '//' + location.host + location.pathname, - code: params.code, - }, - function(result) { - if (result && result.status == 'success') { - $(token).val(result.data.token) - $(configured).val('true') - OCA.Files_External.Settings.mountConfig.saveStorageConfig($tr, function(status) { - if (status) { - displayGranted($tr) - } - }) - } else { - OC.dialogs.alert( - result.data.message, - t('files_external', 'Error configuring OAuth2'), - ) - } - }, - ) - } - } - } - }) - } - }) - - $('#externalStorage').on('click', '[name="oauth2_grant"]', function(event) { - event.preventDefault() - const tr = $(this).parent().parent() - const configured = $(this).parent().find('[data-parameter="configured"]') - const client_id = $(this).parent().find('[data-parameter="client_id"]').val() - const client_secret = $(this).parent().find('[data-parameter="client_secret"]').val() - if (client_id != '' && client_secret != '') { - const token = $(this).parent().find('[data-parameter="token"]') - $.post( - OC.filePath('files_external', 'ajax', 'oauth2.php'), - { - step: 1, - client_id, - client_secret, - redirect: location.protocol + '//' + location.host + location.pathname, - }, - function(result) { - if (result && result.status == 'success') { - $(configured).val('false') - $(token).val('false') - OCA.Files_External.Settings.mountConfig.saveStorageConfig(tr, function(status) { - window.location = result.data.url - }) - } else { - OC.dialogs.alert( - result.data.message, - t('files_external', 'Error configuring OAuth2'), - ) - } - }, - ) - } - }) -}) diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php index 1ad1a2ed779..ae0b1479d64 100644 --- a/apps/files_external/lib/AppInfo/Application.php +++ b/apps/files_external/lib/AppInfo/Application.php @@ -14,7 +14,6 @@ use OCA\Files_External\ConfigLexicon; use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey; use OCA\Files_External\Lib\Auth\Builtin; use OCA\Files_External\Lib\Auth\NullMechanism; -use OCA\Files_External\Lib\Auth\OAuth2\OAuth2; use OCA\Files_External\Lib\Auth\OpenStack\OpenStackV2; use OCA\Files_External\Lib\Auth\OpenStack\OpenStackV3; use OCA\Files_External\Lib\Auth\OpenStack\Rackspace; @@ -136,9 +135,6 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide $container->get(GlobalAuth::class), $container->get(UserGlobalAuth::class), - // AuthMechanism::SCHEME_OAUTH2 mechanisms - $container->get(OAuth2::class), - // AuthMechanism::SCHEME_PUBLICKEY mechanisms $container->get(RSA::class), $container->get(RSAPrivateKey::class), diff --git a/apps/files_external/lib/Controller/AjaxController.php b/apps/files_external/lib/Controller/AjaxController.php index 2953ae8a056..3d1d61254dd 100644 --- a/apps/files_external/lib/Controller/AjaxController.php +++ b/apps/files_external/lib/Controller/AjaxController.php @@ -42,15 +42,6 @@ class AjaxController extends Controller { parent::__construct($appName, $request); } - - /** - * Legacy endpoint for oauth2 callback - */ - #[NoAdminRequired()] - public function oauth2Callback(): JSONResponse { - return new JSONResponse(['status' => 'success']); - } - /** * Returns a list of users and groups that match the given pattern. * Used for user and group picker in the admin settings. diff --git a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php b/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php deleted file mode 100644 index beaf73c2344..00000000000 --- a/apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php +++ /dev/null @@ -1,37 +0,0 @@ -setIdentifier('oauth2::oauth2') - ->setScheme(self::SCHEME_OAUTH2) - ->setText($l->t('OAuth2')) - ->addParameters([ - (new DefinitionParameter('configured', 'configured')) - ->setType(DefinitionParameter::VALUE_TEXT) - ->setFlag(DefinitionParameter::FLAG_HIDDEN), - new DefinitionParameter('client_id', $l->t('Client ID')), - (new DefinitionParameter('client_secret', $l->t('Client secret'))) - ->setType(DefinitionParameter::VALUE_PASSWORD), - (new DefinitionParameter('token', 'token')) - ->setType(DefinitionParameter::VALUE_PASSWORD) - ->setFlag(DefinitionParameter::FLAG_HIDDEN), - ]) - ->addCustomJs('oauth2') - ; - } -}