Git Product home page Git Product logo

primistore's Introduction

PrimiStore

Primistore is a password management application that provides a solution to secure your important (or even less important) passwords and provides suggestions regarding safe password practices.

How does it work?

Encryption

  • Users generate unique AES keys and a unique character set (i.e. a way to map characters to numbers) for each of their passwords.
  • They then use these unique keys (per password) to encrypt the password and store it as an image (details about how this image is used can be found below).
  • They then download the resulting image, that contains their encrypted password and keep it on a storage device of their choice (or in their own device).

Decryption

  • User will upload the image they have on their device.
  • The image will be decrypted into stream of bits (using the algorithm described below).
  • The decrypted bits are then converted to characters using the unique character set.
  • Finally they are decrypted using the AES keys and sent back to the client.

What is the server storing?

  • The server only stores the AES keys and unique character sets for each password that is used to encrypt and decrypt the password. It never stores the actual password image for security reasons. Thus, even if the server is compromised, the passwords are safe.

Target device

  • The entire app (frontend/backend) is meant to be served from a Raspberry Pi running a Ubuntu Server 22.04 LTS image. The choice was made, as PIs are cheap and can be easily used as small home servers.

Documentation

Steps to run

Pre-Requisites

  • Before installing anything else, I recommend downloading and installing OpenSSL. OpenSSL is an open source library for all things encryption/hashing. It is used in this project for AES encryption/decryption. So, without OpenSSL, this application is pretty much useless.

Install and run

The project can be run either using PM2 process manager (requires installation of Node.js and PM2) or inside a docker container (nothing required other than docker). Out of the two docker is probably an easy solution for most.

Both steps require you to clone the repository:

$ git clone https://github.com/frankhart2018/primistore.git

Let's dive into the individual steps for both of the above listed processes.

Using PM2

  1. Install Node.js for your platform (I am not going to tell you how to do it, just google it).

  2. Install React dependencies:

$ cd frontend
$ npm i
  1. Install Node dependencies:
$ cd microservices/password-manager
$ npm i
  1. Install FastAPI dependencies:
$ cd microservices/image-decryptor
$ pip install -r requirements.txt
  1. Install pm2 globally:
$ npm i -g pm2
  1. Install MongoDB for your platform (Again, not going to tell you, google it).

  2. Run all microservices:

$ cd frontend
$ pm2 start --name frontend npm -- start
$ pm2 start --name mongo "<command-for-running-mongo>"
$ cd ../microservices/password-manager
$ pm2 start --name password-manager npm -- start
$ cd ../image-decryptor
$ pm2 start --name image-decryptor "gunicorn -k uvicorn.workers.UvicornWorker app:app"

Note: Replace the <command-for-running-mongo> with an actual command for your platform, e.g. if you are on macOS and you installed mongo using homebrew then the command for running mongo is:

mongod --config /opt/homebrew/etc/mongod.conf

and thus the mongo pm2 command becomes:

$ pm2 start --name mongo "mongod --config /opt/homebrew/etc/mongod.conf"

Finally the app should be up and running, so easy wasn't it?

Using Docker

  1. Create a directory to hold charsets:
$ mkdir charsets
  1. Find IP address of the host (ifconfig for macOS and Linux systems, ipconfig for windows).

  2. Use docker-compose (install this if you don't already have it):

$ IP=<IP> REACT_APP_PI=<true/false> LOCAL_DIR=<charset-dir-path> docker-compose up -d

Note: For the first time it will take some time, for later runs, docker will cache things (I hope you have a high level idea of how docker works, if not google it). The REACT_APP_PI should be turned on (i.e. set to true) if the app is being run on a raspberry pi, otherwise it can be turned off (i.e. set to false)

License

This project is licensed under MIT License.

primistore's People

Contributors

anglerfishlyy avatar benikk avatar dhairyaj avatar frankhart2018 avatar minavkaria avatar sumitkumar-17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

primistore's Issues

Delete passwords even if charset file is missing

Currently if the charset file is missing, the delete endpoint: DELETE /password/:pass_uid fails with 500 when the deletion of charset fails (possible because it does not exist). This is not really required, if it cannot delete it should just move one and delete the database entry and return 200 (already exists).

Design a basic protocol to run commands in pipe

For both downloading (#35) and restoring (#36) backups, commands need to be run on the host, this can be achieved using the existing runCommandInPipe function, but currently it is designed to run only a single command (i.e. the device info command - /usr/bin/landscape-sysinfo). To make it more generic a standard messaging protocol needs to be established while sending command to the pipe, and another protocol needs to be set for sending output and caching.

Option to delete a password

Delete a password (i.e. the AES key + iv and the charset entry from DB and the file containing the charset).

Add option to restore from backup in Pi

In case someone messes up and rotates AES key or charset before they saved their decrypted current password, they will never be able to access (or decrypt) their password. Add this button to the new Device Admin tab, this will ask the user if they want to restore to that point using the snapshot tarball they upload and in that case will restore mongo and charsets to that point.

Option to select either upper or lower or both case alphabets

Currently the safe password generator component does not allow user to select either of upper or lowercase alphabets. It is not necessary that every site allows for uppercase alphabets, enforcing everyone to use both types of alphabets is not right.

Multiple profile support

When the app is deployed to a single server, multiple profiles will allow users to separate their passwords from other people sharing the server access.

Add issues

As the maintainer of a Collaborate repo, keeping Issues up-to-date will help the student community understand what they can do to contribute. Issues should vary by the easy (update documentation) to the difficult (add a new feature). The more involved you are, the more opportunities there are to collaborate.

Recommendations:

Add issues of varying difficulty to the repo often. you must add the tag GSSoC'24, Level 1, Level2, Level 3 good first issue etc.
How we cacluclate the Scores on Leaderboard: Every PR one point
Level 1: 10 points
Level 2: 25 points
Level 3: 45 points
Try to add some documentation issues as well it would be easy for beginner contributor to explore opensource through your repo.
Generate issues even if you plan on solving them, so the repository appears as active.
Contribute/commit often to the repo so it does not go stale.
Reference https://github.com/Recode-Hive/Stackoverflow-Analysis/issues

Add edit password option

Third of many issues for #40 project.

Add a new page to edit password, give an option for each password to go to this page.

  1. Move the Rotate AES Key + IV button to this page.
  2. Move the Rotate Charset button to this page.
  3. Move delete password button to this page.
  4. Provide a select box (that loads all existing policies, with current policy selected as default), and an option to choose other policies.

On clicking edit, after selecting a policy in number 4, stay in the same page.

Add upload progress in frontend

When hosted on a raspberry pi (or any other device on the network), there is a slight delay during uploading the PMS file, the user has no idea if anything is working or not, and can accidentally send multiple upload requests, which might lead to unforeseen results. Display an upload progress bar on the frontend.

Learn.md

Learn repos should have a LEARN.md file to teach student how to build your project step by step. You can explain how to build your project with text, code snippets, images, or even short (5 minute) long video lessons. As the maintainer of a Learn repo, the LEARN.md file requires you to think critically about how to explain the building of your project and how to also make it engaging. We don't expect you to be an expert teacher, but we would like you to reflect on how difficult it was to get to your level of knowledge, and then provide friendly guidance to help other students to learn.

Reference: https://github.com/Recode-Hive/Stackoverflow-Analysis/blob/main/Learn.md

Home page is not really required

The home page (MainMenu component) with all the links is not really required, the default home can be ListPasswords component. And all the links are already in navbar, there's no need for duplicating all the links in home page.

Display time in logs in password-manager

Password manager does have API logs along with the status code returned, but for further helping in debugging, it would make sense to add the time when the log was generated (in the local time zone of course).

Add templates for issues

Issue templates are very helpful for a collaboration repo. When users identify a bug or want to add a new feature, you can provide templates so you can collect all the pertinent information you need to fix a bug or add a new feature.

We recommend creating a “Report Bug” and “Feature Request” issue template.
you can refer this: https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository

Some suggested prompts/questions you can add to a “Report Bug” template are:

Briefly describe the bug
What is the expected behavior?
Please provide step by step instructions on how to reproduce the bug
Some suggested prompts/questions you can add to a “Feature Request” issue template are:

Briefly describe your feature request
What problem is this feature trying to solve?
How do we know when the feature is complete?

Reference: https://github.com/Recode-Hive/Stackoverflow-Analysis/issues/new/choose
Click on Get Started button and copy the template to yours.

Convert encrypted password to image asynchronously

The encrypted password is converted to data URL in frontend/src/components/EncryptPassword/EncryptPassword.js. This slows down the experience when download image button is clicked. This process of converting the string to data URI can be done asynchronously after the encrypted password is fetched and stored in local storage. When download is clicked, it can be loaded from local storage, thus instantly downloading after the button is pressed.

Option to remove or add special characters

Currently the list of special characters is hardcoded into the function, which might generate a password that a website does not allow for. Give the option to remove or add from the special characters list.

Copy decrypted password to clipboard

When decrypted password shows up in DecryptPassword component, user has to manually copy the password. It should automatically be copied into clipboard and the user should be notified (maybe an alert that the password is copied).

NTP has to be forced everytime in RPI

This is not ideal as time is of utmost importance for calculating the age of keys and charset. Fix this on startup in raspberry PI, maybe add this to the script that runs on container spin up.

Script to backup from pi server

When travelling the Pi might not be with you, so it is best to have a script to generate a snapshot of the mongo data and the charset's directory and another script that can be used to load from the snapshot.

prompt user to install net tools in pi

archi@ubuntu:~/primistore/pi$ ifconfig | grep inet
Command 'ifconfig' not found, but can be installed with:
sudo apt install net-tools

ifconfig is not installed by default in pi, which leads to following error :-

 python3 get_current_ip.py 
Traceback (most recent call last):
  File "/home/archi/primistore/pi/get_current_ip.py", line 18, in <module>
    get_ip()
  File "/home/archi/primistore/pi/get_current_ip.py", line 14, in get_ip
    raise RuntimeError(f"Cannot determine a single IP, found: {ips}")
RuntimeError: Cannot determine a single IP, found: []

Add a basic README

The README should contain the following:

  1. An overview of the project.
  2. High level design.
  3. A link to the image processing algorithm wiki.
  4. Steps to run the application (without docker).
  5. Steps to run the application (with docker).
  6. Licensing information (with link).

Add option to set rotation rules

Currently the rotation rules are hardcoded and the colors thus displayed are due to those hardcoded thresholds. Add an option to save this in the database and allow users to modify this.

Add a page to generate password

The page should be frontend only and provides capability just to generate passwords, not encode or store them in any way. There should be three range bars for setting the percent of alphabets, special characters, and numbers. There should be a text box (that accepts only numbers) to get the number of digits in the password and then a button (duh) to generate the password.

Backfill the policy id to existing passwords

Second of many issues for #40 project.

Backfill the existing passwords with a default policy id. The config for this policy would look like:

{
    "name": "default",
    "updateWindowMin": 20, 
    "updateWindowMax": 30,
}
  1. Add this entry.
  2. Get the object id and backfill existing passwords.
  3. Do not update the prod database, do it locally. Use this to restore when prod is upgraded to v0.5.

Investigate encrypted image download time

When an encrypted image is downloaded from the encrypt password page, it takes some time to generate the image and make it available for download, which is not optimal. Investigate if this can be sped up, or if there is no possibility of speed up and a please wait option so the user knows something is going on and the app is not actually stuck.

Display password stats after decryption

Display the following stats about the along with the decrypted password in decrypt page:

  1. Length of password
  2. Percentage of alphabetes
  3. Percentage of digits
  4. Percentage of special characters
  5. Does it have uppercase alphabets
  6. Does it have lowercase alphabets

This helps when creating a new password, I usually prefer to keep password stats same for the same account.

Change font family

The current font family makes it very hard to distinguish between lowercase L (l) and uppercase I (I). Which leads to confusion while using the passwords.

Add the version information in the app

Adding version information would let the user find out what features they have or don't have based on the milestones here in Github (and probably a Changelog document later). It should be clearly visible to the user. This needs to be done ASAP, as currently there is a single version (0.1) but after 0.2 is released, it would be difficult to find out what enhancements/bug fixes are in the installed version.

Girlscript Summer of Code Introduction/Tracking

👋 Hi @frankhart2018,

I am Prince,web developer Girlscript Summer of Code. I'll be collaborating with you on preparing your repo for GSSoC'24 Program

Why are these changes required?
After Analysing last year's contributions and feedback it would be great for students to have a couple of standard readme files on the repo to understand what the project is all about and some issues detailing what they can contribute. This will help you to see increased engagement in your repository as well.

As mentioned students get a chance to learn step by step, how to build this project as well as invite mentors to collaborate and add features to this repo. I will generate issues, which will provide guidance on how to prepare your repo for Girlscript summer of code 2024 on 10th May.

This issue will serve as a tracking issue to track all issues related to GSSoC'24. I recommend creating a new branch for every issue and opening a pull request to track changes so we can effectively collaborate with each other and merge changes when you and I feel like those changes are ready to be merged on your primary branch.

If you have any questions or concerns, please feel free to leave a comment on this issue or any of the other issues that are generated.

I look forward to working with you :octocat:

Upgrade option in UI

Right now to upgrade version, the user has to manually pull the latest docker images and re-build the containers using these new images. This should be automated.

UX is super confusing

create a wiki page describing in detail steps to create, store and use the passwords securely

Add option to download backup in Pi

Currently backup is done using a bash script, which is not optimal as it requires user to login to their Pi server. Instead provide a single button in the UI (update Device Info -> Device Admin and add it there) to generate and download backup for mongo and charset directory.

Script to fetch IP

A script to fetch IP which can be used to spin up the docker containers will be very helpful to automate the whole process of spinning up containers on the PI.

Use loaded policies to update color in ListPasswords

Fourth of many issues for #40 project.

Now that everything is set up, it's time to wire it all up.

  1. Add an endpoint: GET /policy/:policyId, that returns:
{
    "updateWindowMin": 20, 
    "updateWindowMax": 30,
}
  1. Use this to update the colors, instead of using the hardcoded thresholds in ListPasswords component.

Add Topics

In GSSoC'24, GitHub Topics will help the discoverability of your project.

I see that you already have great topics on your repository!
I would recommend adding the name of the company like the software you use to build like "vs-code, ghdesktop" to improve your discoverability.

If you are happy with the topics you have, feel free to close this issue. 👍

Support error handling in frontend

The errors propagated from the backend are not displayed in the frontend, so if anything goes wrong (especially while running OpenSSL commands), there's no way for the user to find out what went wrong, which is not a nice experience (especially for someone running things inside docker containers, it will be painful to search for error logs).

Script to spin up docker container

A simple script that can be executed on bootup to use the IP script to fetch the IP and use spin up docker containers in raspberry PI.

Support for adding a new policy

First of many issues for #40 project.

  1. Add a new schema, model and DAO for policy collection.
  2. Add a new POST endpoint - POST /policy:
{
    "name": "string",
    "updateWindowMin": "num", 
    "updateWindowMax": "num", 
}
  • updateWindowMin: Number of days before the safe update window
  • updateWindowMax: Number of days till upper limit of safe update window, after this the rotation will be overdue
  1. Add a new page in frontend to add this new policy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.