CiscoDevNet / iPSK-Manager

Identity PSK (IPSK) Manager for Cisco ISE provides an example of how to manage the full Life Cycle of Wi-Fi Pre Shared Keys for supported Hardware/Software through Cisco ISE.
Apache License 2.0
30 stars 16 forks source link

How to upgrade #27

Closed GD-Dal closed 9 months ago

GD-Dal commented 10 months ago

Hi. I see there is a new version now. How do I upgrade to this new version without breaking existing installation?

Thanks

ciesinsn commented 10 months ago

@GD-Dal If you didn't make any modifications to the code you should just be able to pull the latest version as no DB changes took place. Note, you'll need to remove the initial installer.php and installer.inc.php file that will re-install when you pull the latest version.

GD-Dal commented 10 months ago

Thanks, but how do I remove 2 files from a pull?

ciesinsn commented 10 months ago

I'd just manually remove them after you pull the code down.

GD-Dal commented 10 months ago

I did a pull, and now the site isn't working. It just displays a lot of text: set_encryptionKey($encryptionKey); //START-[DO NOT REMOVE] - EMPTIES/REMOVES ENCRYTION KEY/DB PASSWORD VARIABLE $encryptionKey = ""; $dbPassword = ""; unset($encryptionKey); unset($dbPassword); //END-[DO NOT REMOVE] - EMPTIES/REMOVES ENCRYTION KEY/DB PASSWORD VARIABLE //START-[DO NOT REMOVE] - REMOVES PASSWORD FROM $_POST $inputPassword = (isset($_POST['inputPassword'])) ? $_POST['inputPassword'] : ''; unset($_POST["inputPassword"]); //END-[DO NOT REMOVE] - REMOVES PASSWORD FROM $_POST //System Sid Variable $systemSID = $baseSid."-".$orgSid."-".$systemSid; $sanitizedInput = sanitizeGetModuleInput($subModuleRegEx); //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:SUCCESS;ACTION:ADMINLOGIN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); if($sanitizedInput["inputUsername"] != "" && $inputPassword != "" && is_numeric($sanitizedInput["authDirectory"])){ if($sanitizedInput['authDirectory'] == "0"){ if($ipskISEDB->authenticateInternalUser($sanitizedInput["inputUsername"], $inputPassword)){ $authorizedGroups = $ipskISEDB->getPortalAdminGroups(); //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:SUCCESS;ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); if($authorizedGroups['count'] > 0){ for($count = 0; $count < $authorizedGroups['count']; $count++){ for($userCount = 0; $userCount < $_SESSION['memberOf']['count']; $userCount++){ if($authorizedGroups[$count] == $_SESSION['memberOf'][$userCount]){ $_SESSION['authorizationGroup'] = $authorizedGroups[$count]; $_SESSION['authorizationGranted'] = true; $_SESSION['authorizationTimestamp'] = time(); //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:SUCCESS;ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); $ipskISEDB->addUserCacheEntry($_SESSION['logonSID'],$_SESSION['userPrincipalName'],$_SESSION['sAMAccountName'],$_SESSION['logonDN'], $systemSID); header("Location: /adminportal.php"); die(); } } } //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{1}[user_authz_failure];ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=1"); }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{2}[no_authz_groups];ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=2"); } }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{3}[user_authn_failure];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=3"); } }else{ if(is_numeric($sanitizedInput["authDirectory"])){ if($ipskISEDB->getLdapDirectoryCount() > 0){ $ldapCreds = $ipskISEDB->getLdapSettings($sanitizedInput["authDirectory"]); if($ldapCreds){ $ldapClass = New BaseLDAPInterface($ldapCreds['adServer'], $ldapCreds['adDomain'], $ldapCreds['adUsername'], $ldapCreds['adPassword'], $ldapCreds['adBaseDN'], $ldapCreds['adSecure'], $ipskISEDB); //START-[DO NOT REMOVE] - REMOVES PASSWORD FROM $ldapCreds unset($ldapCreds['adPassword']); //END-[DO NOT REMOVE] - REMOVES PASSWORD FROM $ldapCreds $authorizedGroups = $ipskISEDB->getPortalAdminGroups(); $validUser = $ldapClass->authenticateUser($sanitizedInput["inputUsername"], $inputPassword); if($validUser){ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("ldapCreds"=>$ldapCreds), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:SUCCESS;ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); if($authorizedGroups['count'] > 0){ for($count = 0; $count < $authorizedGroups['count']; $count++){ for($userCount = 0; $userCount < $_SESSION['memberOf']['count']; $userCount++){ if($authorizedGroups[$count] == $_SESSION['memberOf'][$userCount]){ $_SESSION['authorizationGroup'] = $authorizedGroups[$count]; $_SESSION['authorizationGranted'] = true; $_SESSION['authorizationTimestamp'] = time(); //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("ldapCreds"=>$ldapCreds), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:SUCCESS;ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); $ipskISEDB->addUserCacheEntry($_SESSION['logonSID'],$_SESSION['userPrincipalName'],$_SESSION['sAMAccountName'],$_SESSION['logonDN'], $systemSID); header("Location: /adminportal.php"); die(); } } } //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("ldapCreds"=>$ldapCreds), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{1}[user_authz_failure];ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";".$authorizedGroups['count'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=1"); }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("ldapCreds"=>$ldapCreds), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{2}[no_authz_groups];ACTION:ADMINAUTHZ;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=2"); } }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("authorizedGroups"=>$authorizedGroups), Array("ldapCreds"=>$ldapCreds), Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{3}[user_authn_failure];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=3"); } }else{ //START-[DO NOT REMOVE] - REMOVES PASSWORD FROM $ldapCreds unset($ldapCreds['adPassword']); //END-[DO NOT REMOVE] - REMOVES PASSWORD FROM $ldapCreds //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{4}[invalid_ldap_directory];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=4"); } }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{5}[no_valid_auth_directories];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=5"); } }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{6}[invalid_auth_directory_input];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=6"); } } }else{ //LOG::Entry $logData = $ipskISEDB->generateLogData(Array("sanitizedInput"=>$sanitizedInput)); $logMessage = "REQUEST:FAILURE{7}[invalid_form_input];ACTION:ADMINAUTHN;USERNAME:".$sanitizedInput["inputUsername"].";AUTHDIRECTORY:".$sanitizedInput['authDirectory'].";"; $ipskISEDB->addLogEntry($logMessage, __FILE__, __FUNCTION__, __CLASS__, __METHOD__, __LINE__, $logData); header("Location: /index.php?error=7"); } ?>

Is there something else that needs to be done?

ciesinsn commented 10 months ago

That looks like what would happen if your web server wasn't set to render php files properly. Just moving files shouldn't have impacted anything with your web config. Are you able to look at the web config?

GD-Dal commented 10 months ago

I think something went really bad when Ubuntu was upgraded from v20 to v22 Where is the web config located?

GD-Dal commented 10 months ago

I renamed the IPSK-manager directory and did a new git clone. This is how the login page looks like now:

bilde

ciesinsn commented 10 months ago

I assume you're using apache as the web server? Should be in like /etc/apache2 directory. You should look to make sure the PHP module is being loaded and not commented out.

GD-Dal commented 10 months ago

Yeah, it seems that PHP does not work on the server anymore. I have tried several guides on how to uninstall / purge apache2 and php, but nothing works. Probably have to reinstall the server it seems

GD-Dal commented 10 months ago

FINALLY got it to work. I noticed that php8.3 was in /etc/apache2/mods-available but not int /etc/apache2/mods-enabled

So I manually created 2 symlinks:

sudo ln -s /etc/apache2/mods-available/php8.3.conf /etc/apache2/mods-enabled/
sudo ln -s /etc/apache2/mods-available/php8.3.load /etc/apache2/mods-enabled/

and ran

sudo service apache2 restart

Which gave me the error:

apachectl[1807]: [Wed Nov 29 13:48:27.603178 2023] [php:crit] [pid 1807:tid 140525227964288] Apache is running a threaded MPM, but your PHP Module is not compiled to be threadsafe. You need to recompile PHP.

So after some searching on the internet, I did:

sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restart

And so far it seems to work just fine with Ubuntu 22.04 and PHP 8.3 :)

ciesinsn commented 9 months ago

Good to hear, I'm going to close this issue then :)