Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions keepercommander/commands/discoveryrotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2566,6 +2566,7 @@ class PamConfigurationEditMixin(RecordEditMixin):
PAM_CONFIG_RECORD_TYPES = frozenset({
'pamAwsConfiguration', 'pamAzureConfiguration', 'pamGcpConfiguration',
'pamDomainConfiguration', 'pamNetworkConfiguration', 'pamOciConfiguration',
'pamGitHubConfiguration',
})
PAM_RESOURCE_RECORD_TYPES = frozenset({
'pamDatabase', 'pamDirectory', 'pamMachine', 'pamRemoteBrowser',
Expand Down Expand Up @@ -2758,7 +2759,7 @@ def parse_properties(self, params, record, **kwargs): # type: (KeeperParams, va
extra_properties.append(f'text.pamGitHubId={github_id}')
personal_access_token = kwargs.get('personal_access_token')
if personal_access_token:
extra_properties.append(f'secret.personalAccessToken={personal_access_token}')
extra_properties.append(f'secret.pamGitHubPersonalAccessToken={personal_access_token}')
github_base_url = kwargs.get('github_base_url')
if github_base_url:
extra_properties.append(f'text.pamGitHubBaseUrl={github_base_url}')
Expand Down Expand Up @@ -2870,7 +2871,8 @@ def parse_properties(self, params, record, **kwargs): # type: (KeeperParams, va
# Fields that the backend previously required but now treats as optional for pamAzureConfiguration.
AZURE_OPTIONAL_FIELDS = frozenset({'clientId', 'clientSecret'})

def verify_required(self, record): # type: (vault.TypedRecord) -> None
def verify_required(self, record, command=''): # type: (vault.TypedRecord, str) -> None
missing_fields = []
for field in record.fields:
if field.required:
if len(field.value) == 0:
Expand All @@ -2882,10 +2884,15 @@ def verify_required(self, record): # type: (vault.TypedRecord) -> None
and field.label in self.AZURE_OPTIONAL_FIELDS):
pass
else:
self.warnings.append(f'Empty required field: "{field.get_field_name()}"')
missing_fields.append(field.get_field_name())
for custom in record.custom:
if custom.required:
custom.required = False
if missing_fields:
if len(missing_fields) == 1:
raise CommandError(command, f'Empty required field: "{missing_fields[0]}"')
fields_text = ', '.join(f'"{x}"' for x in missing_fields)
raise CommandError(command, f'Empty required fields: {fields_text}')


class PAMConfigurationNewCommand(Command, PamConfigurationEditMixin):
Expand Down Expand Up @@ -2986,7 +2993,7 @@ def execute(self, params, **kwargs):
if not gateway_uid:
logging.warning(f'Gateway "{gw_name}" not found.')

self.verify_required(record)
self.verify_required(record, command='pam-config-new')

create_pam_configuration_in_folder(params, record, shared_folder_uid, command='pam-config-new')

Expand Down Expand Up @@ -3119,7 +3126,7 @@ def execute(self, params, **kwargs):
orig_admin_cred_ref = value.get('adminCredentialRef') or ''

self.parse_properties(params, configuration, config_edit=True, **kwargs)
self.verify_required(configuration)
self.verify_required(configuration, command='pam-config-edit')

update_pam_record(params, configuration, command='pam-config-edit')

Expand Down
14 changes: 10 additions & 4 deletions keepercommander/commands/discoveryrotation_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,8 @@ def parse_properties(self, params, record, **kwargs): # type: (KeeperParams, va
if extra_properties:
self.assign_typed_fields(record, [RecordEditMixin.parse_field(x) for x in extra_properties])

def verify_required(self, record): # type: (vault.TypedRecord) -> None
def verify_required(self, record, command=''): # type: (vault.TypedRecord, str) -> None
missing_fields = []
for field in record.fields:
if field.required:
if len(field.value) == 0:
Expand All @@ -981,10 +982,15 @@ def verify_required(self, record): # type: (vault.TypedRecord) -> None
'tz': 'Etc/UTC',
}]
else:
self.warnings.append(f'Empty required field: "{field.get_field_name()}"')
missing_fields.append(field.get_field_name())
for custom in record.custom:
if custom.required:
custom.required = False
if missing_fields:
if len(missing_fields) == 1:
raise CommandError(command, f'Empty required field: "{missing_fields[0]}"')
fields_text = ', '.join(f'"{x}"' for x in missing_fields)
raise CommandError(command, f'Empty required fields: {fields_text}')


class PAMConfigurationNewCommand(Command, PamConfigurationEditMixin):
Expand Down Expand Up @@ -1037,7 +1043,7 @@ def execute(self, params, **kwargs):
if not shared_folder_uid:
raise CommandError('pam-config-new', '--shared_folder parameter is required to create a PAM configuration')

self.verify_required(record)
self.verify_required(record, command='pam-config-new')

pam_configuration_create_record_v6(params, record, shared_folder_uid)

Expand Down Expand Up @@ -1126,7 +1132,7 @@ def execute(self, params, **kwargs):
orig_shared_folder_uid = value.get('folderUid') or ''

self.parse_properties(params, configuration, **kwargs)
self.verify_required(configuration)
self.verify_required(configuration, command='pam-config-edit')

record_management.update_record(params, configuration)

Expand Down
Loading