/TalkyWalky

Secure chatroom application based on RabbitMQ broker & using open-LDAP for authentication

Primary LanguagePythonMIT LicenseMIT

Python-Secure-Chatroom

About

A chatroom application written in Python using TKinter & based on RabbitMQ broker using open-LDAP for authentication

Learning objectives

When we've completed this Code Pattern, you will understand how to:

  • Objective 1: LDAP server configuration, helping us manage user authentication.
  • Objective 2: How to set up an authority server that accepts certification requests, creates them, then signs them in order to verify their state
  • Objective 3: How to use RabbitMQ for chatting, which is an enterprise level tool.

Flow

When thinking of chatroom capabilities, our elegant application you will need the following set of features:

1- Client side :
      . Register -> Enter credentials (first time)
      . Login / block authentication (redirect)
      . View all active users
      . Select user-> chat area opened / Select room
      . Using RSA technique  to encrypt/decrypt all messages sent between clients.
      . See message date & time
      . Disconnect && quit application

2- Server side :

  • Register user : 
          . Add new user to the active directory via LDAP 
          . Create PKI -> get a x509 certificaton via authority server
          . Start communication with the chat/Rabbitmq server
  • Login user :
          . Enter credentials -> verify user in the active directory via LDAP
          . Verify the signature via authority server
  • Chatting :
          . Encrypt /decrypt messages while exchanging them between clients

             Demo architecture

Demo encryption

Features:

  • Save a log of the chat
  • Clear the chat history
  • Emoji button with various emojies to choose from and use
  • Change your username
    • revert to default username
    • view your username history
    • clear your username history
  • Style Customization
    • choose a custom font
    • choose from 6 different color themes
    • revert to default layout
  • Select a default window size of program for everytime it opens
    • return to the default window size whenever

Dependencies

  • RabbitMQ: Messaging Broker based on AMQP protocol
  • pycryptodome: well-documented python library for encryption/decryption..
  • OpenSSL: a python package that provides a high-level interface to the functions in the OpenSSL library such as X509 certs generation.
  • Tkinter: Standard Python interface to the Tk GUI toolkit.
  • cryptography: python library for X509 certs with good API
  • OpenLDAP: is an implementation under ubuntu for LDAP protocol
  • Pika: Rabbitmq python client.

Watch the Video

Setup

You have multiple options to setup your own instance:

1. Open LDAP server in your machine

Clone the TalkyWaly repository locally. In a terminal, run:

$ git clone https://github.com/khalilmejri/talkywalky.git

Our application would have the following folder structure:

 TalkyWalky/
   └── CA/
     ├── ...
     ├── ca_server.py
     ├── ...
     └── certificate_ca.pem
   ├── ...
   ├── server.py
   ├── main.py
   ├── chat.py
   ├── requirements.txt
   ├── ...
   └── client_cert.pem

Installation

# install node modules for the API
$ pip install -r requirements.txt --no-index --find-links file:///tmp/packages

2. Run rabbitMQ service

$ systemctl service rabbitmq start

3. Create an Instance of Messaging-server

$ ./server.py

4. Create an Instance of Authority-server

$ ./CA/ca_server.py

Get your ldap domain string. Almost all your servers need it; keep it safe!

5. Run

Finally, start the main app enjoy :)

# start app client
$ ./main.py

You can now connect to ldap:<ur_ldap_host_address>:389 to start chatting.

Refs

http://www.grotan.com/ldap/python-ldap-samples.html
https://turbogears.readthedocs.io/en/latest/cookbook/ldap-auth.html