mirror of
https://github.com/harivansh-afk/betterNAS.git
synced 2026-04-15 21:03:22 +00:00
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>
43 lines
966 B
PHP
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',
|
|
'',
|
|
);
|
|
}
|
|
}
|