label=_('Message Durability'), help_text= _('When set (the default), underlying queues will be persisted to disk. Disable this to enable higher message bus throughput.' ), category=_('System'), category_slug='system', ) def logging_validate(serializer, attrs): if not serializer.instance or \ not hasattr(serializer.instance, 'LOG_AGGREGATOR_HOST') or \ not hasattr(serializer.instance, 'LOG_AGGREGATOR_TYPE'): return attrs errors = [] if attrs.get('LOG_AGGREGATOR_ENABLED', False): if not serializer.instance.LOG_AGGREGATOR_HOST and not attrs.get('LOG_AGGREGATOR_HOST', None) or\ serializer.instance.LOG_AGGREGATOR_HOST and not attrs.get('LOG_AGGREGATOR_HOST', True): errors.append( 'Cannot enable log aggregator without providing host.') if not serializer.instance.LOG_AGGREGATOR_TYPE and not attrs.get('LOG_AGGREGATOR_TYPE', None) or\ serializer.instance.LOG_AGGREGATOR_TYPE and not attrs.get('LOG_AGGREGATOR_TYPE', True): errors.append( 'Cannot enable log aggregator without providing type.') if errors: raise serializers.ValidationError(_('\n'.join(errors))) return attrs register_validate('logging', logging_validate)
setting_name = '{}{}'.format(prefix, k.upper()) if setting_name in attrs: errors.setdefault(setting_name, []) errors[setting_name].append( _('Setting Galaxy token and authentication URL is mutually exclusive with username and password.' )) if bool(galaxy_data['username']) != bool(galaxy_data['password']): msg = _( 'If authenticating via username and password, both must be provided.' ) for k in ('username', 'password'): setting_name = '{}{}'.format(prefix, k.upper()) errors.setdefault(setting_name, []) errors[setting_name].append(msg) if bool(galaxy_data['token']) != bool(galaxy_data['auth_url']): msg = _( 'If authenticating via token, both token and authentication URL must be provided.' ) for k in ('token', 'auth_url'): setting_name = '{}{}'.format(prefix, k.upper()) errors.setdefault(setting_name, []) errors[setting_name].append(msg) if errors: raise serializers.ValidationError(errors) return attrs register_validate('logging', logging_validate) register_validate('jobs', galaxy_validate)
collections.OrderedDict([ ('team', 'Sales'), ('organization', 'Ansible'), ]), ]), ]), ) def tacacs_validate(serializer, attrs): if not serializer.instance or \ not hasattr(serializer.instance, 'TACACSPLUS_HOST') or \ not hasattr(serializer.instance, 'TACACSPLUS_SECRET'): return attrs errors = [] host = serializer.instance.TACACSPLUS_HOST if 'TACACSPLUS_HOST' in attrs: host = attrs['TACACSPLUS_HOST'] secret = serializer.instance.TACACSPLUS_SECRET if 'TACACSPLUS_SECRET' in attrs: secret = attrs['TACACSPLUS_SECRET'] if host and not secret: errors.append( 'TACACSPLUS_SECRET is required when TACACSPLUS_HOST is provided.') if errors: raise serializers.ValidationError(_('\n'.join(errors))) return attrs register_validate('tacacsplus', tacacs_validate)
required=False, default='', label=_('Login redirect override URL'), help_text= _('URL to which unauthorized users will be redirected to log in. If blank, users will be sent to the login page.' ), category=_('Authentication'), category_slug='authentication', ) def authentication_validate(serializer, attrs): remote_auth_settings = [ 'AUTH_LDAP_SERVER_URI', 'SOCIAL_AUTH_GOOGLE_OAUTH2_KEY', 'SOCIAL_AUTH_GITHUB_KEY', 'SOCIAL_AUTH_GITHUB_ORG_KEY', 'SOCIAL_AUTH_GITHUB_TEAM_KEY', 'SOCIAL_AUTH_SAML_ENABLED_IDPS', 'RADIUS_SERVER', 'TACACSPLUS_HOST', ] if attrs.get('DISABLE_LOCAL_AUTH', False): if not any(getattr(settings, s, None) for s in remote_auth_settings): raise serializers.ValidationError( _("There are no remote authentication systems configured.")) return attrs register_validate('authentication', authentication_validate)