86 lines
3.4 KiB
PHP
Executable File
86 lines
3.4 KiB
PHP
Executable File
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App;
|
|
|
|
class Config
|
|
{
|
|
public string $assetVersion;
|
|
public bool $dbAutoInit;
|
|
public ?string $dbInitScript;
|
|
public ?string $dbInitCmd;
|
|
public string $keaDbVersion;
|
|
public array $baseDb;
|
|
public bool $baseDbEnabled;
|
|
public bool $authEnabled;
|
|
public string $oidcIssuer;
|
|
public string $oidcClientId;
|
|
public string $oidcClientSecret;
|
|
public string $oidcRedirectUri;
|
|
public string $oidcAuthEndpoint;
|
|
public string $oidcTokenEndpoint;
|
|
public string $oidcUserinfoEndpoint;
|
|
public string $oidcLogoutEndpoint;
|
|
public string $oidcGroupClaim;
|
|
public string $oidcAdminGroup;
|
|
public string $oidcUserGroup;
|
|
|
|
public function __construct(
|
|
public array $db,
|
|
public bool $dbEnabled = true,
|
|
array $baseDb = [],
|
|
bool $baseDbEnabled = false
|
|
) {
|
|
$this->assetVersion = defined('ASSET_VERSION') ? ASSET_VERSION : '';
|
|
$this->dbAutoInit = defined('APP_DB_AUTO_INIT') ? (bool)APP_DB_AUTO_INIT : false;
|
|
$this->dbInitScript = defined('APP_DB_INIT_SCRIPT') ? (string)APP_DB_INIT_SCRIPT : null;
|
|
$this->dbInitCmd = defined('APP_DB_INIT_CMD') ? (string)APP_DB_INIT_CMD : null;
|
|
$this->keaDbVersion = defined('APP_KEA_DB_VERSION') ? (string)APP_KEA_DB_VERSION : '';
|
|
$this->baseDb = $baseDb;
|
|
$this->baseDbEnabled = $baseDbEnabled;
|
|
$this->authEnabled = defined('APP_AUTH_ENABLED') ? (bool)APP_AUTH_ENABLED : false;
|
|
$this->oidcIssuer = defined('APP_OIDC_ISSUER') ? (string)APP_OIDC_ISSUER : '';
|
|
$this->oidcClientId = defined('APP_OIDC_CLIENT_ID') ? (string)APP_OIDC_CLIENT_ID : '';
|
|
$this->oidcClientSecret = defined('APP_OIDC_CLIENT_SECRET') ? (string)APP_OIDC_CLIENT_SECRET : '';
|
|
$this->oidcRedirectUri = defined('APP_OIDC_REDIRECT_URI') ? (string)APP_OIDC_REDIRECT_URI : '';
|
|
$this->oidcAuthEndpoint = defined('APP_OIDC_AUTH_ENDPOINT') ? (string)APP_OIDC_AUTH_ENDPOINT : '';
|
|
$this->oidcTokenEndpoint = defined('APP_OIDC_TOKEN_ENDPOINT') ? (string)APP_OIDC_TOKEN_ENDPOINT : '';
|
|
$this->oidcUserinfoEndpoint = defined('APP_OIDC_USERINFO_ENDPOINT') ? (string)APP_OIDC_USERINFO_ENDPOINT : '';
|
|
$this->oidcLogoutEndpoint = defined('APP_OIDC_LOGOUT_ENDPOINT') ? (string)APP_OIDC_LOGOUT_ENDPOINT : '';
|
|
$this->oidcGroupClaim = defined('APP_OIDC_GROUP_CLAIM') ? (string)APP_OIDC_GROUP_CLAIM : 'groups';
|
|
$this->oidcAdminGroup = defined('APP_OIDC_ADMIN_GROUP') ? (string)APP_OIDC_ADMIN_GROUP : 'admin';
|
|
$this->oidcUserGroup = defined('APP_OIDC_USER_GROUP') ? (string)APP_OIDC_USER_GROUP : 'user';
|
|
}
|
|
|
|
public function primaryUrl(): string
|
|
{
|
|
if (defined('APP_URL_PRIMARY') && APP_URL_PRIMARY !== '') {
|
|
return APP_URL_PRIMARY;
|
|
}
|
|
$domain = $this->cookieDomain();
|
|
if ($domain) {
|
|
return 'https://' . $domain;
|
|
}
|
|
return '';
|
|
}
|
|
|
|
public function cookiePrefix(): string
|
|
{
|
|
if (defined('APP_PREFIX') && APP_PREFIX !== '') {
|
|
return APP_PREFIX . '_';
|
|
}
|
|
return 'nexus_';
|
|
}
|
|
|
|
public function cookieDomain(): ?string
|
|
{
|
|
if (defined('APP_DOMAIN_PRIMARY') && APP_DOMAIN_PRIMARY !== '') {
|
|
return APP_DOMAIN_PRIMARY;
|
|
}
|
|
if (defined('APP_DOMAIN_NAME') && APP_DOMAIN_NAME !== '') {
|
|
return APP_DOMAIN_NAME;
|
|
}
|
|
return null;
|
|
}
|
|
}
|