mirror of
https://github.com/unraid/api.git
synced 2026-05-25 11:39:52 -05:00
feat: move ssoenabled to a boolean flag rather than ids
This commit is contained in:
+1
-1
@@ -18,5 +18,5 @@ echo $wcExtractor->getScriptTagHtml();
|
||||
?>
|
||||
|
||||
<unraid-i18n-host>
|
||||
<unraid-sso-button subids="<?= $serverState->ssoSubIds ?>"></unraid-sso-button>
|
||||
<unraid-sso-button ssoenabled="<?= $serverState->ssoEnabled ?>"></unraid-sso-button>
|
||||
</unraid-i18n-host>
|
||||
+25
-16
@@ -8,6 +8,7 @@
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo refactor globals – currently if you try to use $GLOBALS the class will break.
|
||||
*/
|
||||
@@ -56,7 +57,7 @@ class ServerState
|
||||
/**
|
||||
* SSO Sub IDs from the my servers config file.
|
||||
*/
|
||||
public $ssoSubIds = '';
|
||||
public $ssoEnabled = false;
|
||||
private $osVersion;
|
||||
private $osVersionBranch;
|
||||
private $rebootDetails;
|
||||
@@ -71,7 +72,7 @@ class ServerState
|
||||
public $myServersMemoryCfg = [];
|
||||
public $host = 'unknown';
|
||||
public $combinedKnownOrigins = [];
|
||||
|
||||
|
||||
public $nginxCfg = [];
|
||||
public $flashbackupStatus = [];
|
||||
public $registered = false;
|
||||
@@ -90,7 +91,7 @@ class ServerState
|
||||
* @see - getWebguiGlobal() for usage
|
||||
* */
|
||||
global $webguiGlobals;
|
||||
$this->webguiGlobals =& $webguiGlobals;
|
||||
$this->webguiGlobals = &$webguiGlobals;
|
||||
// echo "<pre>" . json_encode($this->webguiGlobals, JSON_PRETTY_PRINT) . "</pre>";
|
||||
|
||||
$this->var = (array)parse_ini_file('state/var.ini');
|
||||
@@ -123,7 +124,8 @@ class ServerState
|
||||
/**
|
||||
* Retrieve the value of a webgui global setting.
|
||||
*/
|
||||
public function getWebguiGlobal(string $key, string $subkey = null) {
|
||||
public function getWebguiGlobal(string $key, string $subkey = null)
|
||||
{
|
||||
if (!$subkey) {
|
||||
return _var($this->webguiGlobals, $key, '');
|
||||
}
|
||||
@@ -131,7 +133,8 @@ class ServerState
|
||||
return _var($keyArray, $subkey, '');
|
||||
}
|
||||
|
||||
private function setConnectValues() {
|
||||
private function setConnectValues()
|
||||
{
|
||||
if (file_exists('/var/lib/pkgtools/packages/dynamix.unraid.net')) {
|
||||
$this->connectPluginInstalled = 'dynamix.unraid.net.plg';
|
||||
}
|
||||
@@ -158,13 +161,15 @@ class ServerState
|
||||
$this->getFlashBackupStatus();
|
||||
}
|
||||
|
||||
private function getFlashBackupStatus() {
|
||||
private function getFlashBackupStatus()
|
||||
{
|
||||
$flashbackupCfg = '/var/local/emhttp/flashbackup.ini';
|
||||
$this->flashbackupStatus = (file_exists($flashbackupCfg)) ? @parse_ini_file($flashbackupCfg) : [];
|
||||
$this->flashBackupActivated = empty($this->flashbackupStatus['activated']) ? '' : 'true';
|
||||
}
|
||||
|
||||
private function getMyServersCfgValues() {
|
||||
private function getMyServersCfgValues()
|
||||
{
|
||||
/**
|
||||
* @todo can we read this from somewhere other than the flash? Connect page uses this path and /boot/config/plugins/dynamix.my.servers/myservers.cfg…
|
||||
* - $myservers_memory_cfg_path ='/var/local/emhttp/myservers.cfg';
|
||||
@@ -197,10 +202,11 @@ class ServerState
|
||||
$this->registered = !empty($this->myServersFlashCfg['remote']['apikey']) && $this->connectPluginInstalled;
|
||||
$this->registeredTime = $this->myServersFlashCfg['remote']['regWizTime'] ?? '';
|
||||
$this->username = $this->myServersFlashCfg['remote']['username'] ?? '';
|
||||
$this->ssoSubIds = $this->myServersFlashCfg['remote']['ssoSubIds'] ?? '';
|
||||
$this->ssoEnabled = $this->myServersFlashCfg['remote']['ssoSubIds'] !== '';
|
||||
}
|
||||
|
||||
private function getConnectKnownOrigins() {
|
||||
private function getConnectKnownOrigins()
|
||||
{
|
||||
/**
|
||||
* Allowed origins warning displayed when the current webGUI URL is NOT included in the known lists of allowed origins.
|
||||
* Include localhost in the test, but only display HTTP(S) URLs that do not include localhost.
|
||||
@@ -208,7 +214,7 @@ class ServerState
|
||||
$this->host = $_SERVER['HTTP_HOST'] ?? "unknown";
|
||||
$memoryCfgPath = '/var/local/emhttp/myservers.cfg';
|
||||
$this->myServersMemoryCfg = (file_exists($memoryCfgPath)) ? @parse_ini_file($memoryCfgPath) : [];
|
||||
$this->myServersMiniGraphConnected = (($this->myServersMemoryCfg['minigraph']??'') === 'CONNECTED');
|
||||
$this->myServersMiniGraphConnected = (($this->myServersMemoryCfg['minigraph'] ?? '') === 'CONNECTED');
|
||||
|
||||
$allowedOrigins = $this->myServersMemoryCfg['allowedOrigins'] ?? "";
|
||||
$extraOrigins = $this->myServersFlashCfg['api']['extraOrigins'] ?? "";
|
||||
@@ -224,8 +230,8 @@ class ServerState
|
||||
$this->combinedKnownOrigins = explode(",", $combinedOrigins);
|
||||
|
||||
if ($this->combinedKnownOrigins) {
|
||||
foreach($this->combinedKnownOrigins as $key => $origin) {
|
||||
if ( (strpos($origin, "http") === false) || (strpos($origin, "localhost") !== false) ) {
|
||||
foreach ($this->combinedKnownOrigins as $key => $origin) {
|
||||
if ((strpos($origin, "http") === false) || (strpos($origin, "localhost") !== false)) {
|
||||
// clean up $this->combinedKnownOrigins, only display warning if origins still remain to display
|
||||
unset($this->combinedKnownOrigins[$key]);
|
||||
}
|
||||
@@ -238,7 +244,8 @@ class ServerState
|
||||
}
|
||||
}
|
||||
|
||||
private function detectActivationCode() {
|
||||
private function detectActivationCode()
|
||||
{
|
||||
// Fresh server and we're not loading with a callback param to install
|
||||
if ($this->state !== 'ENOKEYFILE' || !empty($_GET['c'])) {
|
||||
return;
|
||||
@@ -312,6 +319,7 @@ class ServerState
|
||||
"registered" => $this->registered,
|
||||
"registeredTime" => $this->registeredTime,
|
||||
"site" => _var($_SERVER, 'REQUEST_SCHEME') . "://" . _var($_SERVER, 'HTTP_HOST'),
|
||||
"ssoEnabled" => $this->ssoEnabled,
|
||||
"state" => $this->state,
|
||||
"theme" => [
|
||||
"banner" => !empty($this->getWebguiGlobal('display', 'banner')),
|
||||
@@ -326,7 +334,6 @@ class ServerState
|
||||
"uptime" => 1000 * (time() - round(strtok(exec("cat /proc/uptime"), ' '))),
|
||||
"username" => $this->username,
|
||||
"wanFQDN" => @$this->nginxCfg['NGINX_WANFQDN'] ?? '',
|
||||
"ssoSubIds" => $this->ssoSubIds
|
||||
];
|
||||
|
||||
if ($this->combinedKnownOrigins) {
|
||||
@@ -357,7 +364,8 @@ class ServerState
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServerStateJson() {
|
||||
public function getServerStateJson()
|
||||
{
|
||||
return json_encode($this->getServerState());
|
||||
}
|
||||
|
||||
@@ -366,7 +374,8 @@ class ServerState
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getServerStateJsonForHtmlAttr() {
|
||||
public function getServerStateJsonForHtmlAttr()
|
||||
{
|
||||
$json = json_encode($this->getServerState());
|
||||
return htmlspecialchars($json, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user