Dr. Andrew Besmer
AVG()SUM()COUNT()MIN()MAX()SD()Populations need to be of sufficient size of inference of individuals data is possible
Should not be able to determine for example income of one employee
//For PHP
$csprnOrSalt = openssl_random_pseudo_bytes(8);
$hash = hash_pbkdf2("sha256", $password, $salt, $iterations);
Passwords can be written as plain text in SQL statements such as CREATE USER, GRANT, and SET PASSWORD, or statements that invoke the PASSWORD() function. If these statements are logged by the MySQL server as written, such passwords become available to anyone with access to the logs.
$stmt = $db->prepare("Select * from User where (username, hash) =
(Select username, SHA2(CONCAT(salt, :password), 256) as hash
FROM User where username = :username)");
$stmt->bindValue(":username", $username);
$stmt->bindValue(":password", $password);
$stmt->execute();
$stmt = $db->prepare("Select * from User where username = :username");
$stmt->bindValue(":username", $username);
$stmt->execute();
if($stmt->rowCount() == 1){
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$passToCheck = $row["salt"] . $password;
//Plain text password never leaves server, not in MySQL logs...
if(hash("sha256", $passToCheck) == $row["hash"]) {
//Yes!
}
else
{
//No!
}
}
M
M[s,o] in matrix represents the type of
privileges (read, write, update)
that subject s holds on object oSELECT at the account level can select
from any database or tableGRANT SELECT, INSERT ON *.* TO 'andrew'@'%'; --account
GRANT SELECT, INSERT ON company.* TO 'andrew'@'%'; --database
GRANT SELECT, INSERT ON company.employee TO 'andrew'@'%'; --table
GRANT ALL ON *.* TO 'andrew'@'%'; --AHH!
CREATE SCHEMACREATE VIEWALTER Adding/Removing AttributesDROP Relations/ViewsMODIFY
INSERT/DELETE/UPDATESELECTSELECTMODIFYR in database is assigned an owner
GRANT OPTION to allow those users to continue to
pass privilegesGRANT OPTION = MACA is owner of EMPLOYEEGRANT SELECT ON EMPLOYEE, DEPARTMENT TO B WITH GRANT OPTION;
B grants C access.A revokes B’s
privilege?REVOKE SELECT ON EMPLOYEE FROM B;
i usersi=2
S
is not allowed to read access to object O unless
class(S) ≥ class(O)S is not
allowed to write an object O unless
class(O) ≥ class(S)GRANT ALL ON company.* TO 'andrew'@'%' WITH
MAX_QUERIES_PER_HOUR 100 MAX_UPDATES_PER_HOUR 100;
MySQL has a database mysql
User tables loaded into memory when server starts
CREATE USER, SET PASSWORD auto
reloadedINSERT, UPDATE to table
requires restart or “flushing privileges”User is defined by both a name and host
'andrew'@'aspen.winthrop.edu'
'andrew'@'%'
These are two completely different users
Permissions assigned to each individually
MySQL matches based on most specific host to least specific
'%'@'aspen.winthrop.edu''andrew'@'%'SELECT CURRENT_USER();
CREATE USER 'databases'@'localhost' IDENTIFIED BY 'csci355';
-- vs
CREATE USER 'csci355'@'localhost';
-- vs
CREATE USER 'databases'@'%' IDENTIFIED BY 'csci355';
-- vs
CREATE USER 'csci355'@'%';
'%'username_%