set default storage space to max (#122)

This commit is contained in:
Christoph Haas 2022-07-25 21:45:35 +02:00
parent 101f078a98
commit f01d9a6fa3
2 changed files with 43 additions and 29 deletions

View File

@ -9,14 +9,20 @@ _Beware! BitBetter does janky stuff to rewrite the bitwarden core dll and allow
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
1. [Getting Started](#getting-started) - [BitBetter](#bitbetter)
+ [Dependencies](#dependencies) - [Table of Contents](#table-of-contents)
+ [Setting up BitBetter](#setting-up-bitbetter) - [Getting Started](#getting-started)
+ [Building BitBetter](#building-bitbetter) - [Dependencies](#dependencies)
+ [Updating Bitwarden and BitBetter](#updating-bitwarden-and-bitbetter) - [Setting up BitBetter](#setting-up-bitbetter)
+ [Generating Signed Licenses](#generating-signed-licenses) - [Building BitBetter](#building-bitbetter)
2. [FAQ](#faq-questions-you-might-have-) - [Note: Manually generating Certificate & Key](#note-manually-generating-certificate--key)
3. [Footnotes](#footnotes) - [Updating Bitwarden and BitBetter](#updating-bitwarden-and-bitbetter)
- [Generating Signed Licenses](#generating-signed-licenses)
- [Note: Alternative Ways to Generate License](#note-alternative-ways-to-generate-license)
- [FAQ: Questions you might have.](#faq-questions-you-might-have)
- [Why build a license generator for open source software?](#why-build-a-license-generator-for-open-source-software)
- [Shouldn't you have reached out to Bitwarden to ask them for alternative licensing structures?](#shouldnt-you-have-reached-out-to-bitwarden-to-ask-them-for-alternative-licensing-structures)
- [Footnotes](#footnotes)
# Getting Started # 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). 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).
@ -131,8 +137,8 @@ If you wish to run the license gen from a directory aside from the root `BitBett
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
./src/licenseGen/run.sh /Absolute/Path/To/BitBetter/.keys/cert.pfx user "Name" "EMail" "User-GUID" ./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" "EMail" "Install-ID used to install the server" ./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"]
``` ```
--- ---

View File

@ -167,7 +167,7 @@ namespace bitwardenSelfLicensor
var name = config.Argument("Name", "your name"); var name = config.Argument("Name", "your name");
var email = config.Argument("Email", "your email"); var email = config.Argument("Email", "your email");
var userIdArg = config.Argument("User ID", "your user id"); var userIdArg = config.Argument("User ID", "your user id");
var storage = config.Argument("Storage", "Extra storage space in GB. Maximum is " + short.MaxValue + " (optional)"); var storage = config.Argument("Storage", "extra storage space in GB. Maximum is " + short.MaxValue + " (optional, default = max)");
var key = config.Argument("Key", "your key id (optional)"); var key = config.Argument("Key", "your key id (optional)");
var help = config.HelpOption("--help | -h | -?"); var help = config.HelpOption("--help | -h | -?");
@ -201,16 +201,20 @@ namespace bitwardenSelfLicensor
return 1; return 1;
} }
if (double.Parse(storage.Value) > short.MaxValue || short storageShort = 0;
double.Parse(storage.Value) < 0 || if (!string.IsNullOrWhiteSpace(storage.Value))
string.IsNullOrWhiteSpace(storage.Value)) {
var parsedStorage = double.Parse(storage.Value);
if (parsedStorage > short.MaxValue || parsedStorage < 0)
{ {
config.Error.WriteLine("The storage value provided is outside the accepted range of [0-" + short.MaxValue + "]"); config.Error.WriteLine("The storage value provided is outside the accepted range of [0-" + short.MaxValue + "]");
config.ShowHelp("org"); config.ShowHelp("org");
return 1; return 1;
} }
storageShort = (short) parsedStorage;
}
GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, short.Parse(storage.Value), userId, key.Value); GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, storageShort, userId, key.Value);
return 0; return 0;
}); });
@ -220,8 +224,8 @@ namespace bitwardenSelfLicensor
var name = config.Argument("Name", "your name"); var name = config.Argument("Name", "your name");
var email = config.Argument("Email", "your email"); var email = config.Argument("Email", "your email");
var installId = config.Argument("InstallId", "your installation id (GUID)"); var installId = config.Argument("InstallId", "your installation id (GUID)");
var storage = config.Argument("Storage", "Extra storage space in GB. Maximum is " + short.MaxValue + " (optional)"); var storage = config.Argument("Storage", "extra storage space in GB. Maximum is " + short.MaxValue + " (optional, default = max)");
var businessName = config.Argument("BusinessName", "name For the organization (optional)"); var businessName = config.Argument("BusinessName", "name for the organization (optional)");
var key = config.Argument("Key", "your key id (optional)"); var key = config.Argument("Key", "your key id (optional)");
var help = config.HelpOption("--help | -h | -?"); var help = config.HelpOption("--help | -h | -?");
@ -258,16 +262,20 @@ namespace bitwardenSelfLicensor
return 1; return 1;
} }
if (double.Parse(storage.Value) > short.MaxValue || short storageShort = 0;
double.Parse(storage.Value) < 0 || if (!string.IsNullOrWhiteSpace(storage.Value))
string.IsNullOrWhiteSpace(storage.Value)) {
var parsedStorage = double.Parse(storage.Value);
if (parsedStorage > short.MaxValue || parsedStorage < 0)
{ {
config.Error.WriteLine("The storage value provided is outside the accepted range of [0-" + short.MaxValue + "]"); config.Error.WriteLine("The storage value provided is outside the accepted range of [0-" + short.MaxValue + "]");
config.ShowHelp("org"); config.ShowHelp("org");
return 1; return 1;
} }
storageShort = (short) parsedStorage;
}
GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, short.Parse(storage.Value), installationId, businessName.Value, key.Value); GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, storageShort, installationId, businessName.Value, key.Value);
return 0; return 0;
}); });
@ -368,7 +376,7 @@ namespace bitwardenSelfLicensor
set("Id", userId); set("Id", userId);
set("Name", userName); set("Name", userName);
set("Email", email); set("Email", email);
set("MaxStorageGb", storage); set("MaxStorageGb", storage == 0 ? short.MaxValue : storage);
set("Premium", true); set("Premium", true);
set("Version", 1); set("Version", 1);
set("Issued", DateTime.UtcNow); set("Issued", DateTime.UtcNow);
@ -413,7 +421,7 @@ namespace bitwardenSelfLicensor
set("UseDirectory", true); set("UseDirectory", true);
set("UseTotp", true); set("UseTotp", true);
set("Use2fa", true); set("Use2fa", true);
set("MaxStorageGb", storage); set("MaxStorageGb", storage == 0 ? short.MaxValue : storage);
set("SelfHost", true); set("SelfHost", true);
set("UsersGetPremium", true); set("UsersGetPremium", true);
set("Version", 6); set("Version", 6);