Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
113 changes: 113 additions & 0 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# 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: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Node

on: pull_request

permissions:
contents: read

concurrency:
group: node-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
changes:
runs-on: ubuntu-latest-low
permissions:
contents: read
pull-requests: read

outputs:
src: ${{ steps.changes.outputs.src}}

steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changes
continue-on-error: true
with:
filters: |
src:
- '.github/workflows/**'
- 'src/**'
- 'appinfo/info.xml'
- 'package.json'
- 'package-lock.json'
- 'tsconfig.json'
- '**.js'
- '**.ts'
- '**.vue'

build:
runs-on: ubuntu-latest

needs: changes
if: needs.changes.outputs.src != 'false'

name: NPM build
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
id: versions
with:
fallbackNode: '^22'
fallbackNpm: '^10'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'

- name: Validate package-lock.json # See https://github.com/npm/cli/issues/4460
run: |
npm i -g npm-package-lock-add-resolved@1.1.4
npm-package-lock-add-resolved
git --no-pager diff --exit-code

- name: Install dependencies & build
env:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true
run: |
npm ci
npm run build --if-present

- name: Check build changes
run: |
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"

- name: Show changes on failure
if: failure()
run: |
git status
git --no-pager diff
exit 1 # make it red to grab attention

summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: [changes, build]

if: always()

# This is the summary, we just avoid to rename it so that branch protection rules still match
name: node

steps:
- name: Summary status
run: if ${{ needs.changes.outputs.src != 'false' && needs.build.result != 'success' }}; then exit 1; fi
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ vendor
vendor-bin/*/vendor
.php-cs-fixer.cache
tests/.phpunit.cache

# frontend
node_modules
js/*.js
js/*.js.map
js/*.mjs.map
js/*.LICENSE.txt
4 changes: 4 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ Read the [documentation](https://github.com/nextcloud/user_external#readme) to l
<dependencies>
<nextcloud min-version="31" max-version="32" />
</dependencies>
<settings>
<admin>OCA\UserExternal\Settings\Admin</admin>
<admin-section>OCA\UserExternal\Settings\AdminSection</admin-section>
</settings>
</info>
10 changes: 10 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

return [
'routes' => [
['name' => 'Config#getBackends', 'url' => '/api/v1/backends', 'verb' => 'GET'],
['name' => 'Config#setBackends', 'url' => '/api/v1/backends', 'verb' => 'PUT'],
],
];
2 changes: 1 addition & 1 deletion img/app.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions js/user_external-adminSettings.mjs

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions js/user_external-adminSettings.mjs.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
SPDX-License-Identifier: (MPL-2.0 OR Apache-2.0)
SPDX-License-Identifier: AGPL-3.0-or-later
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-License-Identifier: ISC
SPDX-License-Identifier: MIT
SPDX-FileCopyrightText: @nextcloud/dialogs developers
SPDX-FileCopyrightText: Christoph Wurst
SPDX-FileCopyrightText: David Myers <hello@davidmyers.dev>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
SPDX-FileCopyrightText: Jeff Sagal <sagalbot@gmail.com>
SPDX-FileCopyrightText: Matt Zabriskie
SPDX-FileCopyrightText: Nextcloud GmbH and Nextcloud contributors
SPDX-FileCopyrightText: Rob Cresswell <robcresswell@pm.me>
SPDX-FileCopyrightText: Varun A P
SPDX-FileCopyrightText: atomiks
SPDX-FileCopyrightText: escape-html developers
SPDX-FileCopyrightText: user_external developers

This file is generated from multiple sources. Included packages:
- @floating-ui/core
- version: 1.7.5
- license: MIT
- @floating-ui/dom
- version: 1.1.1
- license: MIT
- @floating-ui/dom
- version: 1.7.6
- license: MIT
- @floating-ui/utils
- version: 0.2.11
- license: MIT
- @nextcloud/auth
- version: 2.5.3
- license: GPL-3.0-or-later
- @nextcloud/axios
- version: 2.5.2
- license: GPL-3.0-or-later
- @nextcloud/browser-storage
- version: 0.5.0
- license: GPL-3.0-or-later
- @nextcloud/dialogs
- version: 7.3.0
- license: AGPL-3.0-or-later
- @nextcloud/event-bus
- version: 3.3.3
- license: GPL-3.0-or-later
- @nextcloud/initial-state
- version: 3.0.0
- license: GPL-3.0-or-later
- @nextcloud/l10n
- version: 3.4.1
- license: GPL-3.0-or-later
- @nextcloud/logger
- version: 3.0.3
- license: GPL-3.0-or-later
- @nextcloud/router
- version: 3.1.0
- license: GPL-3.0-or-later
- @nextcloud/vue
- version: 9.6.0
- license: AGPL-3.0-or-later
- @vitejs/plugin-vue
- version: 6.0.5
- license: MIT
- @vue/reactivity
- version: 3.5.31
- license: MIT
- @vue/runtime-core
- version: 3.5.31
- license: MIT
- @vue/runtime-dom
- version: 3.5.31
- license: MIT
- @vue/shared
- version: 3.5.31
- license: MIT
- axios
- version: 1.13.6
- license: MIT
- dompurify
- version: 3.3.3
- license: (MPL-2.0 OR Apache-2.0)
- escape-html
- version: 1.0.3
- license: MIT
- floating-vue
- version: 5.2.2
- license: MIT
- semver
- version: 7.7.4
- license: ISC
- toastify-js
- version: 1.12.0
- license: MIT
- user_external
- version: 3.6.0
- license: AGPL-3.0-or-later
- vite
- version: 7.3.1
- license: MIT
- vite-plugin-node-polyfills
- version: 0.24.0
- license: MIT
- vue-material-design-icons
- version: 5.3.1
- license: MIT
- vue-router
- version: 5.0.4
- license: MIT
- vue-select
- version: 4.0.0-beta.6
- license: MIT
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;

class Application extends App implements IBootstrap {
public const APP_ID = 'user_external';

public function __construct() {
parent::__construct('user_external');
parent::__construct(self::APP_ID);
}

public function register(IRegistrationContext $context): void {
Expand Down
62 changes: 62 additions & 0 deletions lib/Controller/ConfigController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace OCA\UserExternal\Controller;

use OCA\UserExternal\Service\BackendConfigService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;

class ConfigController extends Controller {
public function __construct(
string $appName,
IRequest $request,
private readonly BackendConfigService $backendConfigService,
) {
parent::__construct($appName, $request);
}

/**
* Returns the current user_backends configuration.
* Requires admin (no @NoAdminRequired).
*/
#[NoCSRFRequired]
public function getBackends(): JSONResponse {
return new JSONResponse($this->backendConfigService->getBackends());
}

/**
* Replaces the user_backends configuration.
* Requires admin (no @NoAdminRequired).
*
* @param list<array{class: string, arguments: list<mixed>}> $backends
*/
public function setBackends(array $backends): JSONResponse {
// Validate that each entry has the required keys and an allowed class.
$allowed = [
'\\OCA\\UserExternal\\IMAP',
'\\OCA\\UserExternal\\FTP',
'\\OCA\\UserExternal\\SMB',
'\\OCA\\UserExternal\\SSH',
'\\OCA\\UserExternal\\BasicAuth',
'\\OCA\\UserExternal\\WebDavAuth',
'\\OCA\\UserExternal\\XMPP',
];

foreach ($backends as $backend) {
if (!isset($backend['class'], $backend['arguments'])) {
return new JSONResponse(['error' => 'Invalid backend format'], Http::STATUS_BAD_REQUEST);
}
if (!in_array($backend['class'], $allowed, true)) {
return new JSONResponse(['error' => 'Unknown backend class: ' . $backend['class']], Http::STATUS_BAD_REQUEST);
}
}

$this->backendConfigService->setBackends($backends);
return new JSONResponse(['status' => 'ok']);
}
}
27 changes: 27 additions & 0 deletions lib/Service/BackendConfigService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace OCA\UserExternal\Service;

use OCP\IConfig;

/**
* Reads and writes the user_backends system config key.
*/
class BackendConfigService {
public function __construct(
private readonly IConfig $config,
) {
}

/** @return list<array{class: string, arguments: list<mixed>}> */
public function getBackends(): array {
return $this->config->getSystemValue('user_backends', []);
}

/** @param list<array{class: string, arguments: list<mixed>}> $backends */
public function setBackends(array $backends): void {
$this->config->setSystemValue('user_backends', $backends);
}
}
Loading
Loading