from .interfaces import (
    IAuthSourceService,
    IAuthService,
    )

from .policy import (
    AuthServicePolicy,
    NoAuthCompleted,
    )

def includeme(config):
    config.set_authentication_policy(AuthServicePolicy())

@@ -1,12 +1,74 @@
+from pyramid.settings import (%0A    asbool,%0A    aslist,%0A    )%0A%0A
 from .interf
@@ -77,24 +77,24 @@
 es import (%0A
-
     IAuthSou
@@ -207,30 +207,1907 @@
  )%0A%0A
-def includeme(config):
+from .sources import (%0A    SessionAuthSourceInitializer,%0A    CookieAuthSourceInitializer,%0A    )%0A%0Afrom .util import (%0A    int_or_none,%0A    kw_from_settings,%0A    )%0A%0Adefault_settings = (%0A    ('source', str, ''),%0A    ('cookie.cookie_name', str, 'auth'),%0A    ('cookie.max_age', int_or_none, None),%0A    ('cookie.httponly', asbool, False),%0A    ('cookie.path', str, '/'),%0A    ('cookie.domains', aslist, %5B%5D),%0A    ('cookie.debug', asbool, False),%0A    ('session.value_key', str, 'sanity.'),%0A)%0A%0Adef init_cookie_source(config, settings):%0A    if 'authsanity.secret' not in settings:%0A        raise RuntimeError('authsanity.secret is required for cookie based storage')%0A%0A    kw = kw_from_settings(settings, 'authsanity.cookie.')%0A%0A    config.register_service_factory(CookieAuthSourceInitializer(settings%5B'authsanity.secret'%5D, **kw), iface=IAuthSourceService)%0A%0Adef init_session_source(config, settings):%0A    kw = kw_from_settings(settings, 'authsanity.session.')%0A%0A    config.register_service_factory(SessionAuthSourceInitializer(**kw), iface=IAuthSourceService)%0A%0Adefault_sources = %7B%0A    'cookie': init_cookie_source,%0A    'session': init_session_source,%0A%7D%0A%0A# Stolen from pyramid_debugtoolbar%0Adef parse_settings(settings):%0A    parsed = %7B%7D%0A%0A    def populate(name, convert, default):%0A        name = '%25s%25s' %25 ('authsanity.', name)%0A        value = convert(settings.get(name, default))%0A        parsed%5Bname%5D = value%0A    for name, convert, default in default_settings:%0A        populate(name, convert, default)%0A    return parsed%0A%0A%0Adef includeme(config):%0A    # Go parse the settings%0A    settings = parse_settings(config.registry.settings)%0A%0A    # Update the config%0A    config.registry.settings.update(settings)%0A%0A    # include pyramid_services%0A    config.include('pyramid_services')%0A%0A    if settings%5B'authsanity.source'%5D in default_sources:%0A        default_sources%5Bsettings%5B'authsanity.source'%5D%5D(config, config.registry.settings)%0A
 %0A   

Add settings that can set various defaults