rb-projects-access:start
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rb-projects-access:start [17/07/2024 11:15] – created - external edit 127.0.0.1 | 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 ===== | ||
+ | |||
+ | person present card to reader | ||
+ | |||
+ | card id read and submitted to control system with reader (door) id | ||
+ | |||
+ | card id used to get user and door information from db | ||
+ | <code mysql> | ||
+ | -> > select userID, cardID from keycards where cardNumber = 1234; | ||
+ | +--------+--------+ | ||
+ | | userID | cardID | | ||
+ | +--------+--------+ | ||
+ | | 3 | 1 | | ||
+ | +--------+--------+ | ||
+ | </ | ||
+ | note cardID is an index to the table, use this as it allows a card ID to be changed if a card is lost | ||
+ | |||
+ | |||
+ | select door information from readerID to decide if PIN is needed. | ||
+ | <code mysql> | ||
+ | | ||
+ | +--------+----------+-----------+---------+ | ||
+ | | doorId | readerId | doorDesc | ||
+ | +--------+----------+-----------+---------+ | ||
+ | | 3 | 7678 | Back door | 1 | | ||
+ | +--------+----------+-----------+---------+ | ||
+ | </ | ||
+ | |||
+ | 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; | ||
+ | +------------------------------------------------------------+ | ||
+ | | accesslevel | ||
+ | +------------------------------------------------------------+ | ||
+ | | { | ||
+ | 1 : " | ||
+ | 2 : " | ||
+ | 3 : " | ||
+ | } | | ||
+ | +------------------------------------------------------------+ | ||
+ | </ | ||
+ | so card number 1234 is cardID 1 and userID 3. | ||
+ | presented to reader 7678 which is doorID 3 back door, as it is external it requires a PIN as well | ||
+ | userID 3 has access level to doorID " | ||
+ | |||
+ | |||
===== DB structure ===== | ===== DB structure ===== | ||
+ | <code mysql> | ||
+ | show tables; | ||
+ | +-------------------------+ | ||
+ | | Tables_in_accesscontrol | | ||
+ | +-------------------------+ | ||
+ | | access | ||
+ | | doors | | ||
+ | | keycards | ||
+ | | users | | ||
+ | +-------------------------+ | ||
+ | 23 rows in set (0.000 sec) | ||
+ | </ | ||
+ | |||
+ | |||
+ | <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.1721214948.txt.gz · Last modified: by 127.0.0.1