2018-02-17 00:13:02 +00:00
2018-06-29 12:47:23 +00:00
# Bitwarden_RS
This project is an unofficial implementation of the [Bitwarden Core Server ](https://github.com/bitwarden/core ) written in [Rust ](https://www.rust-lang.org/ ).
2018-02-10 00:00:55 +00:00
2018-06-29 12:47:23 +00:00
*(Note: This project is not associated with the [Bitwarden ](https://bitwarden.com/ ) project nor 8bit Solutions LLC.)*
2018-02-10 00:00:55 +00:00
2018-06-29 12:47:23 +00:00
# Build/Run
This project can be built and deployed in two ways:
2018-02-10 00:00:55 +00:00
2018-06-29 12:47:23 +00:00
## Docker Setup (Easy)
Install [Docker ](https://www.docker.com/ ) to your system and then, from the project root, run:
2018-05-07 19:33:54 +00:00
```sh
2018-06-29 12:47:23 +00:00
# Build the docker image:
docker build -t bitwarden_rs .
2018-02-10 00:00:55 +00:00
2018-06-29 12:47:23 +00:00
# Run the docker image with a docker volume:
docker run --name bitwarden_rs -t --rm -v bw_data:/data -p 80:80 bitwarden_rs
```
Then visit [http://localhost:80 ](http://localhost:80 )
2018-04-18 11:44:28 +00:00
2018-06-29 12:47:23 +00:00
## Manual Setup (Advanced)
### Dependencies
- `Rust nightly` (strongly recommended to use [rustup ](https://rustup.rs/ ))
- `OpenSSL` (should be available in path, install through your system's package manager or use the [prebuilt binaries ](https://wiki.openssl.org/index.php/Binaries ))
- `NodeJS` (required to build the web-vault, (install through your system's package manager or use the [prebuilt binaries ](https://nodejs.org/en/download/ ))
2018-02-17 00:13:02 +00:00
2018-06-29 12:47:23 +00:00
### Install the web-vault
Download the latest official release from the [releases page ](https://github.com/bitwarden/web/releases ) and extract it.
2018-02-10 00:00:55 +00:00
2018-02-17 17:48:42 +00:00
Modify `web-vault/settings.Production.json` to look like this:
2018-02-10 00:00:55 +00:00
```json
{
"appSettings": {
"apiUri": "/api",
"identityUri": "/identity",
"iconsUri": "/icons",
"stripeKey": "",
"braintreeKey": ""
}
}
```
2018-06-29 12:47:23 +00:00
Then, run the following from the `web-vault` directory:
2018-05-07 19:33:54 +00:00
```sh
2018-02-10 00:00:55 +00:00
npm install
npx gulp dist:selfHosted
```
Finally copy the contents of the `web-vault/dist` folder into the `bitwarden_rs/web-vault` folder.
2018-06-29 12:47:23 +00:00
### Running
```sh
cargo run
```
Then visit [http://localhost:80 ](http://localhost:80 )
## How to recreate database schemas (for developers)
2018-02-10 00:00:55 +00:00
Install diesel-cli with cargo:
2018-05-07 19:33:54 +00:00
```sh
2018-06-12 15:24:29 +00:00
cargo install diesel_cli --no-default-features --features sqlite-bundled
2018-02-10 00:00:55 +00:00
```
Make sure that the correct path to the database is in the `.env` file.
If you want to modify the schemas, create a new migration with:
```
diesel migration generate < name >
```
2018-02-17 00:13:02 +00:00
Modify the *.sql files, making sure that any changes are reverted in the down.sql file.
2018-02-10 00:00:55 +00:00
Apply the migrations and save the generated schemas as follows:
2018-06-12 15:24:29 +00:00
```sh
2018-02-10 00:00:55 +00:00
diesel migration redo
2018-06-12 15:24:29 +00:00
# This step should be done automatically when using diesel-cli > 1.3.0
# diesel print-schema > src/db/schema.rs
2018-02-10 00:00:55 +00:00
```