- The password is stored in the form of a hash in the database, to avoid direct exposure to any user:
- All the user actions including logging, registration, CRUD Operations, and permission granting/revoking are logged in the database as follows:
- Tasks and Notes are stored in different tables with their respective title and content.
- 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.
- app/management/constants.py -> All the possible constants across the access_manager.py file.
- app/management/constants.py -> All the possible constants across all files.
- app/models.py -> UserManager, User, UserActionLog, Task, Note models with validations and related functions
- app/models/user_utils.py -> All the functions for implementing logging, registration, CRUD operations and permission granting/revoking by the admin etc.
-
Download and extract the zip file.
-
Download and install MySQL or install via Terminal - brew install MySQL
-
Start MySQL server: brew services start MySQL
-
(Optional) Set MySQL Password, MySQL Root Password
-
Install Docker and start the Docker daemon
-
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 -
MySQL server is now hosted which automatically creates database "user_management_db" (If you have set MySQL Root Password, update the Dockerfile accordingly)
-
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 -
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 -
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 -
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 -
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 -
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
-
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.