Skip to content

Commit

Permalink
feat: jans cli to jans-cli-tui (#3063)
Browse files Browse the repository at this point in the history
* refactor: remove jans-cli

* fix: jans-cli no need to get properties each time

* feat: jans-linux-setup tui installer

* fix: jans-linux-setup clean old cli user data

* fix: jans-linux-setup missing cli libraries

* fix: jans-cli code clean OrderedDict

* fix: jans-cli runtime plugins

* fix: jans-cli don't decode if access_token_enc is empty

* fix: jans-cli edit property (ref: #3058)

* fix: jans-cli screen hangs on scim save (ref: #3061)

* fix: jans-cli multiple device auth message on save creds (ref: #3059)

* fix:jans-cli remove unnecessary logs

* fix:jans-cli reviced all array type in properties (ref: #3062)

* fix:jans-cli fix move backword in auth server column (ref: #\3073)

* fix: jans-cli delete if jca_client_secret manually added to config.ini

* fix: jans-cli typo

* fix: jans-cli config-api move to asyncio

* fix: jans-cli save admin-ui roles

* feat: jans-cli display progressing text on status bar

* feat: jans-cli progressing texts for user plugin

* fix: jans-cli decode encrypted data if salt changed

* fix: jans-cli check existence of data when logout (ref: #3050)

* fix:jans-cli getting window too small error in edit user (ref: #3041)

* fix:jans-cli remove un-used scrollbar (ref: #3070 #3041)

* feat: jans-cli add User-inum to request headers

* fix: jans-cli check existence of inum in user info

* fix: jans-cli DocString (ref: #2572)

* fix: jans-cli DocString (ref: #2572)

* fix: jans-cli DocString and removing unused imports (ref: #2572)

* fix:jans-cli Ask on delete of scripts conf. properties (ref: #3105)

* fix: jans-cli Error on deleting Claims in scopes(ref:  #3106)

* fix: jans-cli Error on deleting without verification of deletion (ref: #3107)

Co-authored-by: Mustafa Baser <mbaser@mail.com>
Co-authored-by: AbdelwahabAdam <abdelwahabosama.1@gmail.com>
  • Loading branch information
3 people authored Nov 29, 2022
1 parent d1e1cc8 commit fc20e28
Show file tree
Hide file tree
Showing 43 changed files with 762 additions and 6,553 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/jans-fido2/ @yurem
/jans-scim/ @jgomer2001
/jans-config-api/ @pujavs @yuriyz
/jans-cli/ @devrimyatar
/jans-cli-tui/ @devrimyatar
/jans-linux-setup/ @devrimyatar @smansoft @yuriyz @yurem
/jans-linux-setup/jans_setup/setup_app/version.py @moabu
/jans-linux-setup/static/scripts/admin_ui_plugin.py @devrimyatar @duttarnab
Expand Down
52 changes: 26 additions & 26 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
cp -r /opt/dist jans-src/opt/
cp -r /opt/jans jans-src/opt/
touch jans-src/opt/jans/jans-setup/package
rm -rf install.py install jans-cli
rm -rf install.py install jans-cli-tui
rm -rf jans-src/opt/jans/jans-setup/logs/setup.log
rm -rf jans-src/opt/jans/jans-setup/logs/setup_error.log
sed -i "s/%VERSION%/${{ steps.previoustag.outputs.version }}/g" run-build.sh
Expand Down Expand Up @@ -134,10 +134,10 @@ jobs:
make zipapp
mv jans-linux-setup.pyz jans-linux-suse-X86-64-setup.pyz
sha256sum jans-linux-suse-X86-64-setup.pyz > jans-linux-suse-X86-64-setup.pyz.sha256sum
cd ../jans-cli
cd ../jans-cli-tui
make zipapp
mv config-cli.pyz jans-cli-linux-suse-X86-64.pyz
sha256sum jans-cli-linux-suse-X86-64.pyz > jans-cli-linux-suse-X86-64.pyz.sha256sum
mv config-cli.pyz jans-cli-tui-linux-suse-X86-64.pyz
sha256sum jans-cli-tui-linux-suse-X86-64.pyz > jans-cli-tui-linux-suse-X86-64.pyz.sha256sum
# To be removed once we get SUSE build working
- uses: addnab/docker-run-action@v3
name: Build with CentOS7
Expand All @@ -163,10 +163,10 @@ jobs:
make zipapp
mv jans-linux-setup.pyz jans-linux-X86-64-setup.pyz
sha256sum jans-linux-X86-64-setup.pyz > jans-linux-X86-64-setup.pyz.sha256sum
cd ../jans-cli
cd ../jans-cli-tui
make zipapp
mv config-cli.pyz jans-cli-linux-X86-64.pyz
sha256sum jans-cli-linux-X86-64.pyz > jans-cli-linux-X86-64.pyz.sha256sum
mv config-cli.pyz jans-cli-tui-linux-X86-64.pyz
sha256sum jans-cli-tui-linux-X86-64.pyz > jans-cli-tui-linux-X86-64.pyz.sha256sum
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
Expand All @@ -183,10 +183,10 @@ jobs:
make zipapp
mv jans-linux-setup.pyz jans-linux-ubuntu-X86-64-setup.pyz
sha256sum jans-linux-ubuntu-X86-64-setup.pyz > jans-linux-ubuntu-X86-64-setup.pyz.sha256sum
cd ../jans-cli
cd ../jans-cli-tui
make zipapp
mv config-cli.pyz jans-cli-linux-ubuntu-X86-64.pyz
sha256sum jans-cli-linux-ubuntu-X86-64.pyz > jans-cli-linux-ubuntu-X86-64.pyz.sha256sum
mv config-cli.pyz jans-cli-tui-linux-ubuntu-X86-64.pyz
sha256sum jans-cli-tui-linux-ubuntu-X86-64.pyz > jans-cli-tui-linux-ubuntu-X86-64.pyz.sha256sum
- uses: actions/cache@v3
id: cache-installers
with:
Expand All @@ -197,12 +197,12 @@ jobs:
${{github.workspace}}/jans-linux-setup/jans-linux-suse-X86-64-setup.pyz.sha256sum
${{github.workspace}}/jans-linux-setup/jans-linux-ubuntu-X86-64-setup.pyz
${{github.workspace}}/jans-linux-setup/jans-linux-ubuntu-X86-64-setup.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-suse-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-suse-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-ubuntu-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-ubuntu-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-suse-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-suse-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-ubuntu-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-ubuntu-X86-64.pyz.sha256sum
key: ${{ github.sha }}

upload_python_packages:
Expand All @@ -224,12 +224,12 @@ jobs:
${{github.workspace}}/jans-linux-setup/jans-linux-suse-X86-64-setup.pyz.sha256sum
${{github.workspace}}/jans-linux-setup/jans-linux-ubuntu-X86-64-setup.pyz
${{github.workspace}}/jans-linux-setup/jans-linux-ubuntu-X86-64-setup.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-suse-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-suse-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli/jans-cli-linux-ubuntu-X86-64.pyz
${{github.workspace}}/jans-cli/jans-cli-linux-ubuntu-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-suse-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-suse-X86-64.pyz.sha256sum
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-ubuntu-X86-64.pyz
${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-ubuntu-X86-64.pyz.sha256sum
key: ${{ github.sha }}
- name: Get latest tag
id: previoustag
Expand Down Expand Up @@ -262,15 +262,15 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
file: ${{github.workspace}}/jans-cli/jans-cli-linux-${{ matrix.name }}-X86-64.pyz
asset_name: jans-cli-linux-${{ matrix.name }}-X86-64.pyz
file: ${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-${{ matrix.name }}-X86-64.pyz
asset_name: jans-cli-tui-linux-${{ matrix.name }}-X86-64.pyz
tag: ${{ steps.previoustag.outputs.tag }}
- name: Upload checksum to release
id: upload_shas_cli
continue-on-error: true
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
file: ${{github.workspace}}/jans-cli/jans-cli-linux-${{ matrix.name }}-X86-64.pyz.sha256sum
asset_name: jans-cli-linux-${{ matrix.name }}-X86-64.pyz.sha256sum
file: ${{github.workspace}}/jans-cli-tui/jans-cli-tui-linux-${{ matrix.name }}-X86-64.pyz.sha256sum
asset_name: jans-cli-tui-linux-${{ matrix.name }}-X86-64.pyz.sha256sum
tag: ${{ steps.previoustag.outputs.tag }}
20 changes: 10 additions & 10 deletions .github/workflows/central_code_quality_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
- 'jans-eleven/**'
- 'agama/**'
- 'jans-linux-setup/**'
- 'jans-cli/**'
- 'jans-cli-tui/**'
- 'jans-pycloudlib/**'
- '!**/CHANGELOG.md'
- '!**.txt'
Expand All @@ -42,7 +42,7 @@ on:
- 'jans-eleven/**'
- 'agama/**'
- 'jans-linux-setup/**'
- 'jans-cli/**'
- 'jans-cli-tui/**'
- 'jans-pycloudlib/**'
- '!**/CHANGELOG.md'
- '!**.txt'
Expand All @@ -56,7 +56,7 @@ jobs:
strategy:
fail-fast: false
matrix:
module: [jans-auth-server, agama, jans-config-api, jans-core, jans-linux-setup, jans-cli, jans-fido2, jans-notify, jans-orm, jans-scim, jans-eleven, jans-pycloudlib]
module: [jans-auth-server, agama, jans-config-api, jans-core, jans-linux-setup, jans-cli-tui, jans-fido2, jans-notify, jans-orm, jans-scim, jans-eleven, jans-pycloudlib]
env:
JVM_PROJECTS: |
jans-auth-server
Expand All @@ -70,7 +70,7 @@ jobs:
agama
NON_JVM_PROJECTS: |
jans-linux-setup
jans-cli
jans-cli-tui
jans-pycloudlib
steps:
Expand Down Expand Up @@ -112,25 +112,25 @@ jobs:
echo GH sha: $GITHUB_SHA
- name: Set up JDK 11
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli'
# JanssenProject/jans-cli-tui is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli-tui'
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

- name: Cache SonarCloud packages for JVM based project
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli'
# JanssenProject/jans-cli-tui is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli-tui'
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Build and analyze JVM based project
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli'
# JanssenProject/jans-cli-tui is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.CHANGED_DIR, matrix.module) && contains(env.JVM_PROJECTS, matrix.module) && matrix.module != 'jans-cli-tui'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
#max-parallel: 1
fail-fast: false
matrix:
python-projects: ["jans-pycloudlib", "jans-cli", "jans-linux-setup"]
python-projects: ["jans-pycloudlib", "jans-cli-tui", "jans-linux-setup"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions automation/github-labels/labels-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@
"title-prefixes": []
}
},
"comp-jans-cli": {
"comp-jans-cli-tui": {
"color": "0052CC",
"description": "Touching folder /jans-cli",
"description": "Touching folder /jans-cli-tui",
"auto-label": {
"branch": "",
"paths": ["jans-cli"],
"paths": ["jans-cli-tui"],
"title-prefixes": []
}
},
Expand Down
2 changes: 1 addition & 1 deletion docker-jans-persistence-loader/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def merge_jans_cli_ctx(manager, ctx):
# - move the configs and secrets creation to configurator
# - remove them on future release

# jans-cli client
# jans-cli-tui client
ctx["role_based_client_id"] = manager.config.get("role_based_client_id")
if not ctx["role_based_client_id"]:
ctx["role_based_client_id"] = f"2000.{uuid4()}"
Expand Down
File renamed without changes.
44 changes: 29 additions & 15 deletions jans-cli-tui/cli_tui/cli/config_cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/env python3

import sys
import os
import sys

cur_dir = os.path.dirname(os.path.realpath(__file__))
pylib_dir = os.path.join(cur_dir, 'pylib')
if os.path.exists(pylib_dir):
sys.path.insert(0, pylib_dir)

import json
import re
import urllib3
Expand Down Expand Up @@ -37,11 +43,8 @@
config_dir = home_dir.joinpath('.config')
config_dir.mkdir(parents=True, exist_ok=True)
config_ini_fn = config_dir.joinpath('jans-cli.ini')
cur_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(cur_dir)



my_op_mode = 'scim' if 'scim' in os.path.basename(sys.argv[0]) else 'jca'
plugins = []

Expand Down Expand Up @@ -204,13 +207,19 @@ def get_plugin_name_from_title(title):
if config['DEFAULT'].get(secret_key_str):
client_secret = config['DEFAULT'][secret_key_str]
elif config['DEFAULT'].get(secret_enc_key_str):
client_secret_enc = config['DEFAULT'][secret_enc_key_str]
client_secret = unobscure(client_secret_enc)
try:
client_secret_enc = config['DEFAULT'][secret_enc_key_str]
client_secret = unobscure(client_secret_enc)
except Exception:
pass

if 'access_token' in config['DEFAULT']:
if 'access_token' in config['DEFAULT'] and config['DEFAULT']['access_token'].strip():
access_token = config['DEFAULT']['access_token']
elif 'access_token_enc' in config['DEFAULT']:
access_token = unobscure(config['DEFAULT']['access_token_enc'])
elif 'access_token_enc' in config['DEFAULT'] and config['DEFAULT']['access_token_enc'].strip():
try:
access_token = unobscure(config['DEFAULT']['access_token_enc'])
except Exception:
pass

debug = config['DEFAULT'].get('debug')
log_dir = config['DEFAULT'].get('log_dir', log_dir)
Expand Down Expand Up @@ -358,6 +367,10 @@ def get_request_header(self, headers={}, access_token=None):
if not access_token:
access_token = self.access_token

user = self.get_user_info()
if 'inum' in user:
headers['User-inum'] = user['inum']

ret_val = {'Authorization': 'Bearer {}'.format(access_token)}
ret_val.update(headers)
return ret_val
Expand Down Expand Up @@ -459,8 +472,9 @@ def revoke_session(self):

def check_access_token(self):

if not self.access_token :
print(self.colored_text("Access token was not found.", warning_color))
if not self.access_token:
if not self.wrapped:
print(self.colored_text("Access token was not found.", warning_color))
return

try:
Expand All @@ -472,9 +486,9 @@ def check_access_token(self):
}
)
except Exception as e:
print(self.colored_text("Unable to validate access token: {}".format(e), error_color))
self.access_token = None

if not self.wrapped:
print(self.colored_text("Unable to validate access token: {}".format(e), error_color))
self.access_token = None

def validate_date_time(self, date_str):
try:
Expand Down Expand Up @@ -672,7 +686,7 @@ def get_jwt_access_token(self, device_verified=None):
def get_access_token(self, scope):
if self.use_test_client:
self.get_scoped_access_token(scope)
elif not self.access_token:
elif not self.access_token and not self.wrapped:
self.check_access_token()
self.get_jwt_access_token()
return True, ''
Expand Down
Loading

0 comments on commit fc20e28

Please sign in to comment.