betterNAS/apps/nextcloud-app/lib/Service/ControlPlaneConfig.php
Harivansh Rathi ed40da7326 Secure first-loop control-plane auth and mount routing.
Protect the control-plane API with explicit bearer auth, add node-scoped
registration/heartbeat credentials, and make export mount paths an explicit
contract field so mount profiles stay correct across runtimes.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-04-01 14:13:14 +00:00

43 lines
966 B
PHP

<?php
declare(strict_types=1);
namespace OCA\BetterNasControlplane\Service;
use OCA\BetterNasControlplane\AppInfo\Application;
use OCP\IAppConfig;
class ControlPlaneConfig {
public function __construct(
private readonly IAppConfig $appConfig,
) {
}
public function getBaseUrl(): string {
$environmentUrl = getenv('BETTERNAS_CONTROL_PLANE_URL');
if (is_string($environmentUrl) && $environmentUrl !== '') {
return rtrim($environmentUrl, '/');
}
$configuredUrl = $this->appConfig->getValueString(
Application::APP_ID,
'control_plane_url',
'http://control-plane:3000',
);
return rtrim($configuredUrl, '/');
}
public function getApiToken(): string {
$environmentToken = getenv('BETTERNAS_CONTROL_PLANE_API_TOKEN');
if (is_string($environmentToken) && $environmentToken !== '') {
return $environmentToken;
}
return $this->appConfig->getValueString(
Application::APP_ID,
'control_plane_api_token',
'',
);
}
}