mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Merge branch 'integrations/rc5-4-2020-08-31-dev-into-master' into develop
This commit is contained in:
commit
b258f34bce
|
@ -57,7 +57,7 @@ class LdapAd extends LdapAdConfiguration
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
// Already initialized
|
// Already initialized
|
||||||
if($this->ldap) {
|
if ($this->ldap) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,19 @@ class LdapAdConfiguration
|
||||||
* @since 5.0.0
|
* @since 5.0.0
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
$this->ldapSettings = $this->getSnipeItLdapSettings();
|
|
||||||
if ($this->isLdapEnabled()) {
|
// This try/catch is dumb, but is necessary to run initial migrations, since
|
||||||
$this->setSnipeItConfig();
|
// this service provider is booted even during migrations. :( - snipe
|
||||||
|
try {
|
||||||
|
$this->ldapSettings = $this->getSnipeItLdapSettings();
|
||||||
|
if ($this->isLdapEnabled()) {
|
||||||
|
$this->setSnipeItConfig();
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\Log::debug($e);
|
||||||
|
$this->ldapSettings = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,33 +91,35 @@ class LdapAdConfiguration
|
||||||
*/
|
*/
|
||||||
private function getSnipeItLdapSettings(): Collection
|
private function getSnipeItLdapSettings(): Collection
|
||||||
{
|
{
|
||||||
$ldapSettings = Setting::getLdapSettings()
|
$ldapSettings = collect();
|
||||||
->map(function ($item, $key) {
|
if(Setting::first()) { // during early migration steps, there may be no settings table entry to start with
|
||||||
// Trim the items
|
$ldapSettings = Setting::getLdapSettings()
|
||||||
if (is_string($item)) {
|
->map(function ($item, $key) {
|
||||||
$item = trim($item);
|
// Trim the items
|
||||||
}
|
if (is_string($item)) {
|
||||||
// Get the boolean value of the LDAP setting, makes it easier to work with them
|
$item = trim($item);
|
||||||
if (in_array($key, self::LDAP_BOOLEAN_SETTINGS)) {
|
}
|
||||||
return boolval($item);
|
// Get the boolean value of the LDAP setting, makes it easier to work with them
|
||||||
}
|
if (in_array($key, self::LDAP_BOOLEAN_SETTINGS)) {
|
||||||
|
return boolval($item);
|
||||||
// Decrypt the admin password
|
|
||||||
if ('ldap_pword' === $key && !empty($item)) {
|
|
||||||
try {
|
|
||||||
return decrypt($item);
|
|
||||||
} catch (Exception $e) {
|
|
||||||
throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($item && 'ldap_server' === $key) {
|
// Decrypt the admin password
|
||||||
return collect(parse_url($item));
|
if ('ldap_pword' === $key && !empty($item)) {
|
||||||
}
|
try {
|
||||||
|
return decrypt($item);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new Exception('Your app key has changed! Could not decrypt LDAP password using your current app key, so LDAP authentication has been disabled. Login with a local account, update the LDAP password and re-enable it in Admin > Settings.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $item;
|
if ($item && 'ldap_server' === $key) {
|
||||||
});
|
return collect(parse_url($item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
}
|
||||||
return $ldapSettings;
|
return $ldapSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class AddAdAppendDomainSettings extends Migration
|
||||||
});
|
});
|
||||||
|
|
||||||
$s = Setting::first(); // we are deliberately *not* using the ::getSettings() method, as it caches things, and our Settings table is being migrated right now
|
$s = Setting::first(); // we are deliberately *not* using the ::getSettings() method, as it caches things, and our Settings table is being migrated right now
|
||||||
if($s->is_ad && $s->ldap_enabled && $s->ad_domain) { //backwards-compatibility setting; < v5 always appended AD Domains
|
if ($s && $s->is_ad && $s->ldap_enabled && $s->ad_domain) { //backwards-compatibility setting; < v5 always appended AD Domains
|
||||||
$s->ad_append_domain = 1;
|
$s->ad_append_domain = 1;
|
||||||
$s->save();
|
$s->save();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue