Пример #1
0
def _adapter_for(name, profile):
    return match(
        Profile, {
            SignedProfile: (lambda config, secret, salt: SignedCookieProfile(
                secret, salt, name, **config)),
            UnsignedProfile: (lambda config: CookieProfile(name, **config))
        }, profile)
Пример #2
0
def factory(_context, request):
    """Return a AuthCookieService instance for the passed context and request."""

    cookie = SignedCookieProfile(
        # This value is set in `h.auth` at the moment
        secret=request.registry.settings["h_auth_cookie_secret"],
        salt="authsanity",
        cookie_name="auth",
        secure=False,
        max_age=30 * 24 * 3600,  # 30 days
        httponly=True,
    )

    return AuthCookieService(
        request.db,
        user_service=request.find_service(name="user"),
        cookie=cookie.bind(request),
    )
Пример #3
0
        def __init__(self, context, request):
            self.domains = domains

            if self.domains is None:
                self.domains = []
                self.domains.append(request.domain)

            self.cookie = SignedCookieProfile(
                secret,
                'authsanity',
                cookie_name,
                secure=secure,
                max_age=max_age,
                httponly=httponly,
                path=path,
                domains=domains,
                hashalg=hashalg,
            )
            # Bind the cookie to the current request
            self.cookie = self.cookie.bind(request)