Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Nov 2, 2023
1 parent 1cc36bb commit 9bb0e19
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 41 deletions.
7 changes: 2 additions & 5 deletions lam/lib/2factor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,6 @@ class DuoProvider extends BaseProvider {
logNewMessage(LOG_ERR, 'DUO error: ' . $e->getMessage());
return false;
}
logNewMessage(LOG_ERR, 'DUO authentication failed');
return false;
}

/**
Expand Down Expand Up @@ -833,11 +831,10 @@ class OpenIdProvider extends BaseProvider {
$meta['redirect_uri'] = $_GET['redirect_uri'];
}
$clientMetadata = \Facile\OpenIDClient\Client\Metadata\ClientMetadata::fromArray($meta);
$client = (new \Facile\OpenIDClient\Client\ClientBuilder())
return (new \Facile\OpenIDClient\Client\ClientBuilder())
->setIssuer($issuer)
->setClientMetadata($clientMetadata)
->build();
return $client;
}

/**
Expand Down Expand Up @@ -1323,7 +1320,7 @@ class TwoFactorConfiguration {
/**
* @var string|array service URL(s)
*/
public $twoFactorAuthenticationURL = null;
public $twoFactorAuthenticationURL;

/**
* @var bool disable certificate check
Expand Down
6 changes: 1 addition & 5 deletions lam/lib/account.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ function getLastLDAPError() {
// all ok
case 0:
return null;
break;
// size limit exceeded
case 4:
$error = array("WARN", _("LDAP sizelimit exceeded, not all entries are shown."));
Expand All @@ -1133,11 +1132,9 @@ function getLastLDAPError() {
$error[] = _("See the manual for instructions to solve this problem.");
}
return $error;
break;
// other errors
default:
return array("ERROR", _("LDAP search failed! Please check your preferences."), ldap_error($_SESSION["ldap"]->server()));
break;
}
}

Expand Down Expand Up @@ -1387,8 +1384,7 @@ function extractRDN(?string $dn): ?string {
return null;
}
$rdn = unescapeLdapSpecialCharacters($parts[0]);
$rdn = str_replace(',', '\\2C', $rdn);
return $rdn;
return str_replace(',', '\\2C', $rdn);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lam/lib/baseModule.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use LAM\PDF\PDFImage;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2021 Roland Gruber
Copyright (C) 2003 - 2023 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -163,7 +163,6 @@ abstract class baseModule {
* @param array $attributes array like the array returned by get_ldap_attributes(dn of account) but without count indices
*/
public function load_attributes($attributes) {
$this->attributes = array();
$this->attributes = array();
// load object classes
if (isset($attributes['objectClass'])) {
Expand Down
35 changes: 16 additions & 19 deletions lam/lib/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1110,33 +1110,33 @@ class LAMConfig {
private $pwdResetDefaultPasswordOutput = LAMconfig::PWDRESET_DEFAULT_MAIL;

/** LDAP user for jobs */
private $jobsBindUser = null;
private $jobsBindUser;
/** LDAP password for jobs */
private $jobsBindPassword = null;
private $jobsBindPassword;
/** database type for jobs */
private $jobsDatabase = null;
private $jobsDatabase;
/** host of job database */
private $jobsDBHost = null;
private $jobsDBHost;
/** port of job database */
private $jobsDBPort = null;
private $jobsDBPort;
/** user of job database */
private $jobsDBUser = null;
private $jobsDBUser;
/** password of job database */
private $jobsDBPassword = null;
private $jobsDBPassword;
/** name of job database */
private $jobsDBName = null;
private $jobsDBName;
/** random job token */
private $jobToken = null;
private $jobToken;
/** job configuration */
private $jobSettings = array();

private $twoFactorAuthentication = TwoFactorProviderService::TWO_FACTOR_NONE;
private $twoFactorAuthenticationURL = 'https://localhost';
private $twoFactorAuthenticationClientId = null;
private $twoFactorAuthenticationSecretKey = null;
private $twoFactorAuthenticationDomain = null;
private $twoFactorAuthenticationClientId;
private $twoFactorAuthenticationSecretKey;
private $twoFactorAuthenticationDomain;
private $twoFactorAuthenticationInsecure = false;
private $twoFactorAuthenticationLabel = null;
private $twoFactorAuthenticationLabel;
private $twoFactorAuthenticationOptional = false;
private $twoFactorAuthenticationCaption = '';
private $twoFactorAuthenticationAttribute = '';
Expand Down Expand Up @@ -3067,13 +3067,13 @@ class LAMCfgMain {
public $passwordMustNotContain3Chars = 'false';

/** external URL for password checking (e.g. https://domain.com/url/{SHA1}) */
public $externalPwdCheckUrl = null;
public $externalPwdCheckUrl;

/** path to config file */
private $conffile;

/** uploaded SSL certificate that is stored to disk on save() */
private $uploadedSSLCaCert = null;
private $uploadedSSLCaCert;

/** SSL certificate should be deleted on save() */
private $delSSLCaCert = false;
Expand Down Expand Up @@ -3238,9 +3238,7 @@ class LAMCfgMain {
public function importCertificates($certsContent) {
$fileName = $this->getSSLCaCertPath();
if (empty($certsContent)) {
if ($fileName !== null) {
unlink($fileName);
}
unlink($fileName);
return;
}
$fileName = $this->getInternalSSLCaCertFileName();
Expand Down Expand Up @@ -3696,7 +3694,6 @@ class LAMCfgMain {
logNewMessage(LOG_ERR, 'Unable to store SSL CA file: ' . $e->getTitle());
return null;
}
return null;
}

/**
Expand Down
10 changes: 0 additions & 10 deletions lam/lib/createntlm.inc
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
array( 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8),
array( 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11)));

/**
* Fixes too large numbers
*/
private function x($i) {
if ($i < 0) return 4294967296 - $i;
else return $i;
}

/**
* @param integer count
* @param array $data
Expand Down Expand Up @@ -371,5 +363,3 @@ private $sbox = array(array(array(14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12
}

}

?>

0 comments on commit 9bb0e19

Please sign in to comment.