sqrl.exceptions module

class sqrl.exceptions.TIF[source]

Bases: int

SQRL TIF int subclass which can represent SQRL TIF flags.

Example

>>> tif = TIF(TIF.IP_MATCH | TIF.TRANSIENT_FAILURE | TIF.COMMAND_FAILED)
>>> tif.is_ip_match
True
>>> tif.is_id_match
False
>>> tif.is_transient_failure
True
>>> tif
100
>>> tif.as_hex_string()
'64'
>>> tif.breakdown() == {
...     'id_match': False,
...     'previous_id_match': False,
...     'ip_match': True,
...     'sqrl_disabled': False,
...     'not_supported': False,
...     'transient_failure': True,
...     'command_failed': True,
...     'client_failure': False,
... }
True
BAD_ID_ASSOCIATION = 256

SQRL Identity is already a ssociated with a different account

CLIENT_FAILURE = 128

SQRL command failed because SQRL client sent invalid data

COMMAND_FAILED = 64

SQRL command failed for any reason

ID_MATCH = 1

SQRL ID was found in DB

IP_MATCH = 4

SQRL client is used from same IP as where transaction started

NOT_SUPPORTED = 16

SQRL client requested SQRl operation which is not supported

PREVIOUS_ID_MATCH = 2

Previous SQRL ID was found in DB

SQRL_DISABLED = 8

SQRL auth is disabled for the found SQRL identity as per users request

TRANSIENT_FAILURE = 32

SQRL command failed transiently. Most likely restarting SQRL transaction should fix this

as_hex_string()[source]

Return TIF value as hex string

breakdown()[source]

Returns a full breakdown of the TIF value.

Returns:Keys are the SQRL TIF property and values are booleans.
Return type:dict
is_bad_id_association

Property which returns boolean whether 0x100 or 0b100000000 bit is present in the TIF value.

is_client_failure

Property which returns boolean whether 0x80 or 0b10000000 bit is present in the TIF value.

is_command_failed

Property which returns boolean whether 0x40 or 0b1000000 bit is present in the TIF value.

is_id_match

Property which returns boolean whether 0x1 or 0b1 bit is present in the TIF value.

is_ip_match

Property which returns boolean whether 0x4 or 0b100 bit is present in the TIF value.

is_not_supported

Property which returns boolean whether 0x10 or 0b10000 bit is present in the TIF value.

is_previous_id_match

Property which returns boolean whether 0x2 or 0b10 bit is present in the TIF value.

is_sqrl_disabled

Property which returns boolean whether 0x8 or 0b1000 bit is present in the TIF value.

is_transient_failure

Property which returns boolean whether 0x20 or 0b100000 bit is present in the TIF value.

update(other)[source]

Return updated TIF which will contain both bits already set in the self value as well as the ``other value.

Parameters:other (int) – Other TIF value which be merged with self bits
Returns:New TIF value which has merged bits.
Return type:TIF
exception sqrl.exceptions.TIFException(tif)[source]

Bases: Exception

Custom Exception which can be used in the views to raise specific TIF bits and immediately return appropriate response to the user.