Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a21d22c7b | ||
|
|
cee3b5c2d1 | ||
|
|
47e44c15cc |
@@ -1,6 +1,8 @@
|
|||||||
-- Upgrae serial to identity type
|
-- Upgrade serial to identity type
|
||||||
--
|
--
|
||||||
-- @param reclass tbl The table where the column is located
|
-- Original: https://www.enterprisedb.com/blog/postgresql-10-identity-columns-explained#section-6
|
||||||
|
--
|
||||||
|
-- @param reclass tbl The table where the column is located, prefix with 'schema.' if different schema
|
||||||
-- @param name col The column to be changed
|
-- @param name col The column to be changed
|
||||||
-- @param varchar identity_type [default=a] Allowed a, d, assigned, default
|
-- @param varchar identity_type [default=a] Allowed a, d, assigned, default
|
||||||
-- @param varchar col_type [default=''] Allowed smallint, int, bigint, int2, int4, int8
|
-- @param varchar col_type [default=''] Allowed smallint, int, bigint, int2, int4, int8
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
'EUID' => 1,
|
'EUID' => 1,
|
||||||
|
'ECUID' => 'abc',
|
||||||
],
|
],
|
||||||
2,
|
2,
|
||||||
[],
|
[],
|
||||||
@@ -260,6 +261,7 @@ final class CoreLibsACLLoginTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
[
|
[
|
||||||
'EUID' => 1,
|
'EUID' => 1,
|
||||||
|
'ECUID' => 'abc',
|
||||||
'USER_NAME' => '',
|
'USER_NAME' => '',
|
||||||
'GROUP_NAME' => '',
|
'GROUP_NAME' => '',
|
||||||
'ADMIN' => 1,
|
'ADMIN' => 1,
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ final class CoreLibsCreateUidsTest extends TestCase
|
|||||||
* must match 7e78fe0d-59b8-4637-af7f-e88d221a7d1e
|
* must match 7e78fe0d-59b8-4637-af7f-e88d221a7d1e
|
||||||
*
|
*
|
||||||
* @covers ::uuidv4
|
* @covers ::uuidv4
|
||||||
|
* @covers ::validateUuidv4
|
||||||
* @testdox uuidv4 check that return is matching regex [$_dataName]
|
* @testdox uuidv4 check that return is matching regex [$_dataName]
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
@@ -129,13 +130,18 @@ final class CoreLibsCreateUidsTest extends TestCase
|
|||||||
{
|
{
|
||||||
$uuid = \CoreLibs\Create\Uids::uuidv4();
|
$uuid = \CoreLibs\Create\Uids::uuidv4();
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
'/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/',
|
'/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/',
|
||||||
$uuid
|
$uuid,
|
||||||
|
'Failed regex check'
|
||||||
|
);
|
||||||
|
$this->assertTrue(
|
||||||
|
\CoreLibs\Create\Uids::validateUuuidv4($uuid),
|
||||||
|
'Failed validate regex method'
|
||||||
|
);
|
||||||
|
$this->assertFalse(
|
||||||
|
\CoreLibs\Create\Uids::validateUuuidv4('not-a-uuidv4'),
|
||||||
|
'Failed wrong uuid validated as true'
|
||||||
);
|
);
|
||||||
// $this->assertStringMatchesFormat(
|
|
||||||
// '%4s%4s-%4s-%4s-%4s-%4s%4s%4s',
|
|
||||||
// $uuid
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ print "PREPARE INSERT PREVIOUS INSERTED: "
|
|||||||
|
|
||||||
print "PREPARE CURSOR RETURN:<br>";
|
print "PREPARE CURSOR RETURN:<br>";
|
||||||
foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) {
|
foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) {
|
||||||
print "KEY: " . $key . ': ' . $db->dbGetPrepareCursorValue('ins_test_foo', $key) . "<br>";
|
print "KEY: " . $key . ': ' . Support::prAr($db->dbGetPrepareCursorValue('ins_test_foo', $key)) . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = <<<SQL
|
$query = <<<SQL
|
||||||
|
|||||||
@@ -52,6 +52,14 @@ print "S:UNIQID (512): " . Uids::uniqId(512) . "<br>";
|
|||||||
// uniq ids
|
// uniq ids
|
||||||
print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>";
|
print "UNIQU ID SHORT : " . Uids::uniqIdShort() . "<br>";
|
||||||
print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";
|
print "UNIQU ID LONG : " . Uids::uniqIdLong() . "<br>";
|
||||||
|
// validate
|
||||||
|
$uuidv4 = Uids::uuidv4();
|
||||||
|
if (!Uids::validateUuuidv4($uuidv4)) {
|
||||||
|
print "Invalid UUIDv4: " . $uuidv4 . "<br>";
|
||||||
|
}
|
||||||
|
if (!Uids::validateUuuidv4("foobar")) {
|
||||||
|
print "Invalid UUIDv4: hard coded<Br>";
|
||||||
|
}
|
||||||
|
|
||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
/* print "D/UUIDV4: ".$basic->uuidv4()."<br>";
|
/* print "D/UUIDV4: ".$basic->uuidv4()."<br>";
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ class Login
|
|||||||
{
|
{
|
||||||
/** @var ?int the user id var*/
|
/** @var ?int the user id var*/
|
||||||
private ?int $euid;
|
private ?int $euid;
|
||||||
|
/** @var ?string the user cuid (note will be super seeded with uuid v4 later) */
|
||||||
|
private ?string $ecuid;
|
||||||
/** @var string _GET/_POST loginUserId parameter for non password login */
|
/** @var string _GET/_POST loginUserId parameter for non password login */
|
||||||
private string $login_user_id = '';
|
private string $login_user_id = '';
|
||||||
/** @var string source, either _GET or _POST or empty */
|
/** @var string source, either _GET or _POST or empty */
|
||||||
@@ -757,7 +759,7 @@ class Login
|
|||||||
}
|
}
|
||||||
// have to get the global stuff here for setting it later
|
// have to get the global stuff here for setting it later
|
||||||
// we have to get the themes in here too
|
// we have to get the themes in here too
|
||||||
$q = "SELECT eu.edit_user_id, eu.username, eu.password, "
|
$q = "SELECT eu.edit_user_id, eu.cuid, eu.username, eu.password, "
|
||||||
. "eu.edit_group_id, "
|
. "eu.edit_group_id, "
|
||||||
. "eg.name AS edit_group_name, eu.admin, "
|
. "eg.name AS edit_group_name, eu.admin, "
|
||||||
// additinal acl lists
|
// additinal acl lists
|
||||||
@@ -889,6 +891,7 @@ class Login
|
|||||||
// normal user processing
|
// normal user processing
|
||||||
// set class var and session var
|
// set class var and session var
|
||||||
$_SESSION['EUID'] = $this->euid = (int)$res['edit_user_id'];
|
$_SESSION['EUID'] = $this->euid = (int)$res['edit_user_id'];
|
||||||
|
$_SESSION['ECUID'] = $this->ecuid = (string)$res['cuid'];
|
||||||
// check if user is okay
|
// check if user is okay
|
||||||
$this->loginCheckPermissions();
|
$this->loginCheckPermissions();
|
||||||
if ($this->login_error == 0) {
|
if ($this->login_error == 0) {
|
||||||
@@ -1132,6 +1135,8 @@ class Login
|
|||||||
// username (login), group name
|
// username (login), group name
|
||||||
$this->acl['user_name'] = $_SESSION['USER_NAME'];
|
$this->acl['user_name'] = $_SESSION['USER_NAME'];
|
||||||
$this->acl['group_name'] = $_SESSION['GROUP_NAME'];
|
$this->acl['group_name'] = $_SESSION['GROUP_NAME'];
|
||||||
|
// edit user cuid
|
||||||
|
$this->acl['ecuid'] = $_SESSION['ECUID'];
|
||||||
// set additional acl
|
// set additional acl
|
||||||
$this->acl['additional_acl'] = [
|
$this->acl['additional_acl'] = [
|
||||||
'user' => $_SESSION['USER_ADDITIONAL_ACL'],
|
'user' => $_SESSION['USER_ADDITIONAL_ACL'],
|
||||||
@@ -1862,6 +1867,8 @@ HTML;
|
|||||||
}
|
}
|
||||||
// if there is none, there is none, saves me POST/GET check
|
// if there is none, there is none, saves me POST/GET check
|
||||||
$this->euid = array_key_exists('EUID', $_SESSION) ? (int)$_SESSION['EUID'] : 0;
|
$this->euid = array_key_exists('EUID', $_SESSION) ? (int)$_SESSION['EUID'] : 0;
|
||||||
|
// TODO: allow load from cuid
|
||||||
|
// $this->ecuid = array_key_exists('ECUID', $_SESSION) ? (string)$_SESSION['ECUID'] : '';
|
||||||
// get login vars, are so, can't be changed
|
// get login vars, are so, can't be changed
|
||||||
// prepare
|
// prepare
|
||||||
// pass on vars to Object vars
|
// pass on vars to Object vars
|
||||||
@@ -2111,6 +2118,7 @@ HTML;
|
|||||||
$this->session->sessionDestroy();
|
$this->session->sessionDestroy();
|
||||||
// unset euid
|
// unset euid
|
||||||
$this->euid = null;
|
$this->euid = null;
|
||||||
|
$this->ecuid = null;
|
||||||
// then prints the login screen again
|
// then prints the login screen again
|
||||||
$this->permission_okay = false;
|
$this->permission_okay = false;
|
||||||
}
|
}
|
||||||
@@ -2128,11 +2136,12 @@ HTML;
|
|||||||
if (empty($this->euid)) {
|
if (empty($this->euid)) {
|
||||||
return $this->permission_okay;
|
return $this->permission_okay;
|
||||||
}
|
}
|
||||||
|
// euid must match ecuid
|
||||||
// bail for previous wrong page match, eg if method is called twice
|
// bail for previous wrong page match, eg if method is called twice
|
||||||
if ($this->login_error == 103) {
|
if ($this->login_error == 103) {
|
||||||
return $this->permission_okay;
|
return $this->permission_okay;
|
||||||
}
|
}
|
||||||
$q = "SELECT ep.filename, "
|
$q = "SELECT ep.filename, eu.cuid, "
|
||||||
// base lock flags
|
// base lock flags
|
||||||
. "eu.deleted, eu.enabled, eu.locked, "
|
. "eu.deleted, eu.enabled, eu.locked, "
|
||||||
// date based lock
|
// date based lock
|
||||||
@@ -2198,6 +2207,8 @@ HTML;
|
|||||||
} else {
|
} else {
|
||||||
$this->login_error = 103;
|
$this->login_error = 103;
|
||||||
}
|
}
|
||||||
|
// set ECUID
|
||||||
|
$_SESSION['ECUID'] = $this->ecuid = (string)$res['cuid'];
|
||||||
// if called from public, so we can check if the permissions are ok
|
// if called from public, so we can check if the permissions are ok
|
||||||
return $this->permission_okay;
|
return $this->permission_okay;
|
||||||
}
|
}
|
||||||
@@ -2503,6 +2514,16 @@ HTML;
|
|||||||
{
|
{
|
||||||
return (string)$this->euid;
|
return (string)$this->euid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current set ECUID (edit user cuid)
|
||||||
|
*
|
||||||
|
* @return string ECUID as string
|
||||||
|
*/
|
||||||
|
public function loginGetEcid(): string
|
||||||
|
{
|
||||||
|
return (string)$this->ecuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class HSB implements Interface\CoordinatesInterface
|
|||||||
private float $B = 0.0;
|
private float $B = 0.0;
|
||||||
|
|
||||||
/** @var string color space: either ok or cie */
|
/** @var string color space: either ok or cie */
|
||||||
private string $colorspace = '';
|
private string $colorspace = ''; /** @phpstan-ignore-line */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HSB (HSV) color coordinates
|
* HSB (HSV) color coordinates
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class HSL implements Interface\CoordinatesInterface
|
|||||||
/** @var float lightness (luminance) */
|
/** @var float lightness (luminance) */
|
||||||
private float $L = 0.0;
|
private float $L = 0.0;
|
||||||
|
|
||||||
/** @var string color space: either ok or cie */
|
/** @var string color space: either sRGB */
|
||||||
private string $colorspace = '';
|
private string $colorspace = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,26 +56,6 @@ class Uids
|
|||||||
*/
|
*/
|
||||||
public static function uuidv4(): string
|
public static function uuidv4(): string
|
||||||
{
|
{
|
||||||
/* return sprintf(
|
|
||||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
|
||||||
// 32 bits for "time_low"
|
|
||||||
mt_rand(0, 0xffff),
|
|
||||||
mt_rand(0, 0xffff),
|
|
||||||
// 16 bits for "time_mid"
|
|
||||||
mt_rand(0, 0xffff),
|
|
||||||
// 16 bits for "time_hi_and_version",
|
|
||||||
// four most significant bits holds version number 4
|
|
||||||
mt_rand(0, 0x0fff) | 0x4000,
|
|
||||||
// 16 bits, 8 bits for "clk_seq_hi_res",
|
|
||||||
// 8 bits for "clk_seq_low",
|
|
||||||
// two most significant bits holds zero and one for variant DCE1.1
|
|
||||||
mt_rand(0, 0x3fff) | 0x8000,
|
|
||||||
// 48 bits for "node"
|
|
||||||
mt_rand(0, 0xffff),
|
|
||||||
mt_rand(0, 0xffff),
|
|
||||||
mt_rand(0, 0xffff)
|
|
||||||
); */
|
|
||||||
|
|
||||||
$data = random_bytes(16);
|
$data = random_bytes(16);
|
||||||
assert(strlen($data) == 16);
|
assert(strlen($data) == 16);
|
||||||
|
|
||||||
@@ -93,6 +73,20 @@ class Uids
|
|||||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* regex validate uuid v4
|
||||||
|
*
|
||||||
|
* @param string $uuidv4
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function validateUuuidv4(string $uuidv4): bool
|
||||||
|
{
|
||||||
|
if (!preg_match("/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/", $uuidv4)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a uniq id based on lengths
|
* creates a uniq id based on lengths
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user