feat: unraid single sign on with account app

This commit is contained in:
Eli Bosley
2025-01-20 12:04:26 -05:00
parent 2d3892deb8
commit 2b25537e26
16 changed files with 422 additions and 175 deletions

View File

@@ -0,0 +1,22 @@
<?
/**
* Caveats to get the SSO login button to display
*
* /usr/local/emhttp/auth-request.php must be updated to include the exact URLs of anything that is being loaded.
* Otherwise, the request for the asset will be blocked and redirected to /login.
*
* The modification of these files should be done via the plugin's install script.
*/
require_once("$docroot/plugins/dynamix.my.servers/include/state.php");
require_once("$docroot/plugins/dynamix.my.servers/include/web-components-extractor.php");
$serverState = new ServerState();
$wcExtractor = new WebComponentsExtractor();
echo $wcExtractor->getScriptTagHtml();
?>
<unraid-i18n-host>
<unraid-sso-button server="<?= $serverState->getServerStateJsonForHtmlAttr() ?>"></unraid-sso-button>
</unraid-i18n-host>

View File

@@ -53,6 +53,10 @@ class ServerState
"nokeyserver" => 'NO_KEY_SERVER',
"withdrawn" => 'WITHDRAWN',
];
/**
* SSO Sub IDs from the my servers config file.
*/
private $ssoSubIds = '';
private $osVersion;
private $osVersionBranch;
private $rebootDetails;
@@ -193,6 +197,7 @@ 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'] ?? '';
}
private function getConnectKnownOrigins() {
@@ -321,6 +326,7 @@ 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) {