mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 11:12:15 +02:00
I know people say not to add vendor/ to git, but this is the --no-dev variant, and it should handle autoloading too ...
This commit is contained in:
parent
9436e9e887
commit
192ef87378
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,5 @@
|
||||
/config.local.php
|
||||
/templates_c/*.tpl.php
|
||||
/templates_c/*menu.conf.php
|
||||
/vendor/
|
||||
/.php_cs.cache
|
||||
/.idea
|
||||
/composer.lock
|
||||
|
7
composer-update.sh
Normal file
7
composer-update.sh
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# for github :
|
||||
composer update --no-dev
|
||||
|
||||
# for local testing/dev:
|
||||
# composer update
|
@ -3,6 +3,7 @@
|
||||
"description": "web based administration interface for Postfix mail servers",
|
||||
"type": "project",
|
||||
"license": "GPL-2.0",
|
||||
"preferred-install":"dist",
|
||||
"scripts": {
|
||||
"build" : [
|
||||
"@check-format",
|
||||
|
5422
composer.lock
generated
Normal file
5422
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
7
vendor/autoload.php
vendored
Normal file
7
vendor/autoload.php
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5e920e1b3514a635db93d5ba8b8046de::getLoader();
|
477
vendor/composer/ClassLoader.php
vendored
Normal file
477
vendor/composer/ClassLoader.php
vendored
Normal file
@ -0,0 +1,477 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
private $prefixLengthsPsr4 = array();
|
||||
private $prefixDirsPsr4 = array();
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
private $prefixesPsr0 = array();
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
private $useIncludePath = false;
|
||||
private $classMap = array();
|
||||
private $classMapAuthoritative = false;
|
||||
private $missingClasses = array();
|
||||
private $apcuPrefix;
|
||||
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
}
|
||||
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
//no-op
|
||||
} elseif ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
293
vendor/composer/InstalledVersions.php
vendored
Normal file
293
vendor/composer/InstalledVersions.php
vendored
Normal file
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class InstalledVersions
|
||||
{
|
||||
private static $installed = array (
|
||||
'root' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '598f7db2e7efaff2f22d581acc4e9447abce2cea',
|
||||
'name' => 'postfixadmin/postfixadmin',
|
||||
),
|
||||
'versions' =>
|
||||
array (
|
||||
'postfixadmin/password-hashing' =>
|
||||
array (
|
||||
'pretty_version' => '0.0.1',
|
||||
'version' => '0.0.1.0',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => 'dc69ed5ccdd2631b9f002e371355df4ba8dba4f1',
|
||||
),
|
||||
'postfixadmin/postfixadmin' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '598f7db2e7efaff2f22d581acc4e9447abce2cea',
|
||||
),
|
||||
),
|
||||
);
|
||||
private static $canGetVendors;
|
||||
private static $installedByVendor = array();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function isInstalled($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getRawData()
|
||||
{
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
21
vendor/composer/LICENSE
vendored
Normal file
21
vendor/composer/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
29
vendor/composer/autoload_classmap.php
vendored
Normal file
29
vendor/composer/autoload_classmap.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'AdminHandler' => $baseDir . '/model/AdminHandler.php',
|
||||
'AdminpasswordHandler' => $baseDir . '/model/AdminpasswordHandler.php',
|
||||
'AliasHandler' => $baseDir . '/model/AliasHandler.php',
|
||||
'AliasdomainHandler' => $baseDir . '/model/AliasdomainHandler.php',
|
||||
'CliDelete' => $baseDir . '/model/CliDelete.php',
|
||||
'CliEdit' => $baseDir . '/model/CliEdit.php',
|
||||
'CliHelp' => $baseDir . '/model/CliHelp.php',
|
||||
'CliScheme' => $baseDir . '/model/CliScheme.php',
|
||||
'CliView' => $baseDir . '/model/CliView.php',
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'Config' => $baseDir . '/model/Config.php',
|
||||
'DomainHandler' => $baseDir . '/model/DomainHandler.php',
|
||||
'FetchmailHandler' => $baseDir . '/model/FetchmailHandler.php',
|
||||
'Login' => $baseDir . '/model/Login.php',
|
||||
'MailboxHandler' => $baseDir . '/model/MailboxHandler.php',
|
||||
'PFACrypt' => $baseDir . '/model/PFACrypt.php',
|
||||
'PFAHandler' => $baseDir . '/model/PFAHandler.php',
|
||||
'PFASmarty' => $baseDir . '/model/PFASmarty.php',
|
||||
'Shell' => $baseDir . '/model/Shell.php',
|
||||
'VacationHandler' => $baseDir . '/model/VacationHandler.php',
|
||||
);
|
12
vendor/composer/autoload_files.php
vendored
Normal file
12
vendor/composer/autoload_files.php
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'af5a69d2938b2214fcb6ebe9525f13cb' => $baseDir . '/config.inc.php',
|
||||
'290119ddccc8e348189d056a158c8589' => $baseDir . '/functions.inc.php',
|
||||
'347f64ab61a9a9678774767a4a2db996' => $baseDir . '/lib/smarty/libs/bootstrap.php',
|
||||
);
|
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
9
vendor/composer/autoload_namespaces.php
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
10
vendor/composer/autoload_psr4.php
vendored
Normal file
10
vendor/composer/autoload_psr4.php
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'PostfixAdmin\\PasswordHashing\\' => array($vendorDir . '/postfixadmin/password-hashing/src'),
|
||||
);
|
75
vendor/composer/autoload_real.php
vendored
Normal file
75
vendor/composer/autoload_real.php
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5e920e1b3514a635db93d5ba8b8046de
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5e920e1b3514a635db93d5ba8b8046de', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5e920e1b3514a635db93d5ba8b8046de', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de::getInitializer($loader));
|
||||
} else {
|
||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->set($namespace, $path);
|
||||
}
|
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php';
|
||||
foreach ($map as $namespace => $path) {
|
||||
$loader->setPsr4($namespace, $path);
|
||||
}
|
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
$loader->addClassMap($classMap);
|
||||
}
|
||||
}
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire5e920e1b3514a635db93d5ba8b8046de($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire5e920e1b3514a635db93d5ba8b8046de($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
}
|
||||
}
|
61
vendor/composer/autoload_static.php
vendored
Normal file
61
vendor/composer/autoload_static.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de
|
||||
{
|
||||
public static $files = array (
|
||||
'af5a69d2938b2214fcb6ebe9525f13cb' => __DIR__ . '/../..' . '/config.inc.php',
|
||||
'290119ddccc8e348189d056a158c8589' => __DIR__ . '/../..' . '/functions.inc.php',
|
||||
'347f64ab61a9a9678774767a4a2db996' => __DIR__ . '/../..' . '/lib/smarty/libs/bootstrap.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'P' =>
|
||||
array (
|
||||
'PostfixAdmin\\PasswordHashing\\' => 29,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'PostfixAdmin\\PasswordHashing\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/postfixadmin/password-hashing/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'AdminHandler' => __DIR__ . '/../..' . '/model/AdminHandler.php',
|
||||
'AdminpasswordHandler' => __DIR__ . '/../..' . '/model/AdminpasswordHandler.php',
|
||||
'AliasHandler' => __DIR__ . '/../..' . '/model/AliasHandler.php',
|
||||
'AliasdomainHandler' => __DIR__ . '/../..' . '/model/AliasdomainHandler.php',
|
||||
'CliDelete' => __DIR__ . '/../..' . '/model/CliDelete.php',
|
||||
'CliEdit' => __DIR__ . '/../..' . '/model/CliEdit.php',
|
||||
'CliHelp' => __DIR__ . '/../..' . '/model/CliHelp.php',
|
||||
'CliScheme' => __DIR__ . '/../..' . '/model/CliScheme.php',
|
||||
'CliView' => __DIR__ . '/../..' . '/model/CliView.php',
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'Config' => __DIR__ . '/../..' . '/model/Config.php',
|
||||
'DomainHandler' => __DIR__ . '/../..' . '/model/DomainHandler.php',
|
||||
'FetchmailHandler' => __DIR__ . '/../..' . '/model/FetchmailHandler.php',
|
||||
'Login' => __DIR__ . '/../..' . '/model/Login.php',
|
||||
'MailboxHandler' => __DIR__ . '/../..' . '/model/MailboxHandler.php',
|
||||
'PFACrypt' => __DIR__ . '/../..' . '/model/PFACrypt.php',
|
||||
'PFAHandler' => __DIR__ . '/../..' . '/model/PFAHandler.php',
|
||||
'PFASmarty' => __DIR__ . '/../..' . '/model/PFASmarty.php',
|
||||
'Shell' => __DIR__ . '/../..' . '/model/Shell.php',
|
||||
'VacationHandler' => __DIR__ . '/../..' . '/model/VacationHandler.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5e920e1b3514a635db93d5ba8b8046de::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
54
vendor/composer/installed.json
vendored
Normal file
54
vendor/composer/installed.json
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "postfixadmin/password-hashing",
|
||||
"version": "0.0.1",
|
||||
"version_normalized": "0.0.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/postfixadmin/pacrypt.git",
|
||||
"reference": "dc69ed5ccdd2631b9f002e371355df4ba8dba4f1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/postfixadmin/pacrypt/zipball/dc69ed5ccdd2631b9f002e371355df4ba8dba4f1",
|
||||
"reference": "dc69ed5ccdd2631b9f002e371355df4ba8dba4f1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "*",
|
||||
"phpunit/phpunit": "^8|^9",
|
||||
"vimeo/psalm": "^4.8"
|
||||
},
|
||||
"time": "2021-10-02T19:03:17+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PostfixAdmin\\PasswordHashing\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"GPL-2.0"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Goodwin",
|
||||
"email": "david@codepoets.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "Routines to generate password hashes, useful for Dovecot or Courier Mail servers",
|
||||
"support": {
|
||||
"issues": "https://github.com/postfixadmin/pacrypt/issues",
|
||||
"source": "https://github.com/postfixadmin/pacrypt/tree/0.0.1"
|
||||
},
|
||||
"install-path": "../postfixadmin/password-hashing"
|
||||
}
|
||||
],
|
||||
"dev": false,
|
||||
"dev-package-names": []
|
||||
}
|
33
vendor/composer/installed.php
vendored
Normal file
33
vendor/composer/installed.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php return array (
|
||||
'root' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '598f7db2e7efaff2f22d581acc4e9447abce2cea',
|
||||
'name' => 'postfixadmin/postfixadmin',
|
||||
),
|
||||
'versions' =>
|
||||
array (
|
||||
'postfixadmin/password-hashing' =>
|
||||
array (
|
||||
'pretty_version' => '0.0.1',
|
||||
'version' => '0.0.1.0',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => 'dc69ed5ccdd2631b9f002e371355df4ba8dba4f1',
|
||||
),
|
||||
'postfixadmin/postfixadmin' =>
|
||||
array (
|
||||
'pretty_version' => 'dev-master',
|
||||
'version' => 'dev-master',
|
||||
'aliases' =>
|
||||
array (
|
||||
),
|
||||
'reference' => '598f7db2e7efaff2f22d581acc4e9447abce2cea',
|
||||
),
|
||||
),
|
||||
);
|
26
vendor/composer/platform_check.php
vendored
Normal file
26
vendor/composer/platform_check.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70200)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
39
vendor/postfixadmin/password-hashing/.github/workflows/php.yml
vendored
Normal file
39
vendor/postfixadmin/password-hashing/.github/workflows/php.yml
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
name: PHP Composer
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate
|
||||
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-progress
|
||||
|
||||
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
|
||||
# Docs: https://getcomposer.org/doc/articles/scripts.md
|
||||
|
||||
- name: Run psalm
|
||||
run: composer run-script psalm
|
||||
|
||||
- name: Run test suite
|
||||
run: composer run-script test
|
339
vendor/postfixadmin/password-hashing/LICENSE
vendored
Normal file
339
vendor/postfixadmin/password-hashing/LICENSE
vendored
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
66
vendor/postfixadmin/password-hashing/README.md
vendored
Normal file
66
vendor/postfixadmin/password-hashing/README.md
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
# PostfixAdmin\PasswordHashing
|
||||
|
||||
Standalone PHP library for creating various password hashes
|
||||
|
||||
Note, this library is still quite new (2021/07/02). It's quite likely to have major refactoring / renaming as it's reviewed.
|
||||
|
||||
|
||||
## Supported Mechanisms (hash formats)
|
||||
|
||||
See : https://github.com/postfixadmin/pacrypt/blob/46ddd21a28433faa8ea279e4161f7853a69b40cb/src/Crypt.php#L12
|
||||
|
||||
Some mechanisms support either HEX (.HEX) encoded or BASE64 (.B64) encoded output.
|
||||
|
||||
Currently :
|
||||
|
||||
* SHA1, SHA1.HEX, SHA1.B64
|
||||
* SSHA
|
||||
* BLF-CRYPT, BLF-CRYPT.B64
|
||||
* SHA512-CRYPT, SHA512-CRYPT.B64
|
||||
* ARGON2I, ARGON2I.B64
|
||||
* ARGON2ID, ARGON2ID.B64
|
||||
* SHA256, SHA256-CRYPT, SHA256-CRYPT.B64
|
||||
* SHA512, SHA512.B64
|
||||
* MD5-CRYPT, MD5
|
||||
* PLAIN-MD5
|
||||
* CRYPT ({CRYPT} prefix, defaults to use Blowfish)
|
||||
* SYSTEM (DES CRYPT, best avoid)
|
||||
* PLAIN, CLEAR, CLEARTEXT (useful for testing)
|
||||
* COURIER:MD5
|
||||
* COURIER:MD5RAW
|
||||
* COURIER:SSHA (same as SSHA)
|
||||
* COURIER:SHA256 (same as SHA256)
|
||||
|
||||
## Example usage
|
||||
|
||||
The main functionality reflects legacy behaviour in PostfixAdmin with a 'pacrypt' function, which when given ...
|
||||
|
||||
* one argument - clear text password - returns a hash.
|
||||
* two arguments - clear text password and stored hash - if the if the return value matches the stored hash, then the clear text password was a match for the hash we have.
|
||||
|
||||
```PHP
|
||||
$tool = new \PostfixAdmin\PasswordHashing\Crypt('ARGON2I');
|
||||
|
||||
// should output something to indicate what your system supports (may be dependent on PHP variant, PHP modules etc)
|
||||
|
||||
$hash = $tool->crypt('fishbeans');
|
||||
|
||||
echo "Hash is : $hash \n";
|
||||
|
||||
echo "Verify : " . json_encode($hash == $tool->crypt('fishbeans', $hash)) . "\n";
|
||||
echo "Verify fails with : " . json_encode('cat' == $tool->crypt('fishbeans', $hash)) . "\n";
|
||||
|
||||
```
|
||||
|
||||
the above code will output something similar to :
|
||||
|
||||
```text
|
||||
Hash is : {ARGON2I}$argon2i$v=19$m=65536,t=4,p=1$d1JMUXVHSUtLTGhxYnowVQ$4raz6DDUbtRysi+1ZTdNL3L5j4tcSYnzWxyLVDtFjKc
|
||||
Verify : true
|
||||
Verify fails with : false
|
||||
```
|
||||
|
||||
|
||||
## ChangeLog
|
||||
|
||||
2021/07/03 - Initial release / copying of code from https://github.com/postfixadmin/postfixadmin ...
|
33
vendor/postfixadmin/password-hashing/composer.json
vendored
Normal file
33
vendor/postfixadmin/password-hashing/composer.json
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "postfixadmin/password-hashing",
|
||||
"description": "Routines to generate password hashes, useful for Dovecot or Courier Mail servers",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"vimeo/psalm": "^4.8",
|
||||
"phpunit/phpunit": "^8|^9",
|
||||
"friendsofphp/php-cs-fixer" : "*"
|
||||
},
|
||||
"license": "GPL-2.0",
|
||||
"scripts": {
|
||||
"psalm" : "@php vendor/bin/psalm src",
|
||||
"test" : "@php vendor/bin/phpunit tests",
|
||||
"format" : [
|
||||
"@php vendor/bin/php-cs-fixer fix src ",
|
||||
"@php vendor/bin/php-cs-fixer fix tests"
|
||||
]
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
"PostfixAdmin\\PasswordHashing\\" : "src"
|
||||
}
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "David Goodwin",
|
||||
"email": "david@codepoets.co.uk"
|
||||
}
|
||||
]
|
||||
}
|
15
vendor/postfixadmin/password-hashing/psalm.xml
vendored
Normal file
15
vendor/postfixadmin/password-hashing/psalm.xml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="3"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src/" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
355
vendor/postfixadmin/password-hashing/src/Crypt.php
vendored
Normal file
355
vendor/postfixadmin/password-hashing/src/Crypt.php
vendored
Normal file
@ -0,0 +1,355 @@
|
||||
<?php
|
||||
|
||||
namespace PostfixAdmin\PasswordHashing;
|
||||
|
||||
class Crypt
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $algorithm;
|
||||
|
||||
public const SUPPORTED = [
|
||||
'COURIER:MD5', // binary md5 base64 encoded
|
||||
'COURIER:MD5RAW', // hex-encoded md5 with {MD5RAW} prefix
|
||||
'COURIER:SSHA', // same as SSHA
|
||||
'COURIER:SHA256', // same as SHA256
|
||||
'SHA1', 'SHA1.HEX', 'SHA1.B64',
|
||||
'SSHA',
|
||||
'BLF-CRYPT', 'BLF-CRYPT.B64',
|
||||
'SHA512-CRYPT', 'SHA512-CRYPT.B64',
|
||||
'ARGON2I',
|
||||
'ARGON2I.B64',
|
||||
'ARGON2ID',
|
||||
'ARGON2ID.B64',
|
||||
'SHA256', 'SHA256-CRYPT', 'SHA256-CRYPT.B64',
|
||||
'SHA512', 'SHA512.B64',
|
||||
'MD5-CRYPT', // crypt with $1$ prefix.
|
||||
'PLAIN-MD5', 'MD5',
|
||||
'CRYPT', // anything crypt() can cope with, optional {CRYPT} prefix, new hashes will use CRYPT_BLOWFISH
|
||||
'SYSTEM', // DES CRYPT, probably best to avoid
|
||||
'PLAIN', 'CLEAR', 'CLEARTEXT',
|
||||
];
|
||||
|
||||
public function __construct(string $algorithm)
|
||||
{
|
||||
$algorithm = strtoupper($algorithm);
|
||||
if (!in_array($algorithm, self::SUPPORTED)) {
|
||||
throw new \InvalidArgumentException("Unsupported hashing scheme / algorith : $algorithm");
|
||||
}
|
||||
$this->algorithm = $algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* When called with a 'pw' and a 'pw_db' (hash from e.g. database).
|
||||
*
|
||||
* If the return value matches $pw_db, then the plain text password ('pw') is correct.
|
||||
*
|
||||
* @param string $pw - plain text password
|
||||
* @param string $pw_db - hash from e.g. database (what we're comparing $pw to).
|
||||
* @return string if $pw is correct (hashes to $pw_db) then we return $pw_db. Else we return a new hash.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function crypt(string $clearText, string $passwordHash = null): string
|
||||
{
|
||||
$algorithm = $this->algorithm;
|
||||
|
||||
switch ($this->algorithm) {
|
||||
|
||||
case 'SHA1':
|
||||
case 'SHA1.B64':
|
||||
case 'SHA1.HEX':
|
||||
return $this->hashSha1($clearText, $algorithm);
|
||||
|
||||
case 'BLF-CRYPT':
|
||||
case 'BLF-CRYPT.B64':
|
||||
return $this->blowfishCrypt($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'SHA512-CRYPT':
|
||||
case 'SHA512-CRYPT.B64':
|
||||
return $this->sha512Crypt($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'ARGON2I':
|
||||
case 'ARGON2I.B64':
|
||||
return $this->argon2iCrypt($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'ARGON2ID':
|
||||
case 'ARGON2ID.B64':
|
||||
return $this->argon2idCrypt($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'SSHA':
|
||||
case 'COURIER:SSHA':
|
||||
return $this->hashSha1Salted($clearText, $passwordHash);
|
||||
|
||||
case 'SHA256':
|
||||
case 'COURIER:SHA256':
|
||||
return $this->hashSha256($clearText);
|
||||
|
||||
case 'SHA256-CRYPT':
|
||||
case 'SHA256-CRYPT.B64':
|
||||
return $this->sha256Crypt($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'SHA512':
|
||||
case 'SHA512B.b64':
|
||||
case 'SHA512.B64':
|
||||
return $this->hashSha512($clearText, $algorithm);
|
||||
|
||||
case 'PLAIN-MD5': // {PLAIN-MD5} prefix
|
||||
case 'MD5': // no prefix
|
||||
return $this->hashMd5($clearText, $algorithm); // this is hex encoded.
|
||||
|
||||
case 'COURIER:MD5':
|
||||
return '{MD5}' . base64_encode(md5($clearText, true)); // seems to need to be base64 encoded.
|
||||
|
||||
case 'COURIER:MD5RAW':
|
||||
return '{MD5RAW}' . md5($clearText);
|
||||
|
||||
case 'MD5-CRYPT':
|
||||
return $this->cryptMd5($clearText, $passwordHash, $algorithm);
|
||||
|
||||
case 'CRYPT':
|
||||
$prefix = false;
|
||||
if (!empty($passwordHash)) {
|
||||
$prefix = (substr($passwordHash, 0, 7) == '{CRYPT}');
|
||||
$passwordHash = preg_replace('/^{CRYPT}/', '', $passwordHash);
|
||||
}
|
||||
if (empty($passwordHash)) {
|
||||
$passwordHash = '$2y$10$' . substr(sha1(random_bytes(8)), 0, 22);
|
||||
}
|
||||
$str = crypt($clearText, $passwordHash);
|
||||
return $prefix ? '{CRYPT}' . $str : $str;
|
||||
|
||||
|
||||
// legacy / older crypt variant (weaker salt, weaker mechanism, DES)
|
||||
case 'SYSTEM':
|
||||
if (empty($passwordHash)) {
|
||||
$passwordHash = bin2hex(random_bytes(1)); // CRYPT_STD_DES
|
||||
}
|
||||
return crypt($clearText, $passwordHash);
|
||||
|
||||
case 'CLEAR':
|
||||
case 'PLAIN':
|
||||
case 'CLEARTEXT':
|
||||
if (!empty($passwordHash)) {
|
||||
if ($passwordHash == "{{$algorithm}}$clearText") {
|
||||
return $passwordHash;
|
||||
}
|
||||
return $clearText;
|
||||
}
|
||||
return '{' . $algorithm . '}' . $clearText;
|
||||
}
|
||||
|
||||
throw new \LogicException("Supported hash, but not implemented?");
|
||||
}
|
||||
|
||||
public function hashSha1(string $clearText, string $algorithm = 'SHA1'): string
|
||||
{
|
||||
$hash = hash('sha1', $clearText, true);
|
||||
|
||||
if (preg_match('/\.HEX$/', $algorithm)) {
|
||||
$hash = bin2hex($hash);
|
||||
} else {
|
||||
$hash = base64_encode($hash);
|
||||
}
|
||||
return "{{$algorithm}}{$hash}";
|
||||
}
|
||||
|
||||
public function hashSha1Salted(string $clearText, string $hash = null): string
|
||||
{
|
||||
if (empty($hash)) {
|
||||
$salt = base64_encode(random_bytes(3)); // 4 char salt.
|
||||
} else {
|
||||
$salt = substr(base64_decode(substr($hash, 6)), 20);
|
||||
}
|
||||
return '{SSHA}' . base64_encode(sha1($clearText . $salt, true) . $salt);
|
||||
}
|
||||
|
||||
public function hashSha512(string $clearText, string $algorithm = 'SHA512')
|
||||
{
|
||||
$prefix = '{SHA512}';
|
||||
|
||||
if ($algorithm == 'SHA512.B64' || $algorithm == 'sha512b.b64') {
|
||||
$prefix = '{SHA512.B64}';
|
||||
}
|
||||
|
||||
return $prefix . base64_encode(hash('sha512', $clearText, true));
|
||||
}
|
||||
|
||||
public function hashMd5(string $clearText, string $algorithm = 'PLAIN-MD5'): string
|
||||
{
|
||||
if ($algorithm == 'PLAIN-MD5') {
|
||||
return '{PLAIN-MD5}' . md5($clearText);
|
||||
}
|
||||
return md5($clearText);
|
||||
}
|
||||
|
||||
public function hashSha256(string $clearText): string
|
||||
{
|
||||
return '{SHA256}' . base64_encode(hash('sha256', $clearText, true));
|
||||
}
|
||||
|
||||
public function cryptMd5(string $clearText, string $hash = null, $algorithm = 'MD5-CRYPT')
|
||||
{
|
||||
if (!empty($hash)) {
|
||||
$hash = preg_replace('/^{MD5.*}/', '', $hash);
|
||||
}
|
||||
if (empty($hash)) {
|
||||
$hash = '$1$' . substr(sha1(random_bytes(8)), 0, 16);
|
||||
}
|
||||
return "{{$algorithm}}" . crypt($clearText, $hash);
|
||||
}
|
||||
|
||||
public function blowfishCrypt(string $clearText, string $hash = null, string $algorithm = 'BLF-CRYPT'): string
|
||||
{
|
||||
if (!empty($hash)) {
|
||||
if ($algorithm == 'BLF-CRYPT') {
|
||||
$hash = preg_replace('/^{BLF-CRYPT}/', '', $hash);
|
||||
}
|
||||
if ($algorithm == 'BLF-CRYPT.B64') {
|
||||
$hash = base64_decode(preg_replace('/^{BLF-CRYPT.B64}/', '', $hash));
|
||||
}
|
||||
$generated = crypt($clearText, $hash);
|
||||
|
||||
if ($algorithm == 'BLF-CRYPT.B64') {
|
||||
$generated = base64_encode($generated);
|
||||
}
|
||||
return "{{$algorithm}}{$generated}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
$r = password_hash($clearText, PASSWORD_BCRYPT);
|
||||
if (!is_string($r)) {
|
||||
throw new Exception("Failed to generate password, using $algorithm");
|
||||
}
|
||||
if ($algorithm == 'BLF-CRYPT.B64') {
|
||||
return '{BLF-CRYPT.B64}' . base64_encode($r);
|
||||
}
|
||||
return '{BLF-CRYPT}' . $r;
|
||||
}
|
||||
|
||||
public function sha256Crypt(string $clearText, string $hash = null, string $algorithm = 'SHA256-CRYPT'): string
|
||||
{
|
||||
if (!empty($hash)) {
|
||||
$hash = preg_replace('/^{SHA256-CRYPT(\.B64)?}/', '', $hash);
|
||||
|
||||
if ($algorithm == 'SHA256-CRYPT.B64') {
|
||||
$hash = base64_decode($hash);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($hash)) {
|
||||
$hash = '$5$' . substr(sha1(random_bytes(8)), 0, 16);
|
||||
}
|
||||
|
||||
$generated = crypt($clearText, $hash);
|
||||
|
||||
if ($algorithm == 'SHA256-CRYPT.B64') {
|
||||
return '{SHA256-CRYPT.B64}' . base64_encode($generated);
|
||||
}
|
||||
return "{SHA256-CRYPT}" . $generated;
|
||||
}
|
||||
|
||||
public function sha512Crypt(string $pw, string $hash = null, string $algorithm = 'SHA512-CRYPT'): string
|
||||
{
|
||||
if (!empty($hash)) {
|
||||
$hash = preg_replace('/^{SHA512-CRYPT(\.B64)?}/', '', $hash);
|
||||
|
||||
if ($algorithm == 'SHA512-CRYPT.B64') {
|
||||
$hash = base64_decode($hash);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($hash)) {
|
||||
$hash = '$6$' . substr(sha1(random_bytes(8)), 0, 16);
|
||||
}
|
||||
|
||||
$generated = crypt($pw, $hash);
|
||||
|
||||
if ($algorithm == 'SHA512-CRYPT.B64') {
|
||||
$generated = base64_encode($generated);
|
||||
return "{SHA512-CRYPT.B64}{$generated}";
|
||||
}
|
||||
|
||||
return "{SHA512-CRYPT}$generated";
|
||||
}
|
||||
|
||||
public function argon2ICrypt(string $clearText, string $hash = null, $algorithm = 'ARGON2I'): string
|
||||
{
|
||||
if (!empty($hash)) {
|
||||
$hash = preg_replace('/^{ARGON2I(\.B64)?}/', '', $hash);
|
||||
$orig_pwdb = $hash;
|
||||
if ($algorithm == 'ARGON2I.B64') {
|
||||
$hash = base64_decode($hash);
|
||||
}
|
||||
|
||||
if (password_verify($clearText, $hash)) {
|
||||
return "{{$algorithm}}" . $orig_pwdb;
|
||||
}
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
$generated = password_hash($clearText, PASSWORD_ARGON2I);
|
||||
if ($algorithm == 'ARGON2I') {
|
||||
return '{ARGON2I}' . $generated;
|
||||
}
|
||||
return '{ARGON2I.B64}' . base64_encode($generated);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
$generated = password_hash($clearText, PASSWORD_ARGON2I);
|
||||
|
||||
if ($algorithm == 'ARGON2I') {
|
||||
return '{ARGON2I}' . $generated;
|
||||
}
|
||||
|
||||
return "{ARGON2I.B64}" . base64_encode($generated);
|
||||
}
|
||||
|
||||
public function argon2idCrypt(string $clearText, string $hash = null, string $algorithm = 'ARGON2ID'): string
|
||||
{
|
||||
if (!defined('PASSWORD_ARGON2ID')) {
|
||||
throw new Exception("$algorithm is not supported; requires PHP 7.3+");
|
||||
}
|
||||
|
||||
if (!empty($hash)) {
|
||||
$hash = preg_replace('/^{ARGON2ID(\.B64)?}/', '', $hash);
|
||||
|
||||
$orig_pwdb = $hash;
|
||||
|
||||
if ($algorithm == 'ARGON2ID.B64') {
|
||||
$hash = base64_decode($hash);
|
||||
}
|
||||
|
||||
if (password_verify($clearText, $hash)) {
|
||||
return "{{$algorithm}}" . $orig_pwdb;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
$generated = password_hash($clearText, PASSWORD_ARGON2ID);
|
||||
|
||||
if ($algorithm == 'ARGON2ID') {
|
||||
return '{ARGON2ID}' . $generated;
|
||||
}
|
||||
// if($algorithm == 'ARGON2ID.B64') {
|
||||
return '{ARGON2ID.B64}' . base64_encode($generated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-suppress InvalidScalarArgument
|
||||
*/
|
||||
$generated = password_hash($clearText, PASSWORD_ARGON2ID);
|
||||
|
||||
if ($algorithm == 'ARGON2ID') {
|
||||
return '{ARGON2ID}' . $generated;
|
||||
}
|
||||
return '{ARGON2ID.B64}' . base64_encode($generated);
|
||||
}
|
||||
}
|
7
vendor/postfixadmin/password-hashing/src/Exception.php
vendored
Normal file
7
vendor/postfixadmin/password-hashing/src/Exception.php
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace PostfixAdmin\PasswordHashing;
|
||||
|
||||
class Exception extends \Exception
|
||||
{
|
||||
}
|
127
vendor/postfixadmin/password-hashing/tests/CryptTest.php
vendored
Normal file
127
vendor/postfixadmin/password-hashing/tests/CryptTest.php
vendored
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace PostfixAdmin\Tests;
|
||||
|
||||
use PostfixAdmin\PasswordHashing\Crypt;
|
||||
|
||||
class CryptTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testMd5Crypt()
|
||||
{
|
||||
$h = new Crypt('MD5-CRYPT');
|
||||
$hash = $h->cryptMd5('test');
|
||||
$check = $h->crypt('test', $hash);
|
||||
|
||||
$this->assertEquals($check, $hash);
|
||||
|
||||
$this->assertNotEmpty($hash);
|
||||
$this->assertNotEquals('test', $hash);
|
||||
$this->assertMatchesRegularExpression('/^{MD5-CRYPT}\$1\$/', $hash);
|
||||
$this->assertEquals($hash, $h->crypt('test', $hash));
|
||||
}
|
||||
|
||||
public function testCryptWithOrWithoutPrefix()
|
||||
{
|
||||
|
||||
// SHA512 CRYPT
|
||||
$hash = '$6$1O7.LNhM058togZg$yH3NA1/SgX/Nn0Q9NlnSN.i8dHeEdHDRn1RPbhDykvyrt/dMA4qeJZ61RA8ov7uFoSJSQ87u7UZfk/jjfUayW0';
|
||||
|
||||
$h = new Crypt('CRYPT');
|
||||
$crypt = $h->crypt('test1234?', $hash);
|
||||
|
||||
$this->assertEquals($crypt, $hash);
|
||||
|
||||
$new = $h->crypt('test1234?');
|
||||
$this->assertNotEquals($hash, $new);
|
||||
|
||||
// BLOWFISH CRYPT
|
||||
$check = '{CRYPT}$2y$10$ee26ef01d29d3d939c079u7LkOJuYmIhJV8yLd3AU6xdORaxc5HqS';
|
||||
$crypt = $h->crypt('test1234?', $check);
|
||||
$not_crypt = $h->crypt('picklesmells', $check);
|
||||
|
||||
$this->assertEquals($crypt, $check);
|
||||
$this->assertNotEquals($not_crypt, $check);
|
||||
}
|
||||
|
||||
|
||||
public function testMd5()
|
||||
{
|
||||
$h = new Crypt('PLAIN-MD5');
|
||||
|
||||
$hash = $h->hashMd5('test');
|
||||
$expected = '{PLAIN-MD5}' . md5('test');
|
||||
$this->assertEquals($hash, $expected);
|
||||
|
||||
$h = new Crypt('MD5');
|
||||
$hash = $h->hashMd5('test', 'MD5');
|
||||
$hash2 = $h->crypt('test');
|
||||
$this->assertEquals($hash, $hash2);
|
||||
|
||||
$expected = md5('test');
|
||||
$this->assertEquals($hash, $expected);
|
||||
}
|
||||
|
||||
|
||||
public function testEverything()
|
||||
{
|
||||
global $CONF;
|
||||
|
||||
// should all be from 'test123', generated via dovecot.
|
||||
$example_json = <<<'EOF'
|
||||
{
|
||||
"SHA1": "{SHA1}cojt0Pw\/\/L6ToM8G41aOKFIWh7w=",
|
||||
"SHA1.B64": "{SHA1.B64}cojt0Pw\/\/L6ToM8G41aOKFIWh7w=",
|
||||
"BLF-CRYPT": "{BLF-CRYPT}$2y$05$cEEZv2h\/NtLXII.emi2TP.rMZyB7VRSkyToXWBqqz6cXDoyay166q",
|
||||
"BLF-CRYPT.B64": "{BLF-CRYPT.B64}JDJ5JDA1JEhlR0lBeGFHR2tNUGxjRWpyeFc0eU9oRjZZZ1NuTWVOTXFxNWp4bmFwVjUwdGU3c2x2L1VT",
|
||||
"SHA512-CRYPT": "{SHA512-CRYPT}$6$MViNQUSbWyXWL9wZ$63VsBU2a\/ZFb9f\/dK4EmaXABE9jAcNltR7y6a2tXLKoV5F5jMezno.2KpmtD3U0FDjfa7A.pkCluVMlZJ.F64.",
|
||||
"SHA512-CRYPT.B64": "{SHA512-CRYPT.B64}JDYkR2JwY3NiZXNMWk9DdERXbiRYdXlhdEZTdy9oa3lyUFE0d24wenpGQTZrSlpTUE9QVWdPcjVRUC40bTRMTjEzdy81aWMvWTdDZllRMWVqSWlhNkd3Q2Z0ZnNjZEFpam9OWjl3OU5tLw==",
|
||||
"SHA512": "{SHA512}2u9JU7l4M2XK1mFSI3IFBsxGxRZ80Wq1APpZeqCP+WTrJPsZaH8012Zfd4\/LbFNY\/ApbgeFmLPkPc6JnHFP5kQ==",
|
||||
"SHA512.B64": "{SHA512.B64}2u9JU7l4M2XK1mFSI3IFBsxGxRZ80Wq1APpZeqCP+WTrJPsZaH8012Zfd4\/LbFNY\/ApbgeFmLPkPc6JnHFP5kQ==",
|
||||
"CRYPT": "{CRYPT}$2y$05$ORqzr0AagWr25v3ixHD5QuMXympIoNTbipEFZz6aAmovGNoij2vDO",
|
||||
"MD5-CRYPT": "{MD5-CRYPT}$1$AIjpWveQ$2s3eEAbZiqkJhMYUIVR240",
|
||||
"SYSTEM": "abRcsZmlrrKFA",
|
||||
"PLAIN-MD5": "{PLAIN-MD5}cc03e747a6afbbcbf8be7668acfebee5",
|
||||
"SSHA": "{SSHA}ZkqrSEAhvd0FTHaK1IxAQCRa5LWbxGQY",
|
||||
"PLAIN": "{PLAIN}test123",
|
||||
"CLEAR": "{CLEAR}test123",
|
||||
"CLEARTEXT": "{CLEARTEXT}test123",
|
||||
"ARGON2I": "{ARGON2I}$argon2i$v=19$m=32768,t=4,p=1$xoOcAGa27k0Sr6ZPbA9ODw$wl\/KAZVmJooD\/35IFG5oGwyQiAREXrLss5BPS1PDKfA",
|
||||
"ARGON2ID": "{ARGON2ID}$argon2id$v=19$m=65536,t=3,p=1$eaXP376O9/VxleLw9OQIxg$jOoDyECeRRV4eta3eSN/j0RdBgqaA1VBGAA/pbviI20",
|
||||
"ARGON2ID.B64" : "{ARGON2ID.B64}JGFyZ29uMmlkJHY9MTkkbT02NTUzNix0PTMscD0xJEljdG9DWko1T04zWlYzM3I0TVMrNEEkMUVtNTJRWkdsRlJzNnBsRXpwVmtMeVd4dVNPRUZ2dUZnaVNhTmNlb08rOA==",
|
||||
"SHA256": "{SHA256}7NcYcNGWMxapfjrDQIyYNa2M8PPBvHA1J8MCZVNPda4=",
|
||||
"SHA256-CRYPT": "{SHA256-CRYPT}$5$CFly6wzfn2az3U8j$EhfQPTdjpMGAisfCjCKektLke5GGEmtdLVaCZSmsKw2",
|
||||
"SHA256-CRYPT.B64": "{SHA256-CRYPT.B64}JDUkUTZZS1ZzZS5sSVJoLndodCR6TWNOUVFVVkhtTmM1ME1SQk9TR3BEeGpRY2M1TzJTQ1lkbWhPN1YxeHlD"
|
||||
}
|
||||
EOF;
|
||||
|
||||
$algo_example = json_decode($example_json, true);
|
||||
|
||||
foreach ($algo_example as $algorithm => $example_hash) {
|
||||
$h = new Crypt($algorithm);
|
||||
|
||||
$pfa_new_hash = $h->crypt('test123');
|
||||
|
||||
$pacrypt_check = $h->crypt('test123', $example_hash);
|
||||
$pacrypt_sanity = $h->crypt('zzzzzzz', $example_hash);
|
||||
|
||||
$this->assertNotEquals($pacrypt_sanity, $example_hash, "Should not match, zzzz password. $algorithm / $pacrypt_sanity");
|
||||
|
||||
$this->assertEquals($pacrypt_check, $example_hash, "Should match, algorithm: $algorithm generated:{$pacrypt_check} vs example:{$example_hash}");
|
||||
|
||||
$new_new = $h->crypt('test123', $pfa_new_hash);
|
||||
|
||||
$this->assertEquals($pfa_new_hash, $new_new, "Trying: $algorithm => gave: $new_new with $pfa_new_hash ... ");
|
||||
}
|
||||
}
|
||||
|
||||
public function testWeSupportWhatWeSayWeDo()
|
||||
{
|
||||
foreach (Crypt::SUPPORTED as $algorithm) {
|
||||
$c = new Crypt($algorithm);
|
||||
$hash1 = $c->crypt('test123');
|
||||
|
||||
$this->assertEquals($hash1, $c->crypt('test123', $hash1));
|
||||
$this->assertNotEquals($hash1, $c->crypt('9999test9999', $hash1));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user