Example #1
0
__all__ = (
    'DEFAULT_POLICY',
    'WEBSOCKET_POLICY',
)

log = logging.getLogger(__name__)

PROXY_POLICY = RemoteUserAuthenticationPolicy(
    environ_key='HTTP_X_FORWARDED_USER', callback=groupfinder)
TICKET_POLICY = pyramid_authsanity.AuthServicePolicy()

TOKEN_POLICY = TokenAuthenticationPolicy(callback=groupfinder)
AUTH_CLIENT_POLICY = AuthClientPolicy()

API_POLICY = APIAuthenticationPolicy(user_policy=TOKEN_POLICY,
                                     client_policy=AUTH_CLIENT_POLICY)

DEFAULT_POLICY = AuthenticationPolicy(api_policy=API_POLICY,
                                      fallback_policy=TICKET_POLICY)
WEBSOCKET_POLICY = TOKEN_POLICY


def includeme(config):
    global DEFAULT_POLICY
    global WEBSOCKET_POLICY

    # Set up authsanity
    settings = config.registry.settings
    settings['authsanity.source'] = 'cookie'
    settings['authsanity.cookie.max_age'] = 2592000
    settings['authsanity.cookie.httponly'] = True
Example #2
0
 def api_policy(self, client_policy, user_policy):
     return APIAuthenticationPolicy(user_policy=user_policy,
                                    client_policy=client_policy)