Skip to content

Commit

Permalink
master # publsih
Browse files Browse the repository at this point in the history
  • Loading branch information
vwxyzjn committed Mar 28, 2020
1 parent 8eceedd commit 6aaf48d
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 64 deletions.
86 changes: 22 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,55 @@
# PortWarden


[![Build Status](https://dev.costa.sh/api/badges/vwxyzjn/portwarden/status.svg)](https://dev.costa.sh/vwxyzjn/portwarden)


This project creates encrypted backups for [Bitwarden](https://bitwarden.com/) vaults including attachments. It pulls your vault items from [Bitwarden CLI](https://github.com/bitwarden/cli) and download all the attachments associated with those items to a temporary backup folder. Then, portwarden zip that folder, encrypt it with a passphrase, and delete the temporary folder.


It addresses this issue in the community forum https://community.bitwarden.com/t/encrypted-export/235, but hopefully Bitwarden will come up with official solutions soon.

## 3/28/20 Update

We now support restoring the backup to an empty account, including attachments.

## Usage Of Portwarden CLI

Go to https://github.com/bitwarden/cli/releases to download the latest version of Bitwarden CLI and place the executable `bw`/`bw.exe` in your `PATH`. Then, go to https://github.com/vwxyzjn/portwarden/releases/ to download the latest release of `portwarden`. Now just follow the steps in the following Gif:
Go to https://github.com/bitwarden/cli/releases to download the latest version of Bitwarden CLI and place the executable `bw`/`bw.exe` in your `PATH`. Then, go to https://github.com/vwxyzjn/portwarden/releases/ to download the latest release of `portwarden`. Now just follow these steps :

![alt text](./portwarden_cli_demo.gif "Portwarden CLI Demo")

```bash
portwarden --passphrase 1234 --filename backup.portwarden encrypt
portwarden --passphrase 1234 --filename backup.portwarden decrypt
# RESTORE IS EXPERIMENTAL!! YOU MAY LOSE YOUR DATA
# IF YOU RESTORE TO YOUR MAIN ACCOUNT
# PLEASE MAKE SURE YOU KNOW WHAT YOU ARE DOING

# Please use a **spare** account for restoring backup
# Portwarden doesn't handle conflicts therefore a
# separate account is needed

# In fact we setup a check to make sure the account your
# are restoring to does not have any data in it
portwarden --passphrase 1234 --filename backup.portwarden restore
```
### Demo Backup

## Usage of Portwarden Server (Setup Scheduled Backup)

Make sure you have [Docker](https://docs.docker.com/install/) installed and ports 8000, 8081, 5000 unused. Then download https://github.com/vwxyzjn/portwarden/blob/master/k8s/docker-compose.build.yaml to a folder and ❗ **name the file `docker-compose.yaml`** ❗ and run
![alt text](./imgs/backup.gif "Portwarden CLI Demo")

```bash
$ # Make sure your server has docker installed.
$ # if you are using remote server, use the following line to forward the server's host to your local machine
$ ssh -L 8000:temp2uk4muy.costa.sh:8000 -L 8081:temp2uk4muy.costa.sh:8081 -L 5000:temp2uk4muy.costa.sh:5000 costa@temp2uk4muy.costa.sh
$ wget https://raw.githubusercontent.com/vwxyzjn/portwarden/master/k8s/docker-compose.build.yaml -O docker-compose.yaml
$ docker-compose up -d
WARNING: Some services (worker) use the 'deploy' key, which will be ignored. Compose does not support 'deploy' configuration - use `docker stack deploy` to deploy to a swarm.
Creating network "portwarden_default" with the default driver
Creating portwarden_redis-commander_1_4e61af10bd41 ... done
Creating portwarden_frontend_1_8671b96c9489 ... done
Creating portwarden_redis_1_63f811026265 ... done
Creating portwarden_scheduler_1_f506c63e5915 ... done
Creating portwarden_worker_1_37de363b0d28 ... done
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
188bfb9d4eba vwxyzjn/portwarden-server-prod:1.7.1 "./scheduler" 11 seconds ago Up 8 seconds 0.0.0.0:5000->5000/tcp portwarden_scheduler_1_127af4e9821a
9cb2a5221b2b vwxyzjn/portwarden-server-prod:1.7.1 "./worker" 11 seconds ago Up 9 seconds 5000/tcp portwarden_worker_1_1a0247e3be8f
c6967ada50c6 redis "docker-entrypoint..." 13 seconds ago Up 11 seconds 6379/tcp portwarden_redis_1_14ee2e0a7e97
472d6d2e7f60 vwxyzjn/portwarden-frontend:1.2.0 "yarn start" 13 seconds ago Up 11 seconds 0.0.0.0:8000->8000/tcp portwarden_frontend_1_55788d316890
ddfbc57a74a0 rediscommander/redis-commander:latest "/usr/bin/dumb-ini..." 13 seconds ago Up 11 seconds 0.0.0.0:8081->8081/tcp portwarden_redis-commander_1_1a656d418a10
```
### Demo Decrypt

After the services are spinned up, go to http://localhost:8000 and follow the steps to setup scheduled backups.
![alt text](./imgs/decrypt.gif "Portwarden CLI Demo")

You will probably have to host Portwarden Server on your machine or server. One caveat is that Portwarden Server does *store your encryption key* (not your master password) and I don't feel comfortable managing your credentials. This server is really for my personal use and a demonstration of the modern architecture for my Software Design class (see below)
### Demo restore

Feel free to watch the following Gif on how to set it up. If you need a control bar, please go to https://imgur.com/a/4Vy1Hat
![alt text](./imgs/restore.gif "Portwarden CLI Demo")

![alt text](./portwarden_server_demo.gif "Portwarden Server Demo")

## Portwarden Compared with Official Bitwarden Backup (As of 12/5/2018)
||Portwarden|Official Bitwarden Backup|
|:---|:---|:---|
|Backend|golang|C#|
|Backup Format|:heavy_check_mark: AES-Encrypted `.portwarden` format| Unencrypted CSV file|
|Backup With Attachments|:heavy_check_mark:|Not supported (see [this feature request](https://community.bitwarden.com/t/allow-attachments-to-be-exported-when-using-export-data))
|Scheduled Backup|:heavy_check_mark: Use Portwarden Server (Experimental)|Not supported|
|Restore Attachments|:heavy_check_mark: Supported|Not supported|

## Contribution & Development

Expand Down Expand Up @@ -117,33 +105,3 @@ Notice the `docker-compose.yaml` file defines the services running and it's moun


PRs are welcome. For ideas, you could probably add a progress bar to the CLI.

## Project Proposal for Software Design Course (SE-575) at Drexel University

This section is experimental and for fun.

I currently taking this class, and our final project is suppose to demonstrate some traits of the modern software architecture. So my teammate [Samridh Prasad](https://github.com/samridhprasad) and I figure we can probably add some components to Portwarden to make it more interesting. Couple initial deliverables are listed below:

### Backend server
- [x] Write a backend server by Go in the `portwarden/web` folder.
- [x] Allow Bitwarden User to login and periodically back up their vault to Google Drive.
- [x] If the user has attachments, download them in every 300 milliseconds because we don't want to get blacklisted. This means we probably want a queue (Maybe use Kafka?) as part of the architecture.
- [ ] Use Let's encrypt to make the server use HTTPS protocal.


### Frontend
- [x] Has a **simple** front end that gets user's username and password and show them if the backup process has begun.
- [x] Allow the user to cancel such backup process if he/she wants.

### System Architecture
We tried to avoid being boxed by a layered architecture and strived to conform to C4 standards best we could and ensured the code reflects the architecture. Overall, we found the lectures and assigned readings to greatly improve our ability to design scalable system architecture.
#### Context Diagram
Figure 1 maps out the basic systems involved with Portwarden and how they interact with each other.
![alt text](./web/diagrams/context.png "Logo Title Text 1")
#### Container Diagram
Figure 2 provides a more in-depth view of the system breaking the system down into containers with arrows depicting the data flow.
![alt text](./web/diagrams/container.png "Logo Title Text 2")
#### Component Diagram
Figure 3 drills down into the most critical containers: the Backend Scheduling Service and the Backend Backup/Worker Service. The boundaries for the containers are clearly marked to provide clarity to the reader.
![alt text](./web/diagrams/component.png "Logo Title Text 3")

2 changes: 2 additions & 0 deletions cmd/portwarden/portwarden.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ var (
func main() {
app := cli.NewApp()

app.Version = "1.0.0"

app.Flags = []cli.Flag{
cli.StringFlag{
Name: "passphrase",
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/kelseyhightower/envconfig v1.3.0
github.com/mattn/go-isatty v0.0.4
github.com/mholt/archiver v2.1.0+incompatible
github.com/mitchellh/gox v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
github.com/nwaples/rardecode v1.0.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand All @@ -46,6 +48,10 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mholt/archiver v2.1.0+incompatible h1:1ivm7KAHPtPere1YDOdrY6xGdbMNGRWThZbYh5lWZT0=
github.com/mholt/archiver v2.1.0+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI=
github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs=
Expand Down
Binary file added imgs/backup.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/decrypt.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/restore.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6aaf48d

Please sign in to comment.