defernia.creds — User credentials

Defernia provides various (currently two) ways to sign in: Login with Facebook, Login with Twitter, and other services could be added in the future.

Credential abstracts each detail of various login services.

In order to define a new credential service, subclass Credential and then define typeid class attribute:

class WindowsLive(Credential):
    '''The Microsoft's legendary SSO (single sign on) service,
    was Passport before.

    '''

    typeid = 'live.com'

Note that typeid should be the service’s canonical domain name such as 'live.com'. This attribute will be internally used for service identifier.

class defernia.creds.Credential(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

Defernia user credentials.

typeid = NotImplemented

The class attribute to be defined for concrete subclasses. It is a default type of the class. It should be the service’s canonical domain name such as 'facebook.com'.

user_id

The foreign key id of user.

user

The owner.

type

The credential type e.g. 'facebook.com', 'twitter.com'. It should be the service’s canonical domain name.

identifier

The user identifier used in the service.

data

The extra data for the credential.

defernia.creds.find_type(typeid)

A class method that finds the subtype of the given typeid.

Parameters:typeid (basestring) – internally used typeid string e.g. 'facebook.com'
Returns:a subtype of Credential
Return type:type
Rairses :LookupError when cannot found the class
defernia.creds.list_types(mixin=<class 'defernia.creds.Credential'>)

Lists all credential types.

Parameters:mixin (type) – an optional mixin class filter. if it is present, lists only subclass of given mixin
Returns:a dictionary of credential types (keys are typeid strings)
Return type:dict
defernia.creds.data_property(key, doc=None)

Makes a descriptor that deals with data dictionary’s specific key.

class HongMinheeWebsite(Credential):
    typeid = 'dahlia.kr'
    gender = data_property('gender', "The ``'male'`` or ``'female'``.")
    birthday = data_property('birthday')
Parameters:
  • key – the key of data dictionary
  • doc (str) – an optional docstring
Returns:

a descriptor for key

Return type:

property

class defernia.creds.PictureMixin(**kwargs)

Bases: defernia.creds.Credential

The credential mixin class for getting profile pictures.

picture_url

The profile picture URL. To be overrided in the subclass. None if there’s no picture.

class defernia.creds.Facebook(**kwargs)

Bases: defernia.creds.PictureMixin

Login with Facebook.

class defernia.creds.Twitter(**kwargs)

Bases: defernia.creds.PictureMixin

Login with Twitter.

screen_name

The Twitter screen name.

Project Versions

Previous topic

defernia.world.repodir — Repositories directory

Next topic

defernia.objsimplify — Object simplifier for generic serialization

This Page