From 18d1507936a9fdcd8ee6daa46f2ca0af070ea4ba Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 2 Mar 2022 19:29:03 +0300 Subject: [PATCH] fix: jans cli build issues (update doc and fix requirements) (#938) --- jans-cli/README.md | 56 +++++++++++++++++++------------------- jans-cli/cli/config_cli.py | 15 +++++----- jans-cli/setup.py | 2 ++ 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/jans-cli/README.md b/jans-cli/README.md index 75cc755b413..b80584001c5 100644 --- a/jans-cli/README.md +++ b/jans-cli/README.md @@ -29,24 +29,46 @@ wget https://github.com/JanssenProject/jans-cli/releases/latest/download/jans-cl If you would like to build `jans-cli` manually, you can go through the following steps noted here: ## Prerequisites -1. git +1. wget +1. unzip 1. Python 3.6+. 1. Python `pip3` package. -### Downloading `jans-cli` files +### Building -1. Clone the repository: +1. Install dependencies + ```sh + apt install -y wget unzip python3-pip python3-dev + pip3 install shiv ``` - git clone https://github.com/JanssenProject/jans-cli/ + +2. Download the repository: + + ```sh + wget https://github.com/JanssenProject/jans/archive/refs/heads/main.zip ``` -2. open directory +3. Unzip package, and change to directory + ```sh + unzip main.zip + cd jans-main/jans-cli ``` - cd jans-cli + +4. Build + + ```sh + make zipapp ``` +You can verify with the following command line if everything is done successfully. + +``` +python3 jans-cli.pyz -h +``` + + ### Standard Python package 1. Create virtual environment and activate: @@ -64,28 +86,6 @@ If you would like to build `jans-cli` manually, you can go through the following This command will install executable called `jans-cli` available in virtual environment `PATH`. -### Python zipapp - -1. Install [shiv](https://shiv.readthedocs.io/) using `pip3`: - - ```sh - pip3 install shiv - ``` - -1. Install the package: - - ```sh - make zipapp - ``` - - This command will generate executable called `jans-cli.pyz` under the same directory. - - -You can verify with the following command line if everything is done successfully. - -``` -python3 jans-cli.pyz -h -``` ![](docs/img/build-jans-cli-pyz-manually.png) diff --git a/jans-cli/cli/config_cli.py b/jans-cli/cli/config_cli.py index ee9eace9dee..90ca490f8f5 100644 --- a/jans-cli/cli/config_cli.py +++ b/jans-cli/cli/config_cli.py @@ -126,6 +126,11 @@ def join(self): ################## end of arguments ################# + +def write_config(): + with open(config_ini_fn, 'w') as w: + config.write(w) + if not (host and client_id and client_secret): host = args.host client_id = args.client_id @@ -152,7 +157,7 @@ def join(self): 'scim_client_id': 'your jans scim client id', 'scim_client_secret': 'client secret for your jans scim client'} - self.write_config() + write_config() print( "Pelase fill {} or set environmental variables jans_host, jans_client_id ,and jans_client_secret and re-run".format(config_ini_fn) @@ -289,10 +294,6 @@ def get_yaml(self): json.dump(self.cfg_yml, w, indent=2) return self.cfg_yml - def write_config(self): - with open(config_ini_fn, 'w') as w: - config.write(w) - def get_rest_client(self): rest = swagger_client.rest.RESTClientObject(self.swagger_configuration) if args.key_password: @@ -490,7 +491,7 @@ def get_jwt_access_token(self): self.access_token = result['access_token'] access_token_enc = encode_decode(self.access_token) config['DEFAULT']['access_token_enc'] = access_token_enc - self.write_config() + write_config() def get_access_token(self, scope): @@ -637,7 +638,7 @@ def get_input(self, values=[], text='Selection', default=None, itype=None, print("Logging out...") if 'access_token_enc' in config['DEFAULT']: config['DEFAULT'].pop('access_token_enc') - self.write_config() + write_config() print("Quiting...") sys.exit() break diff --git a/jans-cli/setup.py b/jans-cli/setup.py index b987ffc620f..ea3c950f3c6 100644 --- a/jans-cli/setup.py +++ b/jans-cli/setup.py @@ -38,6 +38,8 @@ def find_version(*file_paths): install_requires=[ "ruamel.yaml>=0.16.5", "PyJWT==2.3.0", + "certifi", + "six", "jca-swagger-client @ https://ox.gluu.org/icrby8xcvbcv/cli-swagger/jca_swagger_client.zip", "scim_swagger_client @ https://ox.gluu.org/icrby8xcvbcv/cli-swagger/scim_swagger_client.zip",