Models (durin.models)

class durin.models.AuthToken(*args, **kwargs)[source]

Token model with a unique constraint on User <-> Client relationship.

client

Client ForeignKey

created

Created time

property expires_in

Dynamic property that gives the expiry attribute in human readable string format.

Uses humanize package.

expiry

Expiry time

property has_expired

Dynamic property that returns True if token has expired, otherwise False.

renew_token(request=None) → datetime.datetime[source]

Utility function to renew the token.

Updates the expiry attribute by Client.token_ttl.

token

Token string

user

User ForeignKey

class durin.models.Client(*args, **kwargs)[source]

Identifier to represent any API client/browser that consumes your RESTful API.

See example_project.models.ClientSettings if you wish to extend this model per your convenience.

name

A unique identification name for the client.

throttle_rate

Throttle rate for requests authed with this client.

Format: number_of_requests/period where period should be one of: (‘s’, ‘m’, ‘h’, ‘d’). (same format as DRF’s throttle rates)

Example: 100/h implies 100 requests each hour.

New in version 0.2.

token_ttl

Token Time To Live (TTL) in timedelta. Format: DAYS HH:MM:SS.