From 6a1c90a260c44cb27ba14a70cc5dd23189822832 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Wed, 30 Sep 2020 14:37:50 +0200 Subject: [feat] make vendor_init to create independent repo this starts a stub for refactoring the authentication process, leading to keep an external repo. --- branding/README.rst | 30 ++++++++---- branding/scripts/ASSETS_LIST | 2 + branding/scripts/check | 4 ++ branding/scripts/init | 108 +++++++++++++++++++++++++++++++++++++++++++ branding/scripts/provider.py | 1 - 5 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 branding/scripts/ASSETS_LIST create mode 100755 branding/scripts/check create mode 100755 branding/scripts/init (limited to 'branding') diff --git a/branding/README.rst b/branding/README.rst index 7f2f16a..108ba5e 100644 --- a/branding/README.rst +++ b/branding/README.rst @@ -1,4 +1,4 @@ -Branding for BitmaskVPN +BitmaskVPN Branding Procedure ================================================================================ This folder contains everything that is needed to generate a customized built of @@ -8,9 +8,21 @@ the Desktop BitmaskVPN app for a given provider. Configure -------------------------------------------------------------------------------- -* Copy or edit the file at 'branding/config/vendor.conf'. Add all the needed variables. -* Copy your provider CA certificate to the same folder: 'branding/config/-ca.crt' -* Make sure that the folder 'branding/assets/' exists. Copy there all the needed assets. +To start a new vendoring project, initialize a new repo for your provider: + + export VENDOR_PATH=../leapvpn-myprovider-pkg + make vendor_init + +Follow the directions in the output of the above command. Basically you need to +configure your provider CA certificate, and some graphical assets: + + * Copy your provider CA certificate to the same folder: 'config/-ca.crt' + * Check the list of assets at 'assets/FILES.Readme'. + +You can validate your configuration: + + export VENDOR_PATH=../leapvpn-myprovider-pkg + make vendor_check Checkout -------------------------------------------------------------------------------- @@ -29,14 +41,16 @@ before the build. If you want to skip this check, pass `SKIP_CACHECK=yes` Run:: - PROVIDER=example make vendor + export VENDOR_PATH=../leapvpn-myprovider-pkg + make vendor + make prepare Then you can build the binary:: - ./build.sh - + make build -* The following does not work yet! in progress ------------------ +* FIXME: the following does not work yet --------------------- + REFACTORING in progress ------------------------------------ Then you can build all the packages:: diff --git a/branding/scripts/ASSETS_LIST b/branding/scripts/ASSETS_LIST new file mode 100644 index 0000000..71c89e3 --- /dev/null +++ b/branding/scripts/ASSETS_LIST @@ -0,0 +1,2 @@ +svg/icon.svg +ico/logo.ico diff --git a/branding/scripts/check b/branding/scripts/check new file mode 100755 index 0000000..07b2a71 --- /dev/null +++ b/branding/scripts/check @@ -0,0 +1,4 @@ +#!/usr/bin/env python3 + +if __name__ == "__main__": + print("[+] Checking your provider config... (WIP)") diff --git a/branding/scripts/init b/branding/scripts/init new file mode 100755 index 0000000..ba9ce52 --- /dev/null +++ b/branding/scripts/init @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +# (c) LEAP Encryption Access Project 2020 +# License: GPL + +import subprocess +import sys +import os + +VENDOR_PATH = None +SCRIPT_NAME = sys.argv[0] +CA_README = "config/CERT.Readme" +ASSETS_README = "assets/FILES.Readme" + +def initVendor(): + global VENDOR_PATH + if not VENDOR_PATH: + bail("ERROR: Please set VENDOR_PATH environment variable.") + VENDOR_PATH = os.path.abspath(VENDOR_PATH) + if os.path.isdir(VENDOR_PATH): + bail("ERROR: VENDOR_PATH folder already exists") + + for d in ["config", "assets", "pkg"]: + os.makedirs(os.path.join(VENDOR_PATH, d)) + + initVendorConfig() + initGitRepo() + displayRepoInfo() + +def displayRepoInfo(): + print("[+] Initialized repo in", VENDOR_PATH) + print(f"[ ] - Add the assets in the assets/ folder, see {ASSETS_README}.") + print(f"[ ] - Add the CA certificate in the config/ folder, see {CA_README}.") + print("[ ] - Remember to commit your changes.") + print() + print("[+] After doing that, you can run 'make vendor_check' to validate the configuration for your provider.") + +def bail(msg=None): + if not msg: + print("ERROR: no arguments supported!") + print('Usage: {scriptname}'.format( + scriptname=SCRIPT_NAME)) + else: + print(msg) + sys.exit(1) + +def getVendorPath(): + return os.environ.get('VENDOR_PATH') + +def initVendorConfig(): + + with open(os.path.join(VENDOR_PATH, "config", "vendor.conf"), "w") as f: + f.write(CONF_TEMPLATE) + + with open(os.path.join(VENDOR_PATH, CA_README), "w") as f: + f.write(CA_INFO) + + with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "ASSETS_LIST")) as f: + allAssets = f.read() + + with open(os.path.join(VENDOR_PATH, ASSETS_README), "w") as f: + f.write(ASSETS_INFO) + f.write(allAssets) + +def initGitRepo(): + out = subprocess.run(['git', 'init'], cwd=VENDOR_PATH) + if out.returncode != 0: + print(f'ERROR: cannot initialize git repo in {VENDOR_PATH}') + + +CONF_TEMPLATE = """[default] + +provider = myprovider + +[myprovider] + +name = MyProvider +applicationName = MyProviderVPN +binaryName = myprovider-vpn + +providerURL = example.org +auth = anon +apiURL = https://api.myprovider.net/ +caURL = https://myprovider.net/ca.crt + +infoURL = https://myprovider.net/vpn +tosURL = https://myprovider.net/tos +helpURL = https://myprovider.net/support + +geolocationAPI = https://myprovider.net:9001/json + +askForDonations = true +donateURL = https://myprovider.net/vpn/donate +""" + +CA_INFO = """Place in this folder your provider's CA certificate, with the name: + + -ca.crt +""" + +ASSETS_INFO = """This is the list of assets that you MUST place in this folder for your provider: + +""" + +if __name__ == "__main__": + if len(sys.argv) != 1: + bail() + VENDOR_PATH = getVendorPath() + initVendor() diff --git a/branding/scripts/provider.py b/branding/scripts/provider.py index 619382b..ec8c80a 100644 --- a/branding/scripts/provider.py +++ b/branding/scripts/provider.py @@ -32,4 +32,3 @@ def getProviderData(provider, config): datetime.datetime.now()) return d - -- cgit v1.2.3