devices.forms ============= .. py:module:: devices.forms .. autoapi-nested-parse:: Forms exclusively used in the device application. Attributes ---------- .. autoapisummary:: devices.forms.PASSWORD_MIN_LENGTH devices.forms.OTP_SPLIT_PARTS devices.forms.ONBOARDING_PROTOCOLS_ALLOWED_FOR_FORMS devices.forms.APP_CERT_PROFILES Classes ------- .. autoapisummary:: devices.forms.CredentialDownloadForm devices.forms.BaseCredentialForm devices.forms.BaseServerCredentialForm devices.forms.IssueDomainCredentialForm devices.forms.IssueTlsClientCredentialForm devices.forms.IssueTlsServerCredentialForm devices.forms.ApplicationUriFormMixin devices.forms.IssueOpcUaClientCredentialForm devices.forms.IssueOpcUaServerCredentialForm devices.forms.BrowserLoginForm devices.forms.RevokeIssuedCredentialForm devices.forms.RevokeDevicesForm devices.forms.DeleteDevicesForm devices.forms.NoOnboardingCreateForm devices.forms.OnboardingCreateForm devices.forms.ClmDeviceModelOnboardingForm devices.forms.ClmDeviceModelNoOnboardingForm devices.forms.ApplicationCertProfileSelectForm Functions --------- .. autoapisummary:: devices.forms._get_secret Module Contents --------------- .. py:data:: PASSWORD_MIN_LENGTH :value: 12 .. py:data:: OTP_SPLIT_PARTS :value: 2 .. py:data:: ONBOARDING_PROTOCOLS_ALLOWED_FOR_FORMS .. py:function:: _get_secret(number_of_symbols = 16) Generates a secret with the number of symbols provided. :param number_of_symbols: Number of symbols of the generated secret. Defaults to 16. :returns: The generated secret. .. py:class:: CredentialDownloadForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Form to download a credential. .. py:attribute:: password .. py:attribute:: confirm_password .. py:method:: clean() Checks if the passwords match and if the password is long enough. .. py:class:: BaseCredentialForm(*args, device, **kwargs) Bases: :py:obj:`django.forms.Form` Base form for issuing credentials. .. py:attribute:: common_name .. py:attribute:: pseudonym .. py:attribute:: domain_component .. py:attribute:: serial_number .. py:attribute:: validity .. py:attribute:: device .. py:method:: clean_common_name() Checks the common name. .. py:method:: clean_validity() Checks the validity. .. py:class:: BaseServerCredentialForm(*args, device, **kwargs) Bases: :py:obj:`BaseCredentialForm` Base form for issuing server credentials. .. py:attribute:: ipv4_addresses .. py:attribute:: ipv6_addresses .. py:attribute:: domain_names .. py:method:: clean_ipv4_addresses() Checks the IPv4 addresses. .. py:method:: clean_ipv6_addresses() Checks the IPv6 addresses. .. py:method:: clean_domain_names() Checks the domain names. .. py:method:: clean() Ensures at least one SAN entry is set. .. py:class:: IssueDomainCredentialForm(*args, device, **kwargs) Bases: :py:obj:`BaseCredentialForm` Form to issue a new domain credential. .. py:class:: IssueTlsClientCredentialForm(*args, device, **kwargs) Bases: :py:obj:`BaseCredentialForm` Form to issue a new TLS client credential. .. py:class:: IssueTlsServerCredentialForm(*args, device, **kwargs) Bases: :py:obj:`BaseServerCredentialForm` Form to issue a new TLS server credential. .. py:class:: ApplicationUriFormMixin(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Adds a application_uri field to the form. .. py:attribute:: application_uri .. py:method:: clean_application_uri() Checks if the application uri was set properly. :returns: The application uri. .. py:class:: IssueOpcUaClientCredentialForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`ApplicationUriFormMixin`, :py:obj:`BaseCredentialForm` Form to issue a new OPC UA client credential. .. py:class:: IssueOpcUaServerCredentialForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`ApplicationUriFormMixin`, :py:obj:`BaseServerCredentialForm` Form to issue a new OPC UA server credential. .. py:class:: BrowserLoginForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Form for the browser login via OTP for remote credential download. .. py:attribute:: otp .. py:method:: clean() Cleans the form data, extracting the credential ID and OTP. .. py:class:: RevokeIssuedCredentialForm Bases: :py:obj:`django.forms.ModelForm`\ [\ :py:obj:`pki.models.certificate.RevokedCertificateModel`\ ] Form to revoke a specific issued credential. .. py:class:: Meta Meta class configuration. .. py:attribute:: model .. py:attribute:: fields :value: ('revocation_reason',) .. py:class:: RevokeDevicesForm Bases: :py:obj:`django.forms.ModelForm`\ [\ :py:obj:`pki.models.certificate.RevokedCertificateModel`\ ] Form to revoke a issued credentials associated with a specific device. .. py:class:: Meta Meta class configuration. .. py:attribute:: model .. py:attribute:: fields :value: ('revocation_reason',) .. py:attribute:: pks .. py:class:: DeleteDevicesForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Form to delete the requested devices. .. py:attribute:: pks .. py:class:: NoOnboardingCreateForm(*args, **kwargs) Bases: :py:obj:`django.forms.Form` Form for device or OPC UA GDS object creation without onboarding. .. py:attribute:: common_name .. py:attribute:: serial_number .. py:attribute:: domain_queryset :type: django.db.models.query.QuerySet[pki.models.domain.DomainModel] .. py:attribute:: domain .. py:attribute:: no_onboarding_pki_protocols .. py:attribute:: helper .. py:method:: clean_common_name() Validates the device name, i.e. checks if it is unique. :param common_name: The desired name of the new device. :returns: The device name if it passed the checks. .. py:method:: save(device_type) Stores the form as devie model object in the db. :param device_type: The device type to set. Defaults to None. :returns: _description_ .. py:class:: OnboardingCreateForm(*args, **kwargs) Bases: :py:obj:`django.forms.Form` Form for device or OPC UA GDS object creation with onboarding. .. py:attribute:: common_name .. py:attribute:: serial_number .. py:attribute:: domain_queryset :type: django.db.models.query.QuerySet[pki.models.domain.DomainModel] .. py:attribute:: domain .. py:attribute:: onboarding_protocol .. py:attribute:: onboarding_pki_protocols .. py:attribute:: helper .. py:method:: clean_common_name() Validates the device name, i.e. checks if it is unique. :param common_name: The desired name of the new device. :returns: The device name if it passed the checks. .. py:method:: save(device_type) Stores the form as device model object in the db. :param device_type: The device type to set. Defaults to None. :returns: _description_ .. py:class:: ClmDeviceModelOnboardingForm(*args, **kwargs) Bases: :py:obj:`django.forms.Form` CLM Device Model form for devices that use onboarding. .. py:attribute:: common_name .. py:attribute:: serial_number .. py:attribute:: domain_queryset :type: django.db.models.query.QuerySet[pki.models.domain.DomainModel] .. py:attribute:: domain .. py:attribute:: onboarding_protocol .. py:attribute:: onboarding_status .. py:attribute:: pki_protocol_cmp .. py:attribute:: pki_protocol_est .. py:attribute:: instance :type: devices.models.DeviceModel .. py:attribute:: helper .. py:method:: save(onboarding_protocol) Saves the changes to DB. .. py:class:: ClmDeviceModelNoOnboardingForm(*args, **kwargs) Bases: :py:obj:`django.forms.Form` CLM Device Model form for devices that do not use onboarding. .. py:attribute:: common_name .. py:attribute:: serial_number .. py:attribute:: domain_queryset :type: django.db.models.query.QuerySet[pki.models.domain.DomainModel] .. py:attribute:: domain .. py:attribute:: pki_protocol_cmp .. py:attribute:: pki_protocol_est .. py:attribute:: pki_protocol_manual .. py:attribute:: instance :type: devices.models.DeviceModel .. py:attribute:: helper .. py:method:: save() Saves the changes to DB. .. py:data:: APP_CERT_PROFILES :value: [('tls-client', 'TLS-Client Certificate'), ('tls-server', 'TLS-Server Certificate'),... .. py:class:: ApplicationCertProfileSelectForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None, bound_field_class=None) Bases: :py:obj:`django.forms.Form` Allows to select the certificate profile. .. py:attribute:: app_cert_profiles