diff --git a/README.md b/README.md index 1514f9b..8121b67 100644 --- a/README.md +++ b/README.md @@ -1,124 +1,73 @@ # BitBetter - -BitBetter is is a tool to modify bitwardens core dll to allow you to generate your own individual and organisation licenses. Please see the FAQ below for details on why this software was created. - -_Beware! BitBetter does janky IL magic to rewrite the bitwarden core dll and install a self signed certificate. Use at your own risk!_ - -Credit to https://github.com/h44z/BitBetter and https://github.com/jakeswenson/BitBetter - -# Table of Contents -1. [Getting Started](#gettingstarted) - + [Pre-requisites](#prereq) - + [Setting up BitBetter](#setup) - + [Building BitBetter](#building) - + [Generating Signed Licenses](#generating) -2. [FAQ](#faq) -3. [Footnotes](#footnotes) - -# Getting Started -The following instructions are for unix-based systems (Linux, BSD, macOS), it is possible to use a Windows systems assuming you are able to enable and install [WSL](https://docs.microsoft.com/en-us/windows/wsl/install-win10). - -## Pre-requisites -Aside from docker, which you also need for Bitwarden, BitBetter requires the following: - -* openssl (probably already installed on most Linux or WSL systems) -* dotnet-sdk-2.1 (install instructions can be found [here](https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-2.1.604)) - -## Setting up BitBetter -With your pre-requisites installed, begin the installation of BitBetter by downloading it through Github or using the git command: - -```bash -git clone https://github.com/online-stuff/BitBetter.git +./update-bitwarden.sh param1 param2 param3 ``` +`param1`: The path to the directory containing your bwdata directory -First, we need to add the correct version of Newtonsoft.Json to the license generator and the BitBetter docker directories. +`param2`: If you want the docker-compose file to be overwritten (either `y` or `n`) -```bash -cd BitBetter/src/licenseGen/ -dotnet add package Newtonsoft.Json --version 12.0.1 +`param3`: If you want the bitbetter images to be rebuild (either `y` or `n`) -cd ../bitBetter -dotnet add package Newtonsoft.Json --version 12.0.1 -``` +If you are updating from versions <= 1.46.2, you may need to run `update-bitwarden.sh` twice to complete the update process. -Next, we need to generate the self-signed certificate we will use to sign any licenses we generate. - -To sign your own license you first need to generate your own signing cert using the `.keys/generate-keys.sh` script. - -Running this script will prompt you to enter some information about your new certificate, you may leave these at the defaults or set them to your preference. The script will then create a pkcs12 file (.pfx) containing your new key/cert. - -You may also choose to do this manually via the following commands. - -```bash -openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.cert -days 36500 -outform DER -passout pass:test -openssl x509 -inform DER -in cert.cert -out cert.pem -openssl pkcs12 -export -out cert.pfx -inkey key.pem -in cert.pem -passin pass:test -passout pass:test -``` - -Note that the password here must be `test`.[1](#f1) - -## Building BitBetter - -Now that you've generated your own own self-signed certificate, you can run the main `BitBetter/build.sh` script to generate a modified version of the `bitwarden/api` docker image. - -From the BitBetter directory, simply run: -```bash -./build.sh -``` - -This will create a modified version of the official `bitwarden/api` called `bitbetter/api`. You may now simply edit your bitwarden docker-compose.yml to utilize the modified image. - -Edit your `/path/to/bwdata/docker/docker-compose.yml`. - -> Replace `image: bitwarden/api:x.xx.x`
with `image: bitbetter/api` - -You'll also want to edit the `/path/to/bwdata/scripts/run.sh` file. In the `function restart()` block, comment out the call to `dockerComposePull`. - -> Replace `dockerComposePull`
with `#dockerComposePull` - -You can now start or restart Bitwarden as normal and the modified api will be used. It is now ready to accept self-issued licenses. - -## Generating Signed Licenses +## Generating Signed Licenses There is a tool included in the directory `src/licenseGen/` that will generate new individual and organization licenses. These licenses will be accepted by the modified Bitwarden because they will be signed by the certificate you generated in earlier steps. -First, from the `BitBetter/src/licenseGen` directory, build the license generator.[2](#f2) +First, from the `BitBetter/src/licenseGen` directory, **build the license generator**.[2](#f2) ```bash ./build.sh ``` -Now, from the `BitBetter/src/licenseGen` directory, you can run the tool to generate licenses. +In order to run the tool and generate a license you'll need to get a **user's GUID** in order to generate an **invididual license** or the server's **install ID** to generate an **Organization license**. These can be retrieved most easily through the Bitwarden [Admin Portal](https://help.bitwarden.com/article/admin-portal/). -You'll need to get a user's GUID in order to generate an invididual license and the server's install ID to generate an Organization license. These can be retrieved most easily through the Bitwarden [Admin Portal](https://help.bitwarden.com/article/admin-portal/). +**The user must have a verified email address at the time of license import, otherwise Bitwarden will reject the license key. Nevertheless, the license key can be generated even before the user's email is verified.** + +If you generated your keys in the default `BitBetter/.keys` directory, you can **simply run the license gen in interactive mode** from the `Bitbetter` directory and **follow the prompts to generate your license**. ```bash -./run.sh ~/BitBetter/.keys/cert.pfx user "Name" "EMail" "User-GUID" -./run.sh ~/BitBetter/.keys/cert.pfx org "Name" "EMail" "Install-ID used to install the server" +./src/licenseGen/run.sh interactive ``` -The license generator will spit out a JSON-formatted license which can then be used within the Bitwarden web front-end to license your user or org! +**The license generator will spit out a JSON-formatted license which can then be used within the Bitwarden web front-end to license your user or org!** -# FAQ: Questions (you might have?) +--- -I'll work on updates in the next couple weeks, right now, I just wanted something to start with. +### Note: Alternative Ways to Generate License -## But why? Its open source? +If you wish to run the license gen from a directory aside from the root `BitBetter` one, you'll have to provide the absolute path to your cert.pfx. -Yes, bitwarden is great. If I didn't care about it i wouldn't be doing this. -I was bothered that if i want to host bitwarden myself, at my house, -for my family to use (with the ability to share access) I would still have to pay a monthly ENTERPRISE organization fee. -To host it myself. And maintain it myself. Basically WTH was bitwarden doing that I was paying them for? +```bash +./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx interactive +``` -## You should have reached out to bitwarden +Additional, instead of interactive mode, you can also pass the parameters directly to the command as follows. -Thanks, good idea. And I did. Currently they're not focused on solving this issue - yet. -To be clear i'm totally happy to give them my money. Offer a perpetual server license, and i'd pay for it. Let me license the server, period. Allow an orginzation to have Premium for all users.. 500 seats, let the 500 users in the orginzation have the Premium features too. +```bash +./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx user "Name" "E-Mail" "User-GUID" ["Storage Space in GB"] ["Custom LicenseKey"] +./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx org "Name" "E-Mail" "Install-ID used to install the server" ["Storage Space in GB"] ["Custom LicenseKey"] +``` -I'm still in the testing/evaluating phase. If I am hosting the server/data, let me license the server, period. How many licenses does one user need to have... +--- -# Footnotes -1 If you wish to change this you'll need to change the value that `src/licenseGen/Program.cs` uses for it's `GenerateUserLicense` and `GenerateOrgLicense` calls, but this is really unnecessary as this certificate does not represent any type of security issue. +# FAQ: Questions you might have. -2This tool build ontop of the `bitbetter/api` container image so make sure you've built that above using the root `./build.sh` script. \ No newline at end of file +## Why build a license generator for open source software? + +We agree that Bitwarden is great. If we didn't care about it then we wouldn't be doing this. We believe that if a user wants to host Bitwarden themselves on their own infrastructure, for their family to use, and with the ability to share access, they should still pay the fee charged by the software publishers. + +Such use cases may not require enterprise level support and unfortunately Bitwarden doesn't have any method for receiving donations - therefore we recommend you purchasing the relevant licenses for your use directly from Bitwarden: https://bitwarden.com/pricing/. + +## Shouldn't you have reached out to Bitwarden to ask them for alternative licensing structures? + +In the past we have done so but they were not focused on the type of customer that would want a one-time license and would be happy to sacrifice customer service. We believe the features that are currently behind this subscription to be critical ones and believe they should be available to users who do not require an enterprise structure. We'd even be happy to see a move towards a Gitlab-like model where premium features are rolled out *first* to the enterprise subscribers before being added to the fully free version. + +UPDATE: Bitwarden now offers a cheap license called [Families Organization](https://bitwarden.com/pricing/) that provides premium features and the ability to self-host Bitwarden for six persons. Please use this option as it is the correct and supported method by Bitwarden. + + +# Footnotes + +1 If you wish to change this you'll need to change the value that `src/licenseGen/Program.cs` uses for its `GenerateUserLicense` and `GenerateOrgLicense` calls. Remember, this is really unnecessary as this certificate does not represent any type of security-related certificate. + +2This tool builds on top of the `bitbetter/api` container image so make sure you've built that above using the root `./build.sh` script.