12 Commits
Author SHA1 Message Date
captainhook 3bc35ecf76 Merge branch 'develop' 2024-03-04 21:56:53 +00:00
captainhook 0b170fd0d8 correct readme 2024-03-04 21:50:21 +00:00
captainhook c6c4232f46 update README 2024-03-04 21:43:54 +00:00
captainhook fcc22a7d7a update licenseGen.csproj to match latest 2024-03-04 21:43:42 +00:00
Jan SchöppachandGitHub 3c703f517d Update to .NET 8.0 to fix building with bitwarden v2024.2.2 (#187)
* Update to .NET 8.0 to fix building with bitwarden v2024.2.2

* Also update license gen to .NET 8.0
2024-02-22 23:16:34 +00:00
RakeshandGitHub b93c9487eb Update License to use Secrets Manager fully (#182) 2024-01-19 18:02:14 +00:00
AyitakaandGitHub e173c06320 Updated license version to 12, added SM options, increased max seats (short to int) (#172)
* - Updated license version to 12
- Added new SM license options

* Change seats, smseats, smserviceaccounts from short to int, like they are in the Bitwarden server code, to allow for the accurate maximum amount of seats
2023-11-29 12:07:21 +00:00
AyitakaandGitHub 80c0808e72 Update licenseGen with latest version and options (#165)
- Changed Version to 10
- Uncommented UseScim
- Added UseCustomPermissions
2023-04-21 14:24:41 +02:00
Jeff Alyanak 8e6429d533 Bumped Newtonson.Json version
Never versions of the dotnet-sdk have issues with older Newtonsoft versions. 12.0.1 seems to satisfy the widest variety of sdk versions.
2019-05-29 14:05:08 -04:00
Jeff Alyanak 692f2fd1c5 Merge branch 'docs' into develop 2019-05-17 14:24:18 -04:00
Jeff Alyanak 1182108026 Updated Docs
I've taken the steps written out by @online-stuff and consolidated/organized them into the README. This closes #13.

In a future update it might be worth adding a docs/ directory and breaking the readme into several docs that link to one another.
2019-05-17 14:18:44 -04:00
Jeff Alyanak 05543b5b8a Added a Key Generating script
To make the keygen process a bit easier I've added a `generate-keys.sh` script that can be found in the `.keys` directory. It will generate the key & cert and bundle them into the required pkcs#12 file.

I've updated the readme to include instructions on the script.
2019-05-11 15:45:03 -04:00
7 changed files with 129 additions and 11 deletions
+112
View File
@@ -6,6 +6,7 @@ Please see the FAQ below for details on why this software was created.
_Beware! BitBetter does janky stuff to rewrite the bitwarden core dll and allow the installation of a self signed certificate. Use at your own risk!_ _Beware! BitBetter does janky stuff to rewrite the bitwarden core dll and allow the installation of a self signed certificate. Use at your own risk!_
Credit to https://github.com/h44z/BitBetter and https://github.com/jakeswenson/BitBetter
Credit to https://github.com/h44z/BitBetter and https://github.com/jakeswenson/BitBetter Credit to https://github.com/h44z/BitBetter and https://github.com/jakeswenson/BitBetter
# Table of Contents # Table of Contents
@@ -102,7 +103,74 @@ You can either run this script without providing any parameters in interactive m
If you are updating from versions <= 1.46.2, you may need to run `update-bitwarden.sh` twice to complete the update process. If you are updating from versions <= 1.46.2, you may need to run `update-bitwarden.sh` twice to complete the update process.
## Generating Signed Licenses ## Generating Signed Licenses
This will create a new self-signed certificate in the `.keys` directory if one does not already exist and then create a modified version of the official `bitwarden/api` called `bitbetter/api` and a modified version of the `bitwarden/identity` called `bitbetter/identity`.
You may now simply create the file `/path/to/bwdata/docker/docker-compose.override.yml` with the following contents to utilize the modified images.
```yaml
version: '3'
services:
api:
image: bitbetter/api
identity:
image: bitbetter/identity
```
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`<br>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.**
---
### Note: Manually generating Certificate & Key
If you wish to generate your self-signed cert & key manually, you can run 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`.<sup>[1](#f1)</sup>
---
## Updating Bitwarden and BitBetter
To update Bitwarden, the provided `update-bitwarden.sh` script can be used. It will rebuild the BitBetter images and automatically update Bitwarden afterwards. Docker pull errors can be ignored for api and identity images.
You can either run this script without providing any parameters in interactive mode (`./update-bitwarden.sh`) or by setting the parameters as follows, to run the script in non-interactive mode:
```bash
./update-bitwarden.sh param1 param2 param3
```
`param1`: The path to the directory containing your bwdata directory
`param2`: If you want the docker-compose file to be overwritten (either `y` or `n`)
`param3`: If you want the bitbetter images to be rebuild (either `y` or `n`)
If you are updating from versions <= 1.46.2, you may need to run `update-bitwarden.sh` twice to complete the update process.
## 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**.<sup>[2](#f2)</sup>
```bash
./build.sh
```
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/).
**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**.
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. 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.
@@ -134,6 +202,22 @@ If you wish to run the license gen from a directory aside from the root `BitBett
./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx interactive ./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx interactive
``` ```
Additional, instead of interactive mode, you can also pass the parameters directly to the command as follows.
./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!**
---
### Note: Alternative Ways to Generate License
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.
```bash
./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx interactive
```
Additional, instead of interactive mode, you can also pass the parameters directly to the command as follows. Additional, instead of interactive mode, you can also pass the parameters directly to the command as follows.
```bash ```bash
@@ -165,3 +249,31 @@ UPDATE: Bitwarden now offers a cheap license called [Families Organization](http
<a name="#f2"><sup>2</sup></a>This tool builds on top of the `bitbetter/api` container image so make sure you've built that above using the root `./build.sh` script. <a name="#f2"><sup>2</sup></a>This tool builds on top of the `bitbetter/api` container image so make sure you've built that above using the root `./build.sh` script.
./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"]
```
---
# FAQ: Questions you might have.
## 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, in their house, for their family to use and with the ability to share access, they would still have to pay a **monthly** enterprise organization fee. When hosting and maintaining the software yourself there is no need to pay for the level of service that an enterprise customer needs.
Unfortunately, Bitwarden doesn't seem to have any method for receiving donations so we recommend making a one-time donation to your open source project of choice for each BitBetter license you generate if you can afford to do so.
## 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 paywall to be critical ones and believe they should be available to users who can't afford an enterprise payment 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.
# Footnotes
<a name="#f1"><sup>1</sup></a> 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.
<a name="#f2"><sup>2</sup></a>This tool builds on top of the `bitbetter/api` container image so make sure you've built that above using the root `./build.sh` script.
+1 -1
View File
@@ -13,7 +13,7 @@ echo "Building BitBetter for BitWarden version $BW_VERSION"
cp "$DIR/.keys/cert.cert" "$DIR/src/bitBetter/.keys" cp "$DIR/.keys/cert.cert" "$DIR/src/bitBetter/.keys"
docker run --rm -v "$DIR/src/bitBetter:/bitBetter" -w=/bitBetter mcr.microsoft.com/dotnet/sdk:6.0 sh build.sh docker run --rm -v "$DIR/src/bitBetter:/bitBetter" -w=/bitBetter mcr.microsoft.com/dotnet/sdk:8.0 sh build.sh
docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/api:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/api "$DIR/src/bitBetter" # --squash docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/api:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/api "$DIR/src/bitBetter" # --squash
docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/identity:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/identity "$DIR/src/bitBetter" # --squash docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/identity:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/identity "$DIR/src/bitBetter" # --squash
+1 -1
View File
@@ -1,7 +1,7 @@
ARG BITWARDEN_TAG ARG BITWARDEN_TAG
FROM ${BITWARDEN_TAG} FROM ${BITWARDEN_TAG}
COPY bin/Debug/netcoreapp6.0/publish/* /bitBetter/ COPY bin/Release/netcoreapp8.0/publish/* /bitBetter/
COPY ./.keys/cert.cert /newLicensing.cer COPY ./.keys/cert.cert /newLicensing.cer
RUN set -e; set -x; \ RUN set -e; set -x; \
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp6.0</TargetFramework> <TargetFramework>netcoreapp8.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+2 -2
View File
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 as build FROM mcr.microsoft.com/dotnet/sdk:8.0 as build
WORKDIR /licenseGen WORKDIR /licenseGen
@@ -12,6 +12,6 @@ RUN set -e; set -x; \
FROM bitbetter/api FROM bitbetter/api
COPY --from=build /licenseGen/bin/Debug/netcoreapp6.0/publish/* /app/ COPY --from=build /licenseGen/bin/Release/netcoreapp8.0/publish/* /app/
ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ] ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ]
+11 -5
View File
@@ -414,14 +414,14 @@ namespace bitwardenSelfLicensor
set("BillingEmail", email); set("BillingEmail", email);
set("BusinessName", string.IsNullOrWhiteSpace(businessName) ? "BitBetter" : businessName); set("BusinessName", string.IsNullOrWhiteSpace(businessName) ? "BitBetter" : businessName);
set("Enabled", true); set("Enabled", true);
set("Plan", "Custom"); set("Plan", "Enterprise (Annually)");
set("PlanType", Enum.Parse(planTypeEnum, "Custom")); set("PlanType", Enum.Parse(planTypeEnum, "EnterpriseAnnually"));
set("Seats", (int)short.MaxValue); set("Seats", int.MaxValue);
set("MaxCollections", short.MaxValue); set("MaxCollections", short.MaxValue);
set("UsePolicies", true); set("UsePolicies", true);
set("UseSso", true); set("UseSso", true);
set("UseKeyConnector", true); set("UseKeyConnector", true);
//set("UseScim", true); // available in version 10, which is not released yet set("UseScim", true);
set("UseGroups", true); set("UseGroups", true);
set("UseEvents", true); set("UseEvents", true);
set("UseDirectory", true); set("UseDirectory", true);
@@ -429,15 +429,21 @@ namespace bitwardenSelfLicensor
set("Use2fa", true); set("Use2fa", true);
set("UseApi", true); set("UseApi", true);
set("UseResetPassword", true); set("UseResetPassword", true);
set("UseCustomPermissions", true);
set("MaxStorageGb", storage == 0 ? short.MaxValue : storage); set("MaxStorageGb", storage == 0 ? short.MaxValue : storage);
set("SelfHost", true); set("SelfHost", true);
set("UsersGetPremium", true); set("UsersGetPremium", true);
set("Version", 9); set("UsePasswordManager", true);
set("UseSecretsManager", true);
set("SmSeats", int.MaxValue);
set("SmServiceAccounts", int.MaxValue);
set("Version", 14); //This is set to 14 to use LimitCollectionCreationDeletion can be changed to 13 to just use Secrets Manager
set("Issued", DateTime.UtcNow); set("Issued", DateTime.UtcNow);
set("Refresh", DateTime.UtcNow.AddYears(100).AddMonths(-1)); set("Refresh", DateTime.UtcNow.AddYears(100).AddMonths(-1));
set("Expires", DateTime.UtcNow.AddYears(100)); set("Expires", DateTime.UtcNow.AddYears(100));
set("Trial", false); set("Trial", false);
set("LicenseType", Enum.Parse(licenseTypeEnum, "Organization")); set("LicenseType", Enum.Parse(licenseTypeEnum, "Organization"));
set("LimitCollectionCreationDeletion", true); //This will be used in the new version of BitWarden but can be applied now
set("Hash", Convert.ToBase64String((byte[])type.GetMethod("ComputeHash").Invoke(license, new object[0]))); set("Hash", Convert.ToBase64String((byte[])type.GetMethod("ComputeHash").Invoke(license, new object[0])));
set("Signature", Convert.ToBase64String((byte[])type.GetMethod("Sign").Invoke(license, new object[] { cert }))); set("Signature", Convert.ToBase64String((byte[])type.GetMethod("Sign").Invoke(license, new object[] { cert })));
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp6.0</TargetFramework> <TargetFramework>netcoreapp8.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>