Models

Auth Token

class auth_token.models.Token

Model for storing authorization tokens.

key

CharField, contains authorization token value.

user

ForeignKey, foreign key to the logged user.

created_at

DateTimeField, contains date and time of token creation.

last_access

DateTimeField, contains date and time of lost token access.

is_active

BooleanField contains if token is active.

user_agent

CharField, stored HTTP header User-Agent, that was get during token creation.

expiration

BooleanField, contains information if user set preserved token.

ip

IP address of the logged user.

auth_slug

SlugField, slug that you can use for your own purposes.

backend

Field contains name of the django authorization backend

class auth_token.models.TokenRelatedObject

Model storing related objects with authorization token

token

Relation to the authorization token.

content_type

Content type of the related object.

object_id

Identifier of the related object.

content_object

Related object (GenericForeignKey)

class auth_token.models.UserTokenTakeover

Model contains information about token takeover.

token

Relation to the authorization token.

user

Took over user.

is_active

BooleanField contains if token takeover is active.

class auth_token.models.AnonymousToken

AnonymousToken has save purpose as Django AnonymousUser. If you are using auth_token middleware, the request contains token (request.token). If token is not found the AnonymousToken is set to the request.

Device Authentication

class auth_token.models.DeviceKey

Model storing keys of registered mobile devices.

uuid

CharField, contains UUID of registered device (it’s not valid UUID in terms of length, any length up to 32 characters is accepted as valid)

last_login

DateTimeField, holds the time and date of the last login using this key

user

ForeignKey, user object implementing django.contrib.auth.base_user.AbstractBaseUser

login_token

CharField, hashed generated token used as a password

is_active

BooleanField, keys having this flag set to False will be ignored during user login

user_agent

CharField, additional information of the device

class auth_token.models.DeviceKeyQuerySet

This class is the objects manager of auth_token.models.DeviceKey model

get_or_create_token(self, uuid, user, user_agent='')
  • uuid - uuid.UUID object from standard Python library
  • user - user object implementing django.contrib.auth.base_user.AbstractBaseUser class
  • user_agent - str object with additional information about the device, could be just HTTP_USER_AGENT entry of META field from the request.