Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add nextcloud url helper info endpoint to get instance base_url #383

Merged
merged 2 commits into from
Sep 10, 2024
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.2.0 - 2024-09-09]
## [3.2.0 - 2024-09-10]

### Added

- ExAppProxy: added bruteforce protection option for ExApp routes. #368
- ExAppOCS: added miscellaneous method to get Nextcloud instance base URL. #383

### Changed

Expand Down
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
['name' => 'OCSApi#getEnabledState', 'url' => '/ex-app/state', 'verb' => 'GET'],

// ExApps
['name' => 'OCSExApp#getNextcloudUrl', 'url' => '/api/v1/info/nextcloud_url', 'verb' => 'GET'],
['name' => 'OCSExApp#getExAppsList', 'url' => '/api/v1/ex-app/{list}', 'verb' => 'GET'],
['name' => 'OCSExApp#getExApp', 'url' => '/api/v1/ex-app/info/{appId}', 'verb' => 'GET'],

Expand Down
18 changes: 18 additions & 0 deletions docs/tech_details/api/exapp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ Response data

Returns HTTP 200 on success, HTTP 404 - on error.

Get Nextcloud URL
^^^^^^^^^^^^^^^^^

It might be necessary for ExApp to know (or update) the Nextcloud URL.

OCS endpoint: ``GET /apps/app_api/api/v1/info/nextcloud_url``

Response data
*************

Returns the base URL of the Nextcloud instance:

.. code-block:: json

{
"base_url": "http(s)://nextcloud.example.com"
}


Make Requests to ExApps
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions lib/Controller/OCSExAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCP\AppFramework\OCS\OCSBadRequestException;
use OCP\AppFramework\OCSController;
use OCP\IRequest;
use OCP\IURLGenerator;

class OCSExAppController extends OCSController {
protected $request;
Expand All @@ -22,6 +23,7 @@ public function __construct(
IRequest $request,
private readonly AppAPIService $service,
private readonly ExAppService $exAppService,
private readonly IURLGenerator $urlGenerator,
) {
parent::__construct(Application::APP_ID, $request);

Expand All @@ -45,6 +47,13 @@ public function getExApp(string $appId): DataResponse {
return new DataResponse($this->exAppService->formatExAppInfo($exApp), Http::STATUS_OK);
}

#[NoCSRFRequired]
public function getNextcloudUrl(): DataResponse {
return new DataResponse([
'base_url' => $this->urlGenerator->getBaseUrl(),
], Http::STATUS_OK);
}

/**
* @throws OCSBadRequestException
*/
Expand Down
Loading