Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StartTLS for LDAP Identities plugin #1445

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions plugins/ldap-identities/LdapConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class LdapConfig
{
public const CONFIG_SERVER = "server";
public const CONFIG_PROTOCOL_VERSION = "server_version";
public const CONFIG_STARTTLS = "starttls";

public const CONFIG_BIND_USER = "bind_user";
public const CONFIG_BIND_PASSWORD = "bind_password";
Expand All @@ -28,6 +29,7 @@ class LdapConfig

public $server;
public $protocol;
public $starttls;
public $bind_user;
public $bind_password;
public $user_base;
Expand All @@ -48,6 +50,7 @@ public static function MakeConfig(Plugin $config): LdapConfig
$ldap = new self();
$ldap->server = trim($config->Get("plugin", self::CONFIG_SERVER));
$ldap->protocol = (int)trim($config->Get("plugin", self::CONFIG_PROTOCOL_VERSION, 3));
$ldap->starttls = (bool)trim($config->Get("plugin", self::CONFIG_STARTTLS));
$ldap->bind_user = trim($config->Get("plugin", self::CONFIG_BIND_USER));
$ldap->bind_password = trim($config->Get("plugin", self::CONFIG_BIND_PASSWORD));
$ldap->user_base = trim($config->Get("plugin", self::CONFIG_USER_BASE));
Expand Down
9 changes: 9 additions & 0 deletions plugins/ldap-identities/LdapIdentities.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ private function Connect(): bool
return false;
}

// Activate StartTLS
if ($this->config->starttls) {
$starttlsResult = ldap_start_tls($ldap);
if (!$starttlsResult) {
$this->ldapAvailable = false;
return false;
}
}

$this->ldap = $ldap;
$this->ldapConnected = true;
return true;
Expand Down
10 changes: 8 additions & 2 deletions plugins/ldap-identities/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ class LdapIdentitiesPlugin extends AbstractPlugin
{
const
NAME = 'LDAP Identities',
VERSION = '2.1',
VERSION = '2.2',
AUTHOR = 'FWest98',
URL = 'https://github.com/FWest98',
RELEASE = '2022-11-09',
RELEASE = '2024-02-22',
REQUIRED = '2.20.0',
CATEGORY = 'Accounts',
DESCRIPTION = 'Adds functionality to import account identities from LDAP.';
Expand Down Expand Up @@ -57,6 +57,12 @@ protected function configMapping(): array
->SetLabel("LDAP Protocol Version")
->SetType(PluginPropertyType::SELECTION)
->SetDefaultValue([2, 3]),

Property::NewInstance(LdapConfig::CONFIG_STARTTLS)
->SetLabel("Use StartTLS")
->SetType(PluginPropertyType::BOOL)
->SetDescription("Whether or not to use TLS encrypted connection")
->SetDefaultValue(true),

Property::NewInstance(LdapConfig::CONFIG_BIND_USER)
->SetLabel("Bind User DN")
Expand Down
Loading