rb-projects-access:start
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rb-projects-access:start [14/01/2025 17:51] – [DB structure] andrew | rb-projects-access:start [21/02/2025 13:25] (current) – [Access Control] andrew | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Access Control ====== | ====== Access Control ====== | ||
+ | {{ : | ||
Very much embryonic and alpha project to play with commands which would be required to implement a electronic door lock system. | Very much embryonic and alpha project to play with commands which would be required to implement a electronic door lock system. | ||
Key cards with a serial number are issued and each door has a Wiegand or rfid style reader, optionally requiring a PIN as well as card to unlock. Maybe bluetooth instead of PIN? | Key cards with a serial number are issued and each door has a Wiegand or rfid style reader, optionally requiring a PIN as well as card to unlock. Maybe bluetooth instead of PIN? | ||
- | Also, by abstracting the keypad / reader and lock from the physical device, it should enable MQTT enabled devices to be included. If they are to be trusted..... So PKI is probably needed to maintain trust and security. (Trust but Verify!) | + | Also, by abstracting the keypad / reader and lock from the physical device, it should enable MQTT enabled devices to be included. If they are to be trusted..... So PKI is probably needed to maintain trust and security. |
+ | [[https:// | ||
+ | [[https:// | ||
===== Flow ===== | ===== Flow ===== | ||
Line 37: | Line 39: | ||
</ | </ | ||
- | Get access level for user | + | Get access level for user, I don't really like this, I need a way to record info for many users for many doors whilst remaining workable. My idea to store JSON in the SQL was a way to combine a NoSQL style db with MySQL. Seemed cool at the time..... |
<code sql> select accesslevel from access where userID = 3; | <code sql> select accesslevel from access where userID = 3; | ||
+------------------------------------------------------------+ | +------------------------------------------------------------+ | ||
Line 72: | Line 74: | ||
</ | </ | ||
+ | |||
+ | <code mysql> | ||
+ | > show create table access \G; | ||
+ | *************************** 1. row *************************** | ||
+ | | ||
+ | Create Table: CREATE TABLE `access` ( | ||
+ | `accessID` int(11) NOT NULL, | ||
+ | `userID` int(11) NOT NULL, | ||
+ | `accesslevel` varchar(1024) NOT NULL, | ||
+ | PRIMARY KEY (`accessID`), | ||
+ | UNIQUE KEY `userID` (`userID`) | ||
+ | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci | ||
+ | 1 row in set (0.001 sec) | ||
+ | |||
+ | > describe access; | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | | Field | Type | Null | Key | Default | Extra | | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | | accessID | ||
+ | | userID | ||
+ | | accesslevel | varchar(1024) | NO | ||
+ | +-------------+---------------+------+-----+---------+-------+ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | <code mysql> | ||
+ | show create table doors \G; | ||
+ | *************************** 1. row *************************** | ||
+ | | ||
+ | Create Table: CREATE TABLE `doors` ( | ||
+ | `doorID` int(11) NOT NULL AUTO_INCREMENT, | ||
+ | `readerID` int(11) NOT NULL, | ||
+ | `doorDesc` varchar(255) NOT NULL, | ||
+ | `pinReqd` tinyint(1) NOT NULL, | ||
+ | PRIMARY KEY (`doorID`), | ||
+ | UNIQUE KEY `doorDesc` (`doorDesc`) | ||
+ | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci | ||
+ | 1 row in set (0.000 sec) | ||
+ | |||
+ | > describe doors; | ||
+ | +----------+--------------+------+-----+---------+----------------+ | ||
+ | | Field | Type | Null | Key | Default | Extra | | ||
+ | +----------+--------------+------+-----+---------+----------------+ | ||
+ | | doorID | ||
+ | | readerID | int(11) | ||
+ | | doorDesc | varchar(255) | NO | UNI | NULL | | | ||
+ | | pinReqd | ||
+ | +----------+--------------+------+-----+---------+----------------+ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | <code mysql> | ||
+ | show create table keycards \G; | ||
+ | *************************** 1. row *************************** | ||
+ | | ||
+ | Create Table: CREATE TABLE `keycards` ( | ||
+ | `cardID` int(11) NOT NULL, | ||
+ | `cardNumber` varchar(256) NOT NULL, | ||
+ | `Created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
+ | `Deleted` timestamp NOT NULL DEFAULT ' | ||
+ | `userID` int(11) NOT NULL, | ||
+ | PRIMARY KEY (`cardID`) | ||
+ | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci | ||
+ | 1 row in set (0.000 sec) | ||
+ | |||
+ | |||
+ | > describe keycards; | ||
+ | +------------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | | Field | Type | Null | Key | Default | ||
+ | +------------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | | cardID | ||
+ | | cardNumber | varchar(256) | NO | ||
+ | | Created | ||
+ | | Deleted | ||
+ | | userID | ||
+ | +------------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | <code mysql> | ||
+ | show create table users \G; | ||
+ | *************************** 1. row *************************** | ||
+ | | ||
+ | Create Table: CREATE TABLE `users` ( | ||
+ | `userID` int(11) NOT NULL, | ||
+ | `username` varchar(256) NOT NULL, | ||
+ | `firstname` varchar(256) NOT NULL, | ||
+ | `surname` varchar(256) NOT NULL, | ||
+ | `pin` int(11) NOT NULL, | ||
+ | `created` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), | ||
+ | `deleted` timestamp NOT NULL DEFAULT ' | ||
+ | PRIMARY KEY (`userID`) | ||
+ | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci | ||
+ | 1 row in set (0.001 sec) | ||
+ | |||
+ | |||
+ | | ||
+ | +-----------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | | Field | Type | Null | Key | Default | ||
+ | +-----------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | | userID | ||
+ | | username | ||
+ | | firstname | varchar(256) | NO | ||
+ | | surname | ||
+ | | pin | int(11) | ||
+ | | created | ||
+ | | deleted | ||
+ | +-----------+--------------+------+-----+---------------------+-------------------------------+ | ||
+ | |||
+ | </ | ||
rb-projects-access/start.1736877106.txt.gz · Last modified: by andrew