Authomatic
is an authorization / authentication
client library for Python web applications
inspired by Alex Vagin’s Simpleauth.
In fact, I almost named it Deadsimpleauth,
but that name would be too long
for a succinct library.

- Tweet

# Extras

Contents

- Extras
  - Flask Extras
  - Google App Engine Extras
  - Interfaces

## Flask Extras

Utilities you can use when using this library with the Flask framework.

Thanks to Mark Steve Samson.

class `authomatic.extras.flask.``FlaskAuthomatic`(config, secret, session_max_age=600, secure_cookie=False, session=None, session_save_method=None, report_errors=True, debug=False, logging_level=20, prefix='authomatic')

  Flask Plugin for authomatic support.

  Encapsulates all the functionality of this package.

  Parameters: | config (dict) – Config secret (str) – A secret string that will be used as the key for signing `Session` cookie and as a salt by CSRF token generation. session_max_age – Maximum allowed age of `Session` cookie nonce in seconds. secure_cookie (bool) – If `True` the `Session` cookie will be saved wit `Secure` attribute. session – Custom dictionary-like session implementation. session_save_method (callable) – A method of the supplied session or any mechanism that saves the session data and cookie. report_errors (bool) – If `True` exceptions encountered during the login procedure will be caught and reported in the `LoginResult.error` attribute. Default is `True`. debug (bool) – If `True` traceback of exceptions will be written to response. Default is `False`. logging_level (int) – The logging level threshold as specified in the standard Python logging library. Default is `logging.INFO` prefix (str) – Prefix used as the `Session` cookie name.

  `login`(*login_args, **login_kwargs)

    Decorator for Flask view functions.

## Google App Engine Extras

Utilities you can use when using this library on Google App Engine.

class `authomatic.extras.gae.``Webapp2Session`(handler, session=None, secret=None, cookie_name='webapp2authomatic', backend='memcache', config=None)

  A simple wrapper for Webapp2 sessions. If you provide a session it wraps it and adds the `save()` method.

  If you don’t provide a session it creates a new one but you must provide the `secret`.

  For more about Webapp2 sessions see: `http://webapp-improved.appspot.com/api/webapp2_extras/sessions.html`_.

  Warning

  Do not use the `'securecookie'` backend with `providers.OpenID` provider. The python-openid library saves non json serializable objects to session which the `'securecookie'` backend cannot cope with.

  Parameters: | handler – A `webapp2.RequestHandler` instance. session – A `webapp2_extras.session.SessionDict` instance. secret (str) – The session secret. cookie_name (str) – The name of the session cookie. backend – The session backend. One of `'memcache'` or `'datastore'`. config – The session config.

`authomatic.extras.gae.``ndb_config`()

  Allows you to have a datastore Config instead of a hardcoded one.

  This function creates an “Example” entity of kind “NDBConfig” in the datastore if the model is empty and raises and error to inform you that you should populate the model with data.

  Note

  The Datastore Viewer of the Google App Engine admin won’t let you add properties to a model if there is not an entity with that property already. Therefore it is a good idea to keep the “Example” entity (which has all properties set) in the datastore.

  Raises : | `GAEError`
  Returns: | `NDBConfig`

## Interfaces

If you want to implement framework specific extras, use these abstract classes as bases:

class `authomatic.extras.interfaces.``BaseSession`

  Abstract class for custom session implementations.

  `save`()

    Called only once per request. Should implement a mechanism for setting the the session cookie and saving the session data to storage.

  `get`(key)

    Same as `dict.get()`.

class `authomatic.extras.interfaces.``BaseConfig`

  Abstract class for Config implementations.

  `get`(key)

    Same as `dict.get`.

  `values`()

    Same as `dict.values()`.