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

[1.0.0] Various server updates. #84

Open
wants to merge 5 commits into
base: 1.0
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest]
php-versions: ['8.1', '8.2']
php-versions: ['8.1', '8.2', '8.3']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand Down
6 changes: 6 additions & 0 deletions src/FreeDSx/Ldap/ClientOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ final class ClientOptions

private int $port = 389;

/**
* @var 'tcp'|'udp'|'unix'
*/
private string $transport = 'tcp';

private ?string $baseDn = null;
Expand Down Expand Up @@ -127,6 +130,9 @@ public function getTransport(): string
return $this->transport;
}

/**
* @param 'tcp'|'udp'|'unix' $transport
*/
public function setTransport(string $transport): self
{
$this->transport = $transport;
Expand Down
20 changes: 11 additions & 9 deletions src/FreeDSx/Ldap/LdapUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public static function parse(string $ldapUrl): LdapUrl
}

/**
* @return array{scheme: ?string, path: ?string, query: ?string, host: ?string, port: ?string}
* @return array{scheme: 'ldap'|'ldaps', host?: string, port?: int<0, 65535>, user?: string, pass?: string, path?: ?string, query?: ?string, fragment?: string}
* @throws UrlParseException
*/
private static function explodeUrl(string $url): array
Expand All @@ -269,27 +269,30 @@ private static function explodeUrl(string $url): array
}
$query = null;
$path = null;
$raw_path = $matches[2] ?? null;

# Check for query parameters but no path...
if (strlen($matches[2]) > 0 && $matches[2][0] === '?') {
$query = substr($matches[2], 1);
if (is_string($raw_path) && strlen($raw_path) > 0 && $raw_path[0] === '?') {
$query = substr($raw_path, 1);
# Check if there are any query parameters and a possible path...
} elseif (str_contains($matches[2], '?')) {
$parts = explode('?', $matches[2], 2);
} elseif (is_string($raw_path) && str_contains($raw_path, '?')) {
$parts = explode('?', $raw_path, 2);
$path = $parts[0];
$query = $parts[1] ?? null;
# A path only...
} else {
$path = $matches[2];
$path = $raw_path;
}

$pieces = [
'scheme' => $matches[1],
'scheme' => $matches[1] ?? null,
'path' => $path,
'query' => $query,
];
}
$pieces['scheme'] = strtolower($pieces['scheme']);
$pieces['scheme'] = isset($pieces['scheme'])
? strtolower($pieces['scheme'])
: '';

if (!($pieces['scheme'] === 'ldap' || $pieces['scheme'] === 'ldaps')) {
throw new UrlParseException(sprintf(
Expand All @@ -298,7 +301,6 @@ private static function explodeUrl(string $url): array
));
}

/** @phpstan-ignore-next-line */
return $pieces;
}

Expand Down
6 changes: 6 additions & 0 deletions src/FreeDSx/Ldap/ServerOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ final class ServerOptions

private string $unixSocket = '/var/run/ldap.socket';

/**
* @var 'tcp'|'udp'|'unix'
*/
private string $transport = 'tcp';

private int $idleTimeout = 600;
Expand Down Expand Up @@ -105,6 +108,9 @@ public function getTransport(): string
return $this->transport;
}

/**
* @param 'tcp'|'udp'|'unix' $transport
*/
public function setTransport(string $transport): self
{
$this->transport = $transport;
Expand Down
Loading