当前位置: 首页>>代码示例>>Python>>正文


Python SimpleCookie.get方法代码示例

本文整理汇总了Python中six.moves.http_cookies.SimpleCookie.get方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleCookie.get方法的具体用法?Python SimpleCookie.get怎么用?Python SimpleCookie.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.http_cookies.SimpleCookie的用法示例。


在下文中一共展示了SimpleCookie.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cookie_parts

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
def cookie_parts(name, kaka):
    cookie_obj = SimpleCookie(kaka)
    morsel = cookie_obj.get(name)
    if morsel:
        return morsel.value.split("|")
    else:
        return None
开发者ID:HaToHo,项目名称:pysaml2,代码行数:9,代码来源:httputil.py

示例2: parse_cookie

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
def parse_cookie(name, seed, kaka):
    """Parses and verifies a cookie value

    :param seed: A seed used for the HMAC signature
    :param kaka: The cookie
    :return: A tuple consisting of (payload, timestamp)
    """
    if not kaka:
        return None

    cookie_obj = SimpleCookie(kaka)
    morsel = cookie_obj.get(name)

    if morsel:
        parts = morsel.value.split("|")
        if len(parts) != 3:
            return None
            # verify the cookie signature
        sig = cookie_signature(seed, parts[0], parts[1])
        if sig != parts[2]:
            raise SAMLError("Invalid cookie signature")

        try:
            return parts[0].strip(), parts[1]
        except KeyError:
            return None
    else:
        return None
开发者ID:HaToHo,项目名称:pysaml2,代码行数:30,代码来源:httputil.py

示例3: delete_cookie

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
def delete_cookie(environ, name):
    kaka = environ.get("HTTP_COOKIE", "")
    logger.debug("delete KAKA: %s", kaka)
    if kaka:
        cookie_obj = SimpleCookie(kaka)
        morsel = cookie_obj.get(name, None)
        cookie = SimpleCookie()
        cookie[name] = ""
        cookie[name]["path"] = "/"
        logger.debug("Expire: %s", morsel)
        cookie[name]["expires"] = _expiration("dawn")
        return tuple(cookie.output().split(": ", 1))
    return None
开发者ID:tophatmonocle,项目名称:pysaml2,代码行数:15,代码来源:idp.py

示例4: delete_cookie

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
 def delete_cookie(self, environ):
     cookie = environ.get("HTTP_COOKIE", '')
     logger.debug("delete cookie: %s", cookie)
     if cookie:
         _name = self.cookie_name
         cookie_obj = SimpleCookie(cookie)
         morsel = cookie_obj.get(_name, None)
         cookie = SimpleCookie()
         cookie[_name] = ""
         cookie[_name]['path'] = "/"
         logger.debug("Expire: %s", morsel)
         cookie[_name]["expires"] = _expiration("now")
         return cookie.output().split(": ", 1)
     return None
开发者ID:Lefford,项目名称:pysaml2,代码行数:16,代码来源:sp.py

示例5: info_from_cookie

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
def info_from_cookie(kaka):
    logger.debug("KAKA: %s", kaka)
    if kaka:
        cookie_obj = SimpleCookie(kaka)
        morsel = cookie_obj.get("idpauthn", None)
        if morsel:
            try:
                key, ref = base64.b64decode(morsel.value).split(":")
                return IDP.cache.uid2user[key], ref
            except (KeyError, TypeError):
                return None, None
        else:
            logger.debug("No idpauthn cookie")
    return None, None
开发者ID:jkakavas,项目名称:pysaml2,代码行数:16,代码来源:idp.py

示例6: get_user

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
    def get_user(self, environ):
        cookie = environ.get("HTTP_COOKIE", '')
        logger.debug("Cookie: %s", cookie)
        if cookie:
            cookie_obj = SimpleCookie(cookie)
            morsel = cookie_obj.get(self.cookie_name, None)
            if morsel:
                try:
                    return self.uid2user[morsel.value]
                except KeyError:
                    return None
            else:
                logger.debug("No %s cookie", self.cookie_name)

        return None
开发者ID:Lefford,项目名称:pysaml2,代码行数:17,代码来源:sp.py

示例7: _websocket_auth

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
 def _websocket_auth(self, queue_events_data: Dict[str, Dict[str, str]],
                     cookies: SimpleCookie) -> Generator[str, str, None]:
     message = {
         "req_id": self._get_request_id(),
         "type": "auth",
         "request": {
             "csrf_token": cookies.get(settings.CSRF_COOKIE_NAME),
             "queue_id": queue_events_data['queue_id'],
             "status_inquiries": []
         }
     }
     auth_frame_str = ujson.dumps(message)
     self.ws.write_message(ujson.dumps([auth_frame_str]))
     response_ack = yield self.ws.read_message()
     response_message = yield self.ws.read_message()
     raise gen.Return([response_ack, response_message])
开发者ID:brockwhittaker,项目名称:zulip,代码行数:18,代码来源:websocket_client.py

示例8: info_from_cookie

# 需要导入模块: from six.moves.http_cookies import SimpleCookie [as 别名]
# 或者: from six.moves.http_cookies.SimpleCookie import get [as 别名]
def info_from_cookie(kaka):
    logger.debug("KAKA: %s", kaka)
    if kaka:
        cookie_obj = SimpleCookie(kaka)
        morsel = cookie_obj.get("idpauthn", None)
        if morsel:
            try:
                data = base64.b64decode(morsel.value)
                if not isinstance(data, six.string_types):
                    data = data.decode("ascii")
                key, ref = data.split(":", 1)
                return IDP.cache.uid2user[key], ref
            except (KeyError, TypeError):
                return None, None
        else:
            logger.debug("No idpauthn cookie")
    return None, None
开发者ID:tophatmonocle,项目名称:pysaml2,代码行数:19,代码来源:idp.py


注:本文中的six.moves.http_cookies.SimpleCookie.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。