How triledinh159/2fa-mqtt works
Project Type and Purpose
• The project is focused on enhancing MQTT security by integrating OTP (one-time passwords) and AES encryption. It clearly involves multi-component interactions where authentication, secure data transmission, and encryption are key.
• The project uses both MQTT Client code and a broker setup (EC2-EMQX) along with Lambda functions that appear to handle backend validation processes (e.g., verifying credentials and finding email records in a DB).
Analyzing the File Structure
• Client Directory:
• Contains two scripts, pub.py and sub.py. These represent the MQTT client’s publishing and subscribing functionalities.
• EC2-EMQX Directory:
• Contains an index.html and source.js, which likely serve as a monitoring dashboard or a lightweight UI for viewing status or controlling the EMQX (MQTT broker) running on an EC2 instance.
• Lambda Directory:
• Contains findEmailinDB.py and verify_func.py, which suggest that serverless functions are implemented for processes like looking up email credentials and verifying authentication (possibly OTP verification or similar processes).
• Main Components:
• MQTT Clients (represented by the pub.py and sub.py scripts).
• MQTT Broker (represented by the EC2-EMQX component on an AWS EC2 instance hosting EMQX). Use this to illustrate the core message broker/security gateway.
• Authentication Services (represented by the Lambda functions). These serverless components handle OTP generation/verification, AES-based payload encryption, and possibly DB lookups for securing the authentication flow.
• Relationships and Interactions:
• MQTT Clients connect to and communicate with the EMQX broker.
• The EMQX broker interacts with the Lambda functions to perform additional checks: e.g., upon receiving a message, it might trigger a Lambda function to verify user credentials via OTP and AES encryption.
• Any client publishing messages may have their payloads encrypted (AES) and require OTP validation, ensuring messages are secure from the client to the broker.
• Architectural Patterns and Design Principles:
• A clear separation of concerns is used:
▪ Client code for message publishing/subscribing.
▪ Broker (EC2-EMQX) ensures secure communication.
▪ Serverless functions (Lambda) provide modular and scalable authentication and encryption services.
• The design leverages event-driven principles where MQTT messages can trigger authentication processes.
• Technologies, Frameworks, and Libraries:
• MQTT and EMQX for message brokering.
• AWS Lambda for serverless, on-demand authentication.
• OTP and AES mechanisms for enhanced security (likely implemented within the code of Python-based Lambda functions).
• A web-based interface (using index.html and source.js) could be used for monitoring or administration of the broker.