MCPcopy Create free account
hub / github.com/error311/FileRise / getConfig

Method getConfig

src/FileRise/Domain/AdminModel.php:942–1345  ·  view source on GitHub ↗

* Retrieves the current configuration. * * @return array The configuration array, or defaults if not found. */

()

Source from the content-addressed store, hash-verified

940 * @return array The configuration array, or defaults if not found.
941 */
942 public static function getConfig(): array
943 {
944 $configFile = USERS_DIR . 'adminConfig.json';
945
946 if (file_exists($configFile)) {
947 $encryptedContent = file_get_contents($configFile);
948 $decryptedContent = decryptData($encryptedContent, $GLOBALS['encryptionKey']);
949 if ($decryptedContent === false) {
950 clearstatcache(true, $configFile);
951 $retryContent = @file_get_contents($configFile);
952 if (is_string($retryContent) && $retryContent !== '') {
953 $encryptedContent = $retryContent;
954 $decryptedContent = decryptData($encryptedContent, $GLOBALS['encryptionKey']);
955 }
956 }
957
958 if ($decryptedContent === false) {
959 $rawConfig = json_decode((string)$encryptedContent, true);
960 if (is_array($rawConfig)) {
961 $config = $rawConfig;
962 } else {
963 // Do not set HTTP status here; let the controller decide.
964 return ["error" => "Failed to decrypt configuration."];
965 }
966 } else {
967 $config = json_decode($decryptedContent, true);
968 }
969
970 if (!is_array($config)) {
971 $config = [];
972 }
973
974 // Normalize login options if missing
975 if (!isset($config['loginOptions'])) {
976 // Migrate legacy top-level flags; default OIDC to true (disabled)
977 $config['loginOptions'] = [
978 'disableFormLogin' => isset($config['disableFormLogin']) ? (bool)$config['disableFormLogin'] : false,
979 'disableBasicAuth' => isset($config['disableBasicAuth']) ? (bool)$config['disableBasicAuth'] : false,
980 'disableOIDCLogin' => isset($config['disableOIDCLogin']) ? (bool)$config['disableOIDCLogin'] : true,
981 ];
982 unset($config['disableFormLogin'], $config['disableBasicAuth'], $config['disableOIDCLogin']);
983 } else {
984 // Normalize booleans; default OIDC to true (disabled) if missing
985 $lo = &$config['loginOptions'];
986 $lo['disableFormLogin'] = isset($lo['disableFormLogin']) ? (bool)$lo['disableFormLogin'] : false;
987 $lo['disableBasicAuth'] = isset($lo['disableBasicAuth']) ? (bool)$lo['disableBasicAuth'] : false;
988 $lo['disableOIDCLogin'] = isset($lo['disableOIDCLogin']) ? (bool)$lo['disableOIDCLogin'] : true;
989 }
990
991 // Ensure OIDC structure exists
992 if (!isset($config['oidc']) || !is_array($config['oidc'])) {
993 $config['oidc'] = [
994 'providerUrl' => '',
995 'clientId' => '',
996 'clientSecret' => '',
997 'redirectUri' => '',
998 'groupClaim' => '',
999 'extraScopes' => '',

Callers 10

webdav.phpFile · 0.45
getConfig.phpFile · 0.45
oidcDebugInfo.phpFile · 0.45
resumableTtlSecondsMethod · 0.45
isVirusScanEnabledMethod · 0.45
isOidcDemoteAllowedMethod · 0.45

Calls 13

parseSizeMethod · 0.95
sanitizeHttpUrlMethod · 0.95
sanitizeLogoUrlMethod · 0.95
sanitizeColorHexMethod · 0.95
sanitizeCssBackgroundMethod · 0.95
sanitizeTaglineMethod · 0.95
sanitizeFooterHtmlMethod · 0.95
sanitizeIgnoreRegexMethod · 0.95
decryptDataFunction · 0.85

Tested by

no test coverage detected