123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- <?php
- namespace OC;
- use OCP\IConfig;
- class SystemConfig {
-
- protected $sensitiveValues = [
- 'instanceid' => true,
- 'datadirectory' => true,
- 'dbname' => true,
- 'dbhost' => true,
- 'dbpassword' => true,
- 'dbuser' => true,
- 'dbreplica' => true,
- 'activity_dbname' => true,
- 'activity_dbhost' => true,
- 'activity_dbpassword' => true,
- 'activity_dbuser' => true,
- 'mail_from_address' => true,
- 'mail_domain' => true,
- 'mail_smtphost' => true,
- 'mail_smtpname' => true,
- 'mail_smtppassword' => true,
- 'passwordsalt' => true,
- 'secret' => true,
- 'updater.secret' => true,
- 'updater.server.url' => true,
- 'trusted_proxies' => true,
- 'preview_imaginary_url' => true,
- 'preview_imaginary_key' => true,
- 'proxyuserpwd' => true,
- 'sentry.dsn' => true,
- 'sentry.public-dsn' => true,
- 'zammad.download.secret' => true,
- 'zammad.portal.secret' => true,
- 'zammad.secret' => true,
- 'github.client_id' => true,
- 'github.client_secret' => true,
- 'log.condition' => [
- 'shared_secret' => true,
- 'matches' => true,
- ],
- 'license-key' => true,
- 'redis' => [
- 'host' => true,
- 'password' => true,
- ],
- 'redis.cluster' => [
- 'seeds' => true,
- 'password' => true,
- ],
- 'objectstore' => [
- 'arguments' => [
-
- 'options' => [
- 'credentials' => [
- 'key' => true,
- 'secret' => true,
- ]
- ],
-
- 'key' => true,
- 'secret' => true,
-
- 'username' => true,
- 'password' => true,
-
- 'user' => [
- 'name' => true,
- 'password' => true,
- ],
- ],
- ],
- 'objectstore_multibucket' => [
- 'arguments' => [
- 'options' => [
- 'credentials' => [
- 'key' => true,
- 'secret' => true,
- ]
- ],
-
- 'key' => true,
- 'secret' => true,
-
- 'username' => true,
- 'password' => true,
-
- 'user' => [
- 'name' => true,
- 'password' => true,
- ],
- ],
- ],
- 'onlyoffice' => [
- 'jwt_secret' => true,
- ],
- 'PASS' => true,
- ];
- public function __construct(
- private Config $config,
- ) {
- }
-
- public static function trustSystemConfig(mixed $value): mixed {
- return $value;
- }
-
- public function getKeys() {
- return $this->config->getKeys();
- }
-
- public function setValue($key, $value) {
- $this->config->setValue($key, $value);
- }
-
- public function setValues(array $configs) {
- $this->config->setValues($configs);
- }
-
- public function getValue($key, $default = '') {
- return $this->trustSystemConfig($this->config->getValue($key, $default));
- }
-
- public function getFilteredValue($key, $default = '') {
- $value = $this->getValue($key, $default);
- if (isset($this->sensitiveValues[$key])) {
- $value = $this->removeSensitiveValue($this->sensitiveValues[$key], $value);
- }
- return $value;
- }
-
- public function deleteValue($key) {
- $this->config->deleteKey($key);
- }
-
- protected function removeSensitiveValue($keysToRemove, $value) {
- if ($keysToRemove === true) {
- return IConfig::SENSITIVE_VALUE;
- }
- if (is_array($value)) {
- foreach ($keysToRemove as $keyToRemove => $valueToRemove) {
- if (isset($value[$keyToRemove])) {
- $value[$keyToRemove] = $this->removeSensitiveValue($valueToRemove, $value[$keyToRemove]);
- }
- }
- }
- return $value;
- }
- }
|