chore: remove non working and legacy OAuth2 auth schema

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2026-01-12 12:27:09 +01:00 committed by nextcloud-command
parent e1133ec926
commit 545c72becb
5 changed files with 0 additions and 163 deletions

View file

@ -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',

View file

@ -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'),
)
}
},
)
}
})
})

View file

@ -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),

View file

@ -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.

View file

@ -1,37 +0,0 @@
<?php
/**
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Lib\Auth\OAuth2;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCP\IL10N;
/**
* OAuth2 authentication
*/
class OAuth2 extends AuthMechanism {
public function __construct(IL10N $l) {
$this
->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')
;
}
}