From f3748312dc72288d9eea9cf1efba8f2afb5278a9 Mon Sep 17 00:00:00 2001 From: Devrim Date: Wed, 30 Nov 2022 14:57:13 +0300 Subject: [PATCH] fix: client-name, logout, user (#3122) * fix: jans-cli-tui issue logout and exit * fix:jans-cli fix error on saving users (ref: #3120) * fix: jans-cli-tui openid client name (ref: #3119) Co-authored-by: AbdelwahabAdam --- jans-cli-tui/cli_tui/cli/config_cli.py | 5 +- .../plugins/010_oxauth/edit_client_dialog.py | 47 +++++++++---------- .../cli_tui/plugins/070_users/main.py | 2 +- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/jans-cli-tui/cli_tui/cli/config_cli.py b/jans-cli-tui/cli_tui/cli/config_cli.py index 94adc996b2f..aa0208bbbc0 100755 --- a/jans-cli-tui/cli_tui/cli/config_cli.py +++ b/jans-cli-tui/cli_tui/cli/config_cli.py @@ -291,13 +291,16 @@ def getCredentials(self): def get_user_info(self): user_info = {} if 'user_data' in config['DEFAULT']: - user_info = jwt.decode(config['DEFAULT']['user_data'], + try: + user_info = jwt.decode(config['DEFAULT']['user_data'], options={ 'verify_signature': False, 'verify_exp': True, 'verify_aud': False } ) + except: + pass return user_info diff --git a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py index 28db4271dda..28c86bca360 100755 --- a/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py +++ b/jans-cli-tui/cli_tui/plugins/010_oxauth/edit_client_dialog.py @@ -47,10 +47,10 @@ def __init__( delete_UMAresource: Callable= None, )-> Dialog: """init for `EditClientDialog`, inherits from two diffrent classes `JansGDialog` and `DialogUtils` - + JansGDialog (dialog): This is the main dialog Class Widget for all Jans-cli-tui dialogs except custom dialogs like dialogs with navbar DialogUtils (methods): Responsable for all `make data from dialog` and `check required fields` in the form for any Edit or Add New - + Args: parent (widget): This is the parent widget for the dialog, to access `Pageup` and `Pagedown` title (str): The Main dialog title @@ -100,7 +100,7 @@ def save(self) -> None: self.data['attributes']={'parLifetime':self.data['parLifetime']} self.data['attributes']={'requirePar':self.data['requirePar']} for list_key in ( - + 'backchannelLogoutUri', 'additionalAudience', 'rptClaimsScripts', @@ -113,7 +113,7 @@ def save(self) -> None: 'introspectionScripts', 'ropcScripts', 'consentGatheringScripts', - + ): if self.data[list_key]: self.data['attributes'][list_key] = self.data[list_key].splitlines() @@ -190,21 +190,21 @@ def prepare_tabs(self) -> None: _("Active"), name='disabled', checked= not self.data.get('disabled'), - jans_help=self.myparent.get_help_from_schema(schema, 'disabled'), + jans_help=self.myparent.get_help_from_schema(schema, 'disabled'), style='class:outh-client-checkbox'), self.myparent.getTitledText( _("Client Name"), - name='displayName', - value=self.data.get('displayName',''), - jans_help=self.myparent.get_help_from_schema(schema, 'displayName'), + name='clientName', + value=self.data.get('clientName',''), + jans_help=self.myparent.get_help_from_schema(schema, 'clientName'), style='class:outh-client-text'), self.myparent.getTitledText( _("Client Secret"), name='clientSecret', value=self.data.get('clientSecret',''), - jans_help=self.myparent.get_help_from_schema(schema, 'clientSecret'), + jans_help=self.myparent.get_help_from_schema(schema, 'clientSecret'), style='class:outh-client-text'), self.myparent.getTitledText( @@ -213,7 +213,7 @@ def prepare_tabs(self) -> None: value=self.data.get('description',''), jans_help=self.myparent.get_help_from_schema(schema, 'description'), style='class:outh-client-text'), - + self.myparent.getTitledRadioButton( _("Authn Method token endpoint"), name='tokenEndpointAuthMethod', @@ -236,7 +236,7 @@ def prepare_tabs(self) -> None: value=self.data.get('sectorIdentifierUri',''), jans_help=self.myparent.get_help_from_schema(schema, 'sectorIdentifierUri'), style='class:outh-client-text'), - + self.myparent.getTitledCheckBoxList( _("Grant"), name='grantTypes', @@ -268,7 +268,7 @@ def prepare_tabs(self) -> None: current_value=self.data.get('applicationType'), jans_help=self.myparent.get_help_from_schema(schema, 'applicationType'), style='class:outh-client-radiobutton'), - + self.myparent.getTitledText( _("Redirect Uris"), name='redirectUris', @@ -366,7 +366,7 @@ def prepare_tabs(self) -> None: ],width=D(),style='class:outh-client-tabs') self.tabs['Logout'] = HSplit([ - + self.myparent.getTitledText( _("Front channel logout URI"), name='frontChannelLogoutUri', @@ -390,7 +390,7 @@ def prepare_tabs(self) -> None: 'backchannelLogoutUri'), height=3, style='class:outh-client-text' ), - + self.myparent.getTitledCheckBox( _("Back channel logout session required"), name='backchannelLogoutSessionRequired', @@ -447,7 +447,7 @@ def prepare_tabs(self) -> None: value=self.data.get('softwareStatement',''), jans_help=self.myparent.get_help_from_schema(schema, 'softwareStatement'), style='class:outh-client-text'), - + ],width=D(),style='class:outh-client-tabs') @@ -456,7 +456,7 @@ def prepare_tabs(self) -> None: VSplit([ self.myparent.getButton(text=_("Get Resources"), name='oauth:Resources:get', jans_help=_("Retreive UMA Resources"), handler=self.oauth_get_uma_resources), self.myparent.getTitledText(_("Search"), name='oauth:Resources:search', jans_help=_("Press enter to perform search"), accept_handler=self.search_uma_resources,style='class:outh-client-textsearch'), - + ], padding=3, width=D(), @@ -630,7 +630,7 @@ def allow_spontaneous_changed(cb): style='class:outh-client-checkbox' ), - + self.myparent.getTitledCheckBox( _("Persist Authorizations"), name='persistClientAuthorizations', @@ -764,7 +764,7 @@ def allow_spontaneous_changed(cb): self.myparent.cli_object.get_schema_from_reference('', '#/components/schemas/ClientAttributes'), 'ropcScripts'), ), - + self.myparent.getTitledText(_("OAuth Consent"), name='consentGatheringScripts', value='\n'.join(self.data.get('attributes', {}).get('consentGatheringScripts',[]) ), @@ -859,8 +859,7 @@ def oauth_update_uma_resources ( endpoint_args ='limit:10' if pattern: endpoint_args +=',pattern:'+pattern - - + self.myparent.logger.debug('DATA endpoint_args: '+str(endpoint_args)) try : rsponse = self.myparent.cli_object.process_command_by_id( @@ -890,7 +889,7 @@ def oauth_update_uma_resources ( for d in result: scopes_of_resource = [] for scope_dn in d.get('scopes', []): - + inum = scope_dn.split(',')[0].split('=')[1] scope_result = {} try : @@ -906,7 +905,7 @@ def oauth_update_uma_resources ( display_name = 'None' pass display_name = scope_result.get('displayName') or scope_result.get('inum') - + if display_name: scopes_of_resource.append(display_name) else: @@ -959,13 +958,13 @@ def client_dialog_nav_selection_changed( def view_uma_resources(self, **params: Any) -> None: """This method view the UMA resources in a dialog - """ + """ selected_line_data = params['data'] ##self.uma_result title = _("Edit user Data (Clients)") dialog = ViewUMADialog(self.myparent, title=title, data=selected_line_data, deleted_uma=self.delete_UMAresource) - + self.myparent.show_jans_dialog(dialog) def __pt_container__(self)-> Dialog: diff --git a/jans-cli-tui/cli_tui/plugins/070_users/main.py b/jans-cli-tui/cli_tui/plugins/070_users/main.py index 2eefaa6434b..cc62fa9d94c 100755 --- a/jans-cli-tui/cli_tui/plugins/070_users/main.py +++ b/jans-cli-tui/cli_tui/plugins/070_users/main.py @@ -180,7 +180,7 @@ def save_user(self, dialog: Dialog) -> None: _type_: bool value to check the status code response """ - raw_data = self.make_data_from_dialog(tabs={'user': dialog.edit_user_container}) + raw_data = self.make_data_from_dialog(tabs={'user': dialog.edit_user_container.content}) if not (raw_data['userId'].strip() and raw_data['mail'].strip()): self.app.show_message(_("Please fix!"), _("Username and/or Email is empty"))