Acquire.Identity._loginsession module

class LoginSession(username=None, public_key=None, public_cert=None, ipaddr=None, hostname=None, login_message=None, scope=None, permissions=None)[source]

Bases: object

This class holds all details of a single login session

creation_time()[source]

Return the date and time when this was created

device_uid()[source]

If known, return the UID of the device from which the user approved this session

encoded_username()[source]

Return a safely-encoded version of the username. This is used to create safe keys in the object store

static from_data(data)[source]

Return a LoginSession constructed from the passed data (dictionary)

static get_status(uid)[source]

Return the status of the LoginSession with specified UID

hostname()[source]

Return the user-supplied hostname of the host making the login request

ipaddr()[source]

Return the user-supplied IP address of the host making the login request

is_approved()[source]

Return whether or not this session is open and approved by the user

is_logged_out()[source]

Return whether or not this session has logged out

is_null()[source]

Return whether or not this object is null

is_suspicious()[source]

Return whether or not this session is suspicious

static load(status=None, short_uid=None, uid=None, scope=None, permissions=None)[source]

Load and return a LoginSession specified from either a short_uid or a long uid. Note that if more than one session matches the short_uid then you will get a list of LoginSessions returned

login(user_uid=None, device_uid=None)[source]

Convenience function to set the session into the logged in state

login_message()[source]

Return any login message that has been set by the user

login_time()[source]

Return the date and time when the user logged in. This returns None if the user has not yet logged in

login_url()[source]

Return the login URL to login to this session. This is the URL of this identity service plus the short UID of the session

logout(authorisation=None, signature=None)[source]

Convenience function to set the session into the logged out state

logout_time()[source]

Return the date and time when the user logged out. This returns None if the user has not yet logged out

permissions()[source]

Return the permissions requested for this login session

public_certificate()[source]

Return the public certificate

public_key()[source]

Return the public key

regenerate_uid()[source]

Regenerate the UUID as there has been a clash

request_source()[source]

Return the IP address of the source of this request. This could be used to rate limit someone who is maliciously requesting logins…

save()[source]

Save the current state of this LoginSession to the object store

scope()[source]

Return the scope requested for this login session

seconds_since_creation()[source]

Return the number of seconds since this request was created

set_approved(user_uid=None, device_uid=None)[source]

Register that this request has been approved, optionally providing data about the user who approved the session and the device from which the session was approved

set_denied()[source]

Register that this request has been denied

set_logged_out(authorisation=None, signature=None)[source]

Register that this request has been closed as the user has logged out. If an authorisation is passed then verify that this is correct

set_suspicious()[source]

Put this login session into a suspicious state. This will be because weird activity has been detected which indicates that the session may be have been cracked. A login session in a suspicious state should not be granted any permissions.

short_uid()[source]

Return a short UUID that will be used to provide a more human-readable session ID

status()[source]

Return the status of this login session

to_data()[source]

Return a data version (dictionary) of this LoginSession that can be serialised to json

static to_short_uid(long_uid)[source]

Return the short UID version of the passed long uid

uid()[source]

Return the UID of this request

user_uid()[source]

If known, return the UID of the user who approved this session

username()[source]

Return the username for this login session