Beispiel #1
0
Datei: wsgi.py Projekt: plq/spyne
    def get_cookie(self, key):
        cookie_string = self.req_env.get('HTTP_COOKIE', None)
        if cookie_string is None:
            return

        cookie = SimpleCookie()
        cookie.load(cookie_string)

        return cookie.get(key, None).value
Beispiel #2
0
    def get_cookie(self, key):
        cookie_string = self.req_env.get('HTTP_COOKIE', None)
        if cookie_string is None:
            return

        cookie = SimpleCookie()
        cookie.load(cookie_string)

        return cookie.get(key, None).value
Beispiel #3
0
def _on_method_call(ctx):
    if ctx.descriptor.name == "authenticate":
        # No checking of session cookie for call to authenticate
        return

    cookie = SimpleCookie()
    http_cookie = ctx.transport.req_env.get("HTTP_COOKIE")
    if http_cookie:
        cookie.load(http_cookie)
    if "session-id" not in cookie:
        raise UnauthenticatedError()
    session_cookie = cookie["session-id"].value
    session_id = tuple(base64.urlsafe_b64decode(session_cookie).split("\0", 1))
    if not session_id in session_db:
        raise AuthenticationError(session_id[0])
    ctx.udc = session_id[0]  # user name
Beispiel #4
0
    def decompose_incoming_envelope(self, ctx, message):
        assert message == SimpleDictDocument.REQUEST

        ctx.transport.itself.decompose_incoming_envelope(self, ctx, message)

        if self.parse_cookie:
            cookies = ctx.in_header_doc.get('cookie', None)
            if cookies is None:
                cookies = ctx.in_header_doc.get('Cookie', None)
            if cookies is not None:
                for cookie_string in cookies:
                    cookie = SimpleCookie()
                    cookie.load(cookie_string)
                    for k,v in cookie.items():
                        l = ctx.in_header_doc.get(k, [])
                        l.append(v.coded_value)
                        ctx.in_header_doc[k] = l

        logger.debug('\theader : %r' % (ctx.in_header_doc))
        logger.debug('\tbody   : %r' % (ctx.in_body_doc))
Beispiel #5
0
    def decompose_incoming_envelope(self, ctx, message):
        assert message == SimpleDictDocument.REQUEST

        ctx.transport.itself.decompose_incoming_envelope(self, ctx, message)

        if self.parse_cookie:
            cookies = ctx.in_header_doc.get('cookie', None)
            if cookies is None:
                cookies = ctx.in_header_doc.get('Cookie', None)
            if cookies is not None:
                for cookie_string in cookies:
                    cookie = SimpleCookie()
                    cookie.load(cookie_string)
                    for k, v in cookie.items():
                        l = ctx.in_header_doc.get(k, [])
                        l.append(v.coded_value)
                        ctx.in_header_doc[k] = l

        logger.debug('\theader : %r' % (ctx.in_header_doc))
        logger.debug('\tbody   : %r' % (ctx.in_body_doc))