sqrl.fields module¶
-
class
sqrl.fields.Base64CharField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
sqrl.fields.Base64FieldSimilar to
Base64Fieldhowever this field normalizes tostr(unicode) data.-
default_error_messages= {'base64_ascii': 'Invalid value. Must be ascii base64url encoded string.'}¶
-
to_python(value)[source]¶ Returns base64 decoded data as string.
Uses
Base64Field.to_python()to decode base64 value which returns binary data and then this method further decodes ascii data to returnstr(unicode) data.
-
-
class
sqrl.fields.Base64ConditionalPairsField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
sqrl.fields.Base64PairsFieldSimilar to
Base64PairsFieldbut this field does not force the value to be keypairs.-
always_pairs= False¶
-
-
class
sqrl.fields.Base64Field(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
django.forms.fields.CharFieldField which decodes base64 values using
utils.Base64.decode().-
default_error_messages= {'base64': 'Invalid value. Must be base64url encoded string.'}¶
-
-
class
sqrl.fields.Base64PairsField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
sqrl.fields.Base64CharFieldField which normalizes base64 encoded multistring key-value pairs to
OrderedDict.-
always_pairs¶ bool – Boolean which enforces that the value must always be keypairs. When
Falseand the value is not a keypair, the value itself is returned.
-
always_pairs= True
-
default_error_messages= {'pairs': 'Invalid value. Must be multi-line string of pair of values.', 'crlf': 'Invalid value. Must be multi-line string separated by CRLF.'}¶
-
-
class
sqrl.fields.ExtractedNextUrlField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
sqrl.fields.NextUrlFieldSimilar to
NextUrlFieldhowever this extracts next url from full encoded URL.-
default_error_messages= {'missing_next': 'Missing next query parameter.'}¶
-
to_python(value)[source]¶ Extract next url from full URL string and then use
NextUrlFieldto validate that value is valid URL.
-
-
class
sqrl.fields.NextUrlField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
django.forms.fields.CharFieldCustom
CharFieldwhich validates that a value is a valid next URL.It validates that by checking that the value can be resolved to a view hence guaranteeing that when redirected URL will not fail.
-
default_error_messages= {'invalid_url': 'Invalid next url.'}¶
-
-
class
sqrl.fields.SQRLURLField(*args, **kwargs)[source]¶ Bases:
django.forms.fields.URLFieldSQRL URL field which uses
SQRLURLValidatorfor validation.-
default_validators= [<sqrl.fields.SQRLURLValidator object>]¶
-
-
class
sqrl.fields.SQRLURLValidator(schemes=None, **kwargs)[source]¶ Bases:
django.core.validators.URLValidatorCustom URL validator which validates that a URL is a valid SQRL url.
These are the differences with regular HTTP URLs:
- scheme is either sqrl (secure) and qrl (non-secure)
:is a valid path separator which can be used to indicate which section of the SQRL should be used to generate public/provate keypair for the domain.
-
schemes= ['sqrl', 'qrl']¶
-
class
sqrl.fields.TildeMultipleValuesField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
django.forms.fields.CharFieldField which returns tilde-separated list.
-
class
sqrl.fields.TildeMultipleValuesFieldChoiceField(max_length=None, min_length=None, strip=True, empty_value='', *args, **kwargs)[source]¶ Bases:
sqrl.fields.TildeMultipleValuesField,django.forms.fields.ChoiceFieldSimilar to
TildeMultipleValuesFieldhowever this field also validates each value to be a valid choice.