soumyarao17 / user_management_app

A user management system with RBAC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User Management System with Role-Based Access Control

Output/Screenshots -

  1. The password is stored in the form of a hash in the database, to avoid direct exposure to any user:
Screenshot 2023-09-27 at 9 17 07 PM
  1. All the user actions including logging, registration, CRUD Operations, and permission granting/revoking are logged in the database as follows:
Screenshot 2023-09-27 at 9 19 22 PM
  1. Tasks and Notes are stored in different tables with their respective title and content.
Screenshot 2023-09-27 at 9 19 59 PM

Code flow -

  1. app/management/commands/access_manager.py -> Implementation of the command line interface (CLI) for performing core functions such as registration, logging in/out, displaying options, permissions, tasks/notes, navigate_from_options etc.
  2. app/management/constants.py -> All the possible constants across the access_manager.py file.
  3. app/management/constants.py -> All the possible constants across all files.
  4. app/models.py -> UserManager, User, UserActionLog, Task, Note models with validations and related functions
  5. app/models/user_utils.py -> All the functions for implementing logging, registration, CRUD operations and permission granting/revoking by the admin etc.

Execution Setup -

  1. Download and extract the zip file.

  2. Download and install MySQL or install via Terminal - brew install MySQL

  3. Start MySQL server: brew services start MySQL

  4. (Optional) Set MySQL Password, MySQL Root Password

  5. Install Docker and start the Docker daemon

  6. Host MySQL server on Docker container and expose it to port 3306. Use commands -
    (Ensure you are in the project home directory)
    Build - docker build -f docker/db/Dockerfile -t user_management_db .
    Run - docker run --network=host -it --expose 3306 -p 3306:3306 user_management_db

  7. MySQL server is now hosted which automatically creates database "user_management_db" (If you have set MySQL Root Password, update the Dockerfile accordingly)

  8. Build and run docker for user management commands:
    Build - docker build -f docker/cli/Dockerfile -t user_management_system .
    Run - docker run --network=host -it --expose 8000 -p 8000:8000 user_management_system

  9. Open Docker Desktop and run a terminal in the user_management_system container
    OR
    docker images | grep user_management_system # Copy id
    docker run -i -t /bin/bash

  10. Testing and Output:

  • Run the command: 'python manage.py access_manager'

  • Home Page: Choose from options R, LI, LO, -1 to perform the desired operation
    a) Options:
    R. Register - New User Registration - (By default the first user is assigned as the admin, who can then grant/revoke permission to others)
    LI. Login - Existing User Login
    LO. Logout - User Log out
    -1. Exit - Exit Program

    image
    image

  • Enter 'username' and 'password' during logging in or registration stage. Also, add whether you are an "Admin" or not.

  • Choose from options:
    N. Notes - To perform operations on notes
    T. Tasks - To perform operations on notes
    A. Admin Panel - To grant/revoke addition/deletion/updation/view access to other users
    HP. Home Page - To return to Home Page
    LO. Logout - To log out of the account
    -1. Exit - Exit Program

    image
  • Notes:
    ND. Show Note Detail - To show the detail of a note by its id
    CN. Create Note - To create a new note
    UN. Update Note - To update the contents of a note
    DN. Delete Note - To delete a note

    image
  • Tasks:
    TD. Show Task Detail - To show the detail of a task by its id
    CT. Create Task - To create a new task
    UT. Update Task - To update the contents of a task
    DT. Delete Task - To delete a task

image
  • Admin Panel:
    V_A. Add/Remove view access - To grant or revoke view access to/from a user
    U_A. Add/Remove update access - To grant or revoke update access to/from a user
    A_A. Add/Remove add access - To grant or revoke add access to/from a user
    D_A. Add/Remove delete access - To grant or revoke delete access to/from a user
    The user can then further choose the resource whose permission needs to be updated, the username of the user and the access option (add or delete) to perform permission based operations.

    image
    image

About

A user management system with RBAC


Languages

Language:Python 99.0%Language:Dockerfile 1.0%