mirror of
https://github.com/jakeswenson/BitBetter.git
synced 2025-12-20 23:36:44 +00:00
Compare commits
9 Commits
29c6266948
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31a08b7e89 | ||
|
|
5387d1803d | ||
|
|
2c9e4fd9fa | ||
|
|
0e2c9d42aa | ||
|
|
063ab1d316 | ||
|
|
df9e74bb7a | ||
|
|
ac01b0c7ec | ||
|
|
f3e36ab404 | ||
|
|
b9c46fffb2 |
@@ -13,3 +13,12 @@ jobs:
|
|||||||
- run:
|
- run:
|
||||||
name: Build script
|
name: Build script
|
||||||
command: ./build.sh
|
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,6 +4,8 @@ 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.
|
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!_
|
_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
|
||||||
@@ -72,9 +74,11 @@ You may now simply create the file `/path/to/bwdata/docker/docker-compose.overri
|
|||||||
services:
|
services:
|
||||||
api:
|
api:
|
||||||
image: bitbetter/api
|
image: bitbetter/api
|
||||||
|
pull_policy: never
|
||||||
|
|
||||||
identity:
|
identity:
|
||||||
image: bitbetter/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`.
|
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`.
|
||||||
|
|||||||
48
build.sh
48
build.sh
@@ -6,6 +6,25 @@ BW_VERSION=$(curl -sL https://go.btwrdn.co/bw-sh-versions | grep '^ *"'coreVersi
|
|||||||
|
|
||||||
echo "Building BitBetter for BitWarden version $BW_VERSION"
|
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.
|
# If there aren't any keys, generate them first.
|
||||||
[ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh"
|
[ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh"
|
||||||
|
|
||||||
@@ -14,13 +33,30 @@ rm -rf $DIR/server
|
|||||||
git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server
|
git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server
|
||||||
|
|
||||||
# Replace certificate file and thumbprint
|
# Replace certificate file and thumbprint
|
||||||
old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':')
|
old_thumbprint=$(openssl x509 -inform DER -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':')
|
||||||
new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | 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/Services/Implementations/LicensingService.cs
|
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/server/src/Core/licensing.cer
|
||||||
|
|
||||||
docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api
|
docker build \
|
||||||
docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Identity/Dockerfile -t bitbetter/identity
|
--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 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 tag bitbetter/api bitbetter/api:latest
|
docker tag bitbetter/api bitbetter/api:latest
|
||||||
docker tag bitbetter/identity bitbetter/identity:latest
|
docker tag bitbetter/identity bitbetter/identity:latest
|
||||||
@@ -28,5 +64,5 @@ docker tag bitbetter/api bitbetter/api:$BW_VERSION
|
|||||||
docker tag bitbetter/identity bitbetter/identity:$BW_VERSION
|
docker tag bitbetter/identity bitbetter/identity:$BW_VERSION
|
||||||
|
|
||||||
# Remove old instances of the image after a successful build.
|
# Remove old instances of the image after a successful build.
|
||||||
ids=$( docker images bitbetter/* | grep -E -v -- "CREATED|latest|${BW_VERSION}" | awk '{ print $3 }' )
|
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 }' )
|
||||||
[ -n "$ids" ] && docker rmi $ids || true
|
[ -n "$ids" ] && docker rmi $ids || true
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ namespace BitwardenSelfLicensor
|
|||||||
{
|
{
|
||||||
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
||||||
|
|
||||||
var type = core.GetType("Bit.Core.Models.Business.UserLicense");
|
var type = core.GetType("Bit.Core.Billing.Models.Business.UserLicense");
|
||||||
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
||||||
|
|
||||||
var license = Activator.CreateInstance(type);
|
var license = Activator.CreateInstance(type);
|
||||||
@@ -383,7 +383,7 @@ namespace BitwardenSelfLicensor
|
|||||||
{
|
{
|
||||||
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath);
|
||||||
|
|
||||||
var type = core.GetType("Bit.Core.Models.Business.OrganizationLicense");
|
var type = core.GetType("Bit.Core.Billing.Organizations.Models.OrganizationLicense");
|
||||||
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
var licenseTypeEnum = core.GetType("Bit.Core.Enums.LicenseType");
|
||||||
var planTypeEnum = core.GetType("Bit.Core.Billing.Enums.PlanType");
|
var planTypeEnum = core.GetType("Bit.Core.Billing.Enums.PlanType");
|
||||||
|
|
||||||
@@ -432,6 +432,9 @@ namespace BitwardenSelfLicensor
|
|||||||
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("LimitCollectionCreationDeletion", true); //This will be used in the new version of BitWarden but can be applied now
|
||||||
set("AllowAdminAccessToAllCollectionItems", true);
|
set("AllowAdminAccessToAllCollectionItems", true);
|
||||||
|
set("UseRiskInsights", true);
|
||||||
|
set("UseOrganizationDomains", true);
|
||||||
|
set("UseAdminSponsoredFamilies", true);
|
||||||
|
|
||||||
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 })));
|
||||||
|
|||||||
Reference in New Issue
Block a user