mirror of
https://github.com/jakeswenson/BitBetter.git
synced 2025-12-20 21:56:37 +00:00
Compare commits
2 Commits
master
...
77a7023153
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77a7023153 | ||
|
|
90e563e21f |
@@ -13,12 +13,3 @@ jobs:
|
||||
- run:
|
||||
name: Build script
|
||||
command: ./build.sh
|
||||
- run:
|
||||
name: Build licenseGen
|
||||
command: ./src/licenseGen/build.sh
|
||||
- run:
|
||||
name: Test generating user license
|
||||
command: ./src/licenseGen/run.sh ./.keys/cert.pfx user TestName TestEmail@example.com 4a619d4a-522d-4c70-8596-affb5b607c23
|
||||
- run:
|
||||
name: Test generating organization license
|
||||
command: ./src/licenseGen/run.sh ./.keys/cert.pfx org TestName TestEmail@example.com 4a619d4a-522d-4c70-8596-affb5b607c23
|
||||
|
||||
@@ -4,8 +4,6 @@ BitBetter is is a tool to modify Bitwarden's core dll to allow you to generate y
|
||||
|
||||
Please see the FAQ below for details on why this software was created.
|
||||
|
||||
Looking for a solution to the Lite (formerly unified) version of bitwarden, [go to the Lite branch](../../tree/lite).
|
||||
|
||||
_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
|
||||
@@ -74,11 +72,9 @@ You may now simply create the file `/path/to/bwdata/docker/docker-compose.overri
|
||||
services:
|
||||
api:
|
||||
image: bitbetter/api
|
||||
pull_policy: never
|
||||
|
||||
identity:
|
||||
image: bitbetter/identity
|
||||
pull_policy: never
|
||||
```
|
||||
|
||||
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`.
|
||||
|
||||
54
build.sh
54
build.sh
@@ -1,62 +1,22 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
DIR=`dirname "$0"`
|
||||
DIR=`exec 2>/dev/null;(cd -- "$DIR") && cd -- "$DIR"|| cd "$DIR"; unset PWD; /usr/bin/pwd || /bin/pwd || pwd`
|
||||
BW_VERSION=$(curl -sL https://go.btwrdn.co/bw-sh-versions | grep '^ *"'coreVersion'":' | awk -F\: '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//')
|
||||
|
||||
echo "Building BitBetter for BitWarden version $BW_VERSION"
|
||||
|
||||
# Enable BuildKit for better build experience and to ensure platform args are populated
|
||||
export DOCKER_BUILDKIT=1
|
||||
export COMPOSE_DOCKER_CLI_BUILD=1
|
||||
|
||||
# Determine host architecture to use as default BUILDPLATFORM / TARGETPLATFORM if not supplied.
|
||||
# Allow override via environment variables when invoking the script.
|
||||
HOST_UNAME_ARCH=$(uname -m 2>/dev/null || echo unknown)
|
||||
case "$HOST_UNAME_ARCH" in
|
||||
x86_64|amd64) DEFAULT_ARCH=amd64 ;;
|
||||
aarch64|arm64) DEFAULT_ARCH=arm64 ;;
|
||||
armv7l|armv7) DEFAULT_ARCH=arm/v7 ;;
|
||||
*) DEFAULT_ARCH=amd64 ;;
|
||||
esac
|
||||
|
||||
: "${BUILDPLATFORM:=linux/${DEFAULT_ARCH}}"
|
||||
: "${TARGETPLATFORM:=linux/${DEFAULT_ARCH}}"
|
||||
|
||||
echo "Using BUILDPLATFORM=$BUILDPLATFORM TARGETPLATFORM=$TARGETPLATFORM"
|
||||
|
||||
# If there aren't any keys, generate them first.
|
||||
[ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh"
|
||||
|
||||
# Prepare Bitwarden server repository
|
||||
rm -rf $DIR/server
|
||||
git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server
|
||||
[ -e "$DIR/src/bitBetter/.keys" ] || mkdir "$DIR/src/bitBetter/.keys"
|
||||
|
||||
# Replace certificate file and thumbprint
|
||||
old_thumbprint=$(openssl x509 -inform DER -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':')
|
||||
new_thumbprint=$(openssl x509 -inform DER -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':')
|
||||
sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Billing/Services/Implementations/LicensingService.cs
|
||||
cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer
|
||||
cp "$DIR/.keys/cert.cert" "$DIR/src/bitBetter/.keys"
|
||||
|
||||
docker build \
|
||||
--no-cache \
|
||||
--platform "$TARGETPLATFORM" \
|
||||
--build-arg BUILDPLATFORM="$BUILDPLATFORM" \
|
||||
--build-arg TARGETPLATFORM="$TARGETPLATFORM" \
|
||||
--label com.bitwarden.product="bitbetter" \
|
||||
-f $DIR/server/src/Api/Dockerfile \
|
||||
-t bitbetter/api \
|
||||
$DIR/server
|
||||
docker run --rm -v "$DIR/src/bitBetter:/bitBetter" -w=/bitBetter mcr.microsoft.com/dotnet/sdk:8.0 sh build.sh
|
||||
|
||||
docker build \
|
||||
--no-cache \
|
||||
--platform "$TARGETPLATFORM" \
|
||||
--build-arg BUILDPLATFORM="$BUILDPLATFORM" \
|
||||
--build-arg TARGETPLATFORM="$TARGETPLATFORM" \
|
||||
--label com.bitwarden.product="bitbetter" \
|
||||
-f $DIR/server/src/Identity/Dockerfile \
|
||||
-t bitbetter/identity \
|
||||
$DIR/server
|
||||
docker build --no-cache --build-arg BITWARDEN_TAG=ghcr.io/bitwarden/api:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/api "$DIR/src/bitBetter" # --squash
|
||||
docker build --no-cache --build-arg BITWARDEN_TAG=ghcr.io/bitwarden/identity:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/identity "$DIR/src/bitBetter" # --squash
|
||||
|
||||
docker tag bitbetter/api bitbetter/api:latest
|
||||
docker tag bitbetter/identity bitbetter/identity:latest
|
||||
@@ -64,5 +24,5 @@ docker tag bitbetter/api bitbetter/api:$BW_VERSION
|
||||
docker tag bitbetter/identity bitbetter/identity:$BW_VERSION
|
||||
|
||||
# Remove old instances of the image after a successful build.
|
||||
ids=$( docker image ls --format="{{ .ID }} {{ .Tag }}" 'bitbetter/*' | grep -E -v -- "CREATED|latest|${BW_VERSION}" | awk '{ ids = (ids ? ids FS $1 : $1) } END { print ids }' )
|
||||
ids=$( docker images bitbetter/* | grep -E -v -- "CREATED|latest|${BW_VERSION}" | awk '{ print $3 }' )
|
||||
[ -n "$ids" ] && docker rmi $ids || true
|
||||
|
||||
11
src/bitBetter/Dockerfile
Normal file
11
src/bitBetter/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
ARG BITWARDEN_TAG
|
||||
FROM ${BITWARDEN_TAG}
|
||||
|
||||
COPY bin/Release/net8.0/publish/* /bitBetter/
|
||||
COPY ./.keys/cert.cert /newLicensing.cer
|
||||
|
||||
RUN set -e; set -x; \
|
||||
dotnet /bitBetter/bitBetter.dll && \
|
||||
mv /app/Core.dll /app/Core.orig.dll && \
|
||||
mv /app/modified.dll /app/Core.dll && \
|
||||
rm -rf /bitBetter && rm -rf /newLicensing.cer
|
||||
93
src/bitBetter/Program.cs
Normal file
93
src/bitBetter/Program.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Cecil.Rocks;
|
||||
|
||||
namespace bitwardenSelfLicensor
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
string cerFile;
|
||||
string corePath;
|
||||
|
||||
if(args.Length >= 2) {
|
||||
cerFile = args[0];
|
||||
corePath = args[1];
|
||||
} else if (args.Length == 1) {
|
||||
cerFile = args[0];
|
||||
corePath = "/app/Core.dll";
|
||||
}
|
||||
else {
|
||||
cerFile = "/newLicensing.cer";
|
||||
corePath = "/app/Core.dll";
|
||||
}
|
||||
|
||||
|
||||
var module = ModuleDefinition.ReadModule(new MemoryStream(File.ReadAllBytes(corePath)));
|
||||
var cert = File.ReadAllBytes(cerFile);
|
||||
|
||||
var x = module.Resources.OfType<EmbeddedResource>()
|
||||
.Where(r => r.Name.Equals("Bit.Core.licensing.cer"))
|
||||
.First();
|
||||
|
||||
Console.WriteLine(x.Name);
|
||||
|
||||
var e = new EmbeddedResource("Bit.Core.licensing.cer", x.Attributes, cert);
|
||||
|
||||
module.Resources.Add(e);
|
||||
module.Resources.Remove(x);
|
||||
|
||||
var services = module.Types.Where(t => t.Namespace == "Bit.Core.Services");
|
||||
|
||||
|
||||
var type = services.First(t => t.Name == "LicensingService");
|
||||
|
||||
var licensingType = type.Resolve();
|
||||
|
||||
var existingCert = new X509Certificate2(x.GetResourceData());
|
||||
|
||||
Console.WriteLine($"Existing Cert Thumbprint: {existingCert.Thumbprint}");
|
||||
X509Certificate2 certificate = new X509Certificate2(cert);
|
||||
|
||||
Console.WriteLine($"New Cert Thumbprint: {certificate.Thumbprint}");
|
||||
|
||||
var ctor = licensingType.GetConstructors().Single();
|
||||
|
||||
|
||||
var rewriter = ctor.Body.GetILProcessor();
|
||||
|
||||
var instToReplace =
|
||||
ctor.Body.Instructions.Where(i => i.OpCode == OpCodes.Ldstr
|
||||
&& string.Equals((string)i.Operand, existingCert.Thumbprint, StringComparison.InvariantCultureIgnoreCase))
|
||||
.FirstOrDefault();
|
||||
|
||||
if(instToReplace != null) {
|
||||
rewriter.Replace(instToReplace, Instruction.Create(OpCodes.Ldstr, certificate.Thumbprint));
|
||||
}
|
||||
else {
|
||||
Console.WriteLine("Cant find inst");
|
||||
}
|
||||
|
||||
// foreach (var inst in ctor.Body.Instructions)
|
||||
// {
|
||||
// Console.Write(inst.OpCode.Name + " " + inst.Operand?.GetType() + " = ");
|
||||
// if(inst.OpCode.FlowControl == FlowControl.Call) {
|
||||
// Console.WriteLine(inst.Operand);
|
||||
// }
|
||||
// else if(inst.OpCode == OpCodes.Ldstr) {
|
||||
// Console.WriteLine(inst.Operand);
|
||||
// }
|
||||
// else {Console.WriteLine();}
|
||||
// }
|
||||
|
||||
module.Write("modified.dll");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/bitBetter/bitBetter.csproj
Normal file
12
src/bitBetter/bitBetter.csproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
7
src/bitBetter/build.sh
Executable file
7
src/bitBetter/build.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
dotnet restore
|
||||
dotnet publish
|
||||
@@ -14,4 +14,4 @@ FROM bitbetter/api
|
||||
|
||||
COPY --from=build /licenseGen/bin/Release/net8.0/publish/* /app/
|
||||
|
||||
ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--executable", "/app/Api", "--cert", "/cert.pfx" ]
|
||||
ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ]
|
||||
|
||||
@@ -1,39 +1,37 @@
|
||||
namespace BitwardenSelfLicensor
|
||||
{
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Newtonsoft.Json;
|
||||
using SingleFileExtractor.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Loader;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Loader;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
public static class Program
|
||||
namespace bitwardenSelfLicensor
|
||||
{
|
||||
class Program
|
||||
{
|
||||
public static int Main(string[] args)
|
||||
static int Main(string[] args)
|
||||
{
|
||||
var app = new CommandLineApplication();
|
||||
var app = new Microsoft.Extensions.CommandLineUtils.CommandLineApplication();
|
||||
var cert = app.Option("--cert", "cert file", CommandOptionType.SingleValue);
|
||||
var coreDll = app.Option("--core", "path to core dll", CommandOptionType.SingleValue);
|
||||
var exec = app.Option("--executable", "path to Bitwarden single file executable", CommandOptionType.SingleValue);
|
||||
|
||||
bool ExecExists() => File.Exists(exec.Value());
|
||||
bool CertExists() => File.Exists(cert.Value());
|
||||
bool CoreExists() => File.Exists(coreDll.Value());
|
||||
bool VerifyTopOptions() =>
|
||||
!string.IsNullOrWhiteSpace(cert.Value()) &&
|
||||
(!string.IsNullOrWhiteSpace(coreDll.Value()) || !string.IsNullOrWhiteSpace(exec.Value())) &&
|
||||
CertExists() &&
|
||||
(CoreExists() || ExecExists());
|
||||
string GetExtractedDll()
|
||||
bool certExists()
|
||||
{
|
||||
var coreDllPath = Path.Combine("extract", "Core.dll");
|
||||
var reader = new ExecutableReader(exec.Value());
|
||||
reader.ExtractToDirectory("extract");
|
||||
var fileInfo = new FileInfo(coreDllPath);
|
||||
return fileInfo.FullName;
|
||||
return File.Exists(cert.Value());
|
||||
}
|
||||
|
||||
bool coreExists()
|
||||
{
|
||||
return File.Exists(coreDll.Value());
|
||||
}
|
||||
|
||||
bool verifyTopOptions()
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(cert.Value()) &&
|
||||
!string.IsNullOrWhiteSpace(coreDll.Value()) &&
|
||||
certExists() && coreExists();
|
||||
}
|
||||
string GetCoreDllPath() => CoreExists() ? coreDll.Value() : GetExtractedDll();
|
||||
|
||||
app.Command("interactive", config =>
|
||||
{
|
||||
@@ -45,11 +43,11 @@ namespace BitwardenSelfLicensor
|
||||
|
||||
config.OnExecute(() =>
|
||||
{
|
||||
if (!VerifyTopOptions())
|
||||
if (!verifyTopOptions())
|
||||
{
|
||||
if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}");
|
||||
if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
if (!coreExists()) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
if (!certExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
|
||||
config.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
@@ -94,7 +92,7 @@ namespace BitwardenSelfLicensor
|
||||
WriteLineOver("Please enter a business name, default is BitBetter. [Business Name]:");
|
||||
buff = Console.ReadLine();
|
||||
if (buff == "") businessname = "BitBetter";
|
||||
else if (CheckBusinessName(buff)) businessname = buff;
|
||||
else if (checkBusinessName(buff)) businessname = buff;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -107,14 +105,14 @@ namespace BitwardenSelfLicensor
|
||||
{
|
||||
WriteLineOver("Please provide the username this license will be registered to. [username]:");
|
||||
buff = Console.ReadLine();
|
||||
if ( CheckUsername(buff) ) name = buff;
|
||||
if ( checkUsername(buff) ) name = buff;
|
||||
}
|
||||
|
||||
while (email == "")
|
||||
{
|
||||
WriteLineOver("Please provide the email address for the user " + name + ". [email]");
|
||||
buff = Console.ReadLine();
|
||||
if ( CheckEmail(buff) ) email = buff;
|
||||
if ( checkEmail(buff) ) email = buff;
|
||||
}
|
||||
|
||||
while (storage == 0)
|
||||
@@ -127,7 +125,7 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckStorage(buff)) storage = short.Parse(buff);
|
||||
if (checkStorage(buff)) storage = short.Parse(buff);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +135,7 @@ namespace BitwardenSelfLicensor
|
||||
buff = Console.ReadLine();
|
||||
if ( buff == "" || buff == "y" || buff == "Y" )
|
||||
{
|
||||
GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name, email, storage, guid, null);
|
||||
GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name, email, storage, guid, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,7 +149,7 @@ namespace BitwardenSelfLicensor
|
||||
buff = Console.ReadLine();
|
||||
if ( buff == "" || buff == "y" || buff == "Y" )
|
||||
{
|
||||
GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name, email, storage, installid, businessname, null);
|
||||
GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name, email, storage, installid, businessname, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -175,11 +173,17 @@ namespace BitwardenSelfLicensor
|
||||
|
||||
config.OnExecute(() =>
|
||||
{
|
||||
if (!VerifyTopOptions())
|
||||
if (!verifyTopOptions())
|
||||
{
|
||||
if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}");
|
||||
if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
if (!coreExists())
|
||||
{
|
||||
config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
}
|
||||
if (!certExists())
|
||||
{
|
||||
config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
}
|
||||
|
||||
config.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
@@ -210,7 +214,7 @@ namespace BitwardenSelfLicensor
|
||||
storageShort = (short) parsedStorage;
|
||||
}
|
||||
|
||||
GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name.Value, email.Value, storageShort, userId, key.Value);
|
||||
GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, storageShort, userId, key.Value);
|
||||
|
||||
return 0;
|
||||
});
|
||||
@@ -227,11 +231,17 @@ namespace BitwardenSelfLicensor
|
||||
|
||||
config.OnExecute(() =>
|
||||
{
|
||||
if (!VerifyTopOptions())
|
||||
if (!verifyTopOptions())
|
||||
{
|
||||
if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}");
|
||||
if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
if (!coreExists())
|
||||
{
|
||||
config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}");
|
||||
}
|
||||
if (!certExists())
|
||||
{
|
||||
config.Error.WriteLine($"Cant find certificate at: {cert.Value()}");
|
||||
}
|
||||
|
||||
config.ShowHelp();
|
||||
return 1;
|
||||
}
|
||||
@@ -265,7 +275,7 @@ namespace BitwardenSelfLicensor
|
||||
storageShort = (short) parsedStorage;
|
||||
}
|
||||
|
||||
GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name.Value, email.Value, storageShort, 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;
|
||||
});
|
||||
@@ -291,7 +301,7 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
|
||||
// checkUsername Checks that the username is a valid username
|
||||
private static bool CheckUsername(string s)
|
||||
static bool checkUsername(string s)
|
||||
{
|
||||
if ( string.IsNullOrWhiteSpace(s) ) {
|
||||
WriteLineOver("The username provided doesn't appear to be valid.\n");
|
||||
@@ -301,7 +311,7 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
|
||||
// checkBusinessName Checks that the Business Name is a valid username
|
||||
private static bool CheckBusinessName(string s)
|
||||
static bool checkBusinessName(string s)
|
||||
{
|
||||
if ( string.IsNullOrWhiteSpace(s) ) {
|
||||
WriteLineOver("The Business Name provided doesn't appear to be valid.\n");
|
||||
@@ -311,7 +321,7 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
|
||||
// checkEmail Checks that the email address is a valid email address
|
||||
private static bool CheckEmail(string s)
|
||||
static bool checkEmail(string s)
|
||||
{
|
||||
if ( string.IsNullOrWhiteSpace(s) ) {
|
||||
WriteLineOver("The email provided doesn't appear to be valid.\n");
|
||||
@@ -321,7 +331,7 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
|
||||
// checkStorage Checks that the storage is in a valid range
|
||||
private static bool CheckStorage(string s)
|
||||
static bool checkStorage(string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
@@ -337,20 +347,23 @@ namespace BitwardenSelfLicensor
|
||||
}
|
||||
|
||||
// WriteLineOver Writes a new line to console over last line.
|
||||
private static void WriteLineOver(string s)
|
||||
static void WriteLineOver(string s)
|
||||
{
|
||||
Console.SetCursorPosition(0, Console.CursorTop -1);
|
||||
Console.WriteLine(s);
|
||||
}
|
||||
|
||||
// WriteLine This wrapper is just here so that console writes all look similar.
|
||||
private static void WriteLine(string s) => Console.WriteLine(s);
|
||||
static void WriteLine(string s)
|
||||
{
|
||||
Console.WriteLine(s);
|
||||
}
|
||||
|
||||
private static void GenerateUserLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid userId, string key)
|
||||
static void GenerateUserLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid userId, string key)
|
||||
{
|
||||
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
||||
|
||||
var type = core.GetType("Bit.Core.Billing.Models.Business.UserLicense");
|
||||
var type = core.GetType("Bit.Core.Models.Business.UserLicense");
|
||||
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
||||
|
||||
var license = Activator.CreateInstance(type);
|
||||
@@ -379,11 +392,11 @@ namespace BitwardenSelfLicensor
|
||||
Console.WriteLine(JsonConvert.SerializeObject(license, Formatting.Indented));
|
||||
}
|
||||
|
||||
private static void GenerateOrgLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid instalId, string businessName, string key)
|
||||
static void GenerateOrgLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid instalId, string businessName, string key)
|
||||
{
|
||||
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
||||
|
||||
var type = core.GetType("Bit.Core.Billing.Organizations.Models.OrganizationLicense");
|
||||
var type = core.GetType("Bit.Core.Models.Business.OrganizationLicense");
|
||||
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
||||
var planTypeEnum = core.GetType("Bit.Core.Billing.Enums.PlanType");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
@@ -7,8 +7,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SingleFileExtractor.Core" Version="2.3.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user