Skip to content

feat: Manage Trusted Servers via OCC command - #63440

Open
T0mWz wants to merge 1 commit into
nextcloud:masterfrom
T0mWz:63439
Open

feat: Manage Trusted Servers via OCC command#63440
T0mWz wants to merge 1 commit into
nextcloud:masterfrom
T0mWz:63439

Conversation

@T0mWz

@T0mWz T0mWz commented Aug 20, 2026

Copy link
Copy Markdown

Issue

As an administrator, I currently have to manually add each URL one by one as a trusted server via the Web Interface. From an administrative standpoint, the ability to add a single URL or a list of URLs via the shell would be highly desirable.

See submitted issue; #63439

Wish

Add an OCC option to list and manage federated trusted servers. This would eliminate the need for multiple clicks and copy-and-paste actions. But it also makes automated management easier.

Usage

occ federation:trusted-servers --list
occ federation:trusted-servers --add https://a.example.com https://b.example.com
occ federation:trusted-servers --remove https://a.example.com

Notes

  • --list ignores the servers argument; --add/--remove require at least one URL — enforced via INVALID (exit 2) return codes.
  • --remove takes a URL rather than an id (matching your ask), so findServerId() re-applies the same https:// prefix + trailing-slash trim that TrustedServers::addServer() used when the row was stored, then matches against getServers() to find the id removeServer(int $id) needs.
  • Status codes (STATUS_OK etc.) are mapped to readable labels in the --list table.

@T0mWz
T0mWz requested review from a team and sorbaugh as code owners August 20, 2026 13:58
@T0mWz
T0mWz requested review from Altahrim, come-nc and icewind1991 and removed request for a team August 20, 2026 13:58
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ManageTrustedServers extends Command {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if this was using the new AsCommand attribute, see for example the files app how this is done

Comment on lines +44 to +46
->addOption('add', null, InputOption::VALUE_NONE, 'add the given servers to the trusted servers list')
->addOption('remove', null, InputOption::VALUE_NONE, 'remove the given servers from the trusted servers list')
->addOption('list', null, InputOption::VALUE_NONE, 'list all trusted servers');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer 3 sub commands federation:trusted-servers:add, federation:trusted-servers:remove and federation:trusted-servers:list.

You can have multiple command in a single class, see https://docs.nextcloud.com/server/latest/developer_manual/app_development/commands.html#multiple-commands-in-one-class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants