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


Python logging_util.satosa_logging函数代码示例

本文整理汇总了Python中satosa.logging_util.satosa_logging函数的典型用法代码示例。如果您正苦于以下问题:Python satosa_logging函数的具体用法?Python satosa_logging怎么用?Python satosa_logging使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _handle_backend_error

    def _handle_backend_error(self, exception, idp):
        """
        See super class satosa.frontends.base.FrontendModule

        :type exception: satosa.exception.SATOSAAuthenticationError
        :type idp: saml.server.Server
        :rtype: satosa.response.Response

        :param exception: The SATOSAAuthenticationError
        :param idp: The saml frontend idp server
        :return: A response
        """
        loaded_state = self.load_state(exception.state)
        relay_state = loaded_state["relay_state"]
        resp_args = loaded_state["resp_args"]
        error_resp = idp.create_error_response(resp_args["in_response_to"],
                                               resp_args["destination"],
                                               Exception(exception.message))
        http_args = idp.apply_binding(
            resp_args["binding"], "%s" % error_resp,
            resp_args["destination"],
            relay_state, response=True)

        satosa_logging(LOGGER, logging.DEBUG, "HTTPargs: %s" % http_args, exception.state)
        return response(resp_args["binding"], http_args)
开发者ID:digideskio,项目名称:SATOSA,代码行数:25,代码来源:saml2.py

示例2: _translate_response

    def _translate_response(self, response, state):
        """
        Translates a saml authorization response to an internal response

        :type response: saml2.response.AuthnResponse
        :rtype: satosa.internal_data.InternalResponse
        :param response: The saml authorization response
        :return: A translated internal response
        """
        _authn_info = response.authn_info()[0]
        timestamp = response.assertion.authn_statement[0].authn_instant
        issuer = response.response.issuer.text
        auth_class_ref = _authn_info[0]

        auth_info = AuthenticationInformation(auth_class_ref, timestamp, issuer)
        internal_resp = InternalResponse(auth_info=auth_info)

        internal_resp.set_user_id(response.get_subject().text)
        if "user_id_params" in self.config:
            user_id = ""
            for param in self.config["user_id_params"]:
                try:
                    user_id += response.ava[param]
                except Exception as error:
                    raise SATOSAAuthenticationError from error
            internal_resp.set_user_id(user_id)

        internal_resp.add_attributes(self.converter.to_internal(self.attribute_profile, response.ava))

        satosa_logging(LOGGER, logging.DEBUG,
                       "received attributes:\n%s" % json.dumps(response.ava, indent=4), state)

        return internal_resp
开发者ID:borgand,项目名称:SATOSA,代码行数:33,代码来源:saml2.py

示例3: manage_al

    def manage_al(self, context, internal_response):
        """
        Manage account linking and recovery

        :type context: satosa.context.Context
        :type internal_response: satosa.internal_data.InternalResponse
        :rtype: satosa.response.Response

        :param context:
        :param internal_response:
        :return: response
        """

        if not self.enabled:
            return self.callback_func(context, internal_response)

        issuer = internal_response.auth_info.issuer
        id = internal_response.get_user_id()
        status_code, message = self._get_uuid(context, issuer, id)

        if status_code == 200:
            satosa_logging(LOGGER, logging.INFO, "issuer/id pair is linked in AL service",
                           context.state)
            internal_response.set_user_id(message)
            try:
                context.state.remove(AccountLinkingModule.STATE_KEY)
            except KeyError:
                pass
            return self.callback_func(context, internal_response)

        return self._approve_new_id(context, internal_response, message)
开发者ID:borgand,项目名称:SATOSA,代码行数:31,代码来源:account_linking.py

示例4: redirect_endpoint

    def redirect_endpoint(self, context, *args):
        """
        Handles the authentication response from the OP.
        :type context: satosa.context.Context
        :type args: Any
        :rtype: satosa.response.Response

        :param context: SATOSA context
        :param args: None
        :return:
        """
        state = context.state
        backend_state = state.get(self.config.STATE_ID)
        if backend_state["state"] != context.request["state"]:
            satosa_logging(LOGGER, logging.DEBUG,
                           "Missing or invalid state in authn response for state: %s" %
                           backend_state,
                           state)
            raise SATOSAAuthenticationError(state, "Missing or invalid state in authn response")
        client = self.restore_state(backend_state)
        result = client.callback(context.request, state, backend_state)
        context.state.remove(self.config.STATE_ID)
        return self.auth_callback_func(context,
                                       self._translate_response(
                                           result,
                                           client.authorization_endpoint,
                                           self.get_subject_type(client),
                                       ))
开发者ID:borgand,项目名称:SATOSA,代码行数:28,代码来源:openid_connect.py

示例5: get_filter_attributes

    def get_filter_attributes(self, idp, idp_policy, sp_entity_id, state):
        """
        Returns a list of approved attributes

        :type idp: saml.server.Server
        :type idp_policy: saml2.assertion.Policy
        :type sp_entity_id: str
        :type state: satosa.state.State
        :rtype: list[str]

        :param idp: The saml frontend idp server
        :param idp_policy: The idp policy
        :param sp_entity_id: The requesting sp entity id
        :param state: The current state
        :return: A list containing approved attributes
        """
        name_format = idp_policy.get_name_form(sp_entity_id)
        attrconvs = idp.config.attribute_converters
        idp_policy.acs = attrconvs
        attribute_filter = []
        for aconv in attrconvs:
            if aconv.name_format == name_format:
                attribute_filter = list(idp_policy.restrict(aconv._to, sp_entity_id, idp.metadata).keys())
        attribute_filter = self.converter.to_internal_filter(self.attribute_profile, attribute_filter, True)
        satosa_logging(LOGGER, logging.DEBUG, "Filter: %s" % attribute_filter, state)
        return attribute_filter
开发者ID:borgand,项目名称:SATOSA,代码行数:26,代码来源:saml2.py

示例6: _save_state

    def _save_state(self, resp, context):
        """
        Saves a state from context to cookie

        :type resp: satosa.response.Response
        :type context: satosa.context.Context

        :param resp: The response
        :param context: Session context
        """
        if context.state.should_delete():
            # Save empty state with a max age of 0
            cookie = state_to_cookie(State(),
                                     self.config.COOKIE_STATE_NAME,
                                     "/",
                                     self.config.STATE_ENCRYPTION_KEY,
                                     0)
        else:
            cookie = state_to_cookie(context.state,
                                     self.config.COOKIE_STATE_NAME,
                                     "/",
                                     self.config.STATE_ENCRYPTION_KEY)

        if isinstance(resp, Response):
            resp.add_cookie(cookie)
        else:
            try:
                resp.headers.append(tuple(cookie.output().split(": ", 1)))
            except:
                satosa_logging(LOGGER, logging.WARN,
                               "can't add cookie to response '%s'" % resp.__class__, context.state)
                pass
开发者ID:borgand,项目名称:SATOSA,代码行数:32,代码来源:base.py

示例7: _auth_req_callback_func

    def _auth_req_callback_func(self, context, internal_request):
        """
        This function is called by a frontend module when an authorization request has been
        processed.

        :type context: satosa.context.Context
        :type internal_request: satosa.internal_data.InternalRequest
        :rtype: satosa.response.Response

        :param context: The request context
        :param internal_request: request processed by the frontend

        :return: response
        """
        state = context.state
        state.add(SATOSABase.STATE_KEY, internal_request.requestor)
        satosa_logging(LOGGER, logging.INFO,
                       "Requesting provider: {}".format(internal_request.requestor), state)
        context.request = None
        backend = self.module_router.backend_routing(context)
        self.consent_module.save_state(internal_request, state)
        UserIdHasher.save_state(internal_request, state)
        if self.request_micro_services:
            internal_request = self.request_micro_services.process_service_queue(context,
                                                                                 internal_request)
        return backend.start_auth(context, internal_request)
开发者ID:borgand,项目名称:SATOSA,代码行数:26,代码来源:base.py

示例8: state_to_cookie

def state_to_cookie(state, name, path, encryption_key, max_age=STATE_COOKIE_MAX_AGE):
    """
    Saves a state to a cookie

    :type state: satosa.state.State
    :type name: str
    :type path: str
    :type encryption_key: str
    :rtype: http.cookies.SimpleCookie

    :param state: The state to save
    :param name: Name identifier of the cookie
    :param path: Endpoint path the cookie will be associated to
    :param encryption_key: Key to encrypt the state information
    :return: A cookie
    """
    satosa_logging(LOGGER, logging.DEBUG,
                   "Saving state as cookie, secure: %s, max-age: %s, path: %s" %
                   (STATE_COOKIE_SECURE, STATE_COOKIE_MAX_AGE, path), state)
    cookie = SimpleCookie()
    cookie[name] = state.urlstate(encryption_key)
    cookie[name]["secure"] = STATE_COOKIE_SECURE
    cookie[name]["path"] = path
    cookie[name]["max-age"] = max_age
    return cookie
开发者ID:borgand,项目名称:SATOSA,代码行数:25,代码来源:state.py

示例9: run

    def run(self, context):
        """
        Runs the satosa proxy with the given context.

        :type context: satosa.context.Context
        :rtype: satosa.response.Response

        :param context: The request context
        :return: response
        """
        try:
            self._load_state(context)
            spec = self.module_router.endpoint_routing(context)
            resp = self._run_bound_endpoint(context, spec)
            self._save_state(resp, context)
        except SATOSANoBoundEndpointError:
            raise
        except SATOSAError:
            satosa_logging(LOGGER, logging.ERROR, "Uncaught SATOSA error", context.state,
                           exc_info=True)
            raise
        except Exception as err:
            satosa_logging(LOGGER, logging.ERROR, "Uncaught exception", context.state,
                           exc_info=True)
            raise SATOSAUnknownError("Unknown error") from err
        return resp
开发者ID:digideskio,项目名称:SATOSA,代码行数:26,代码来源:base.py

示例10: handle_authn_request

    def handle_authn_request(self, context):
        """
        Parse and verify the authentication request and pass it on to the backend.
        :type context: satosa.context.Context
        :rtype: oic.utils.http_util.Response

        :param context: the current context
        :return: HTTP response to the client
        """

        # verify auth req (correct redirect_uri, contains nonce and response_type='id_token')
        request = urlencode(context.request)
        satosa_logging(LOGGER, logging.DEBUG, "Authn req from client: {}".format(request),
                       context.state)

        info = self.provider.auth_init(request, request_class=AuthorizationRequest)
        if isinstance(info, Response):
            satosa_logging(LOGGER, logging.ERROR, "Error in authn req: {}".format(info.message),
                           context.state)
            return info

        client_id = info["areq"]["client_id"]

        context.state.add(self.state_id, {"oidc_request": request})
        hash_type = oidc_subject_type_to_hash_type(
                self.provider.cdb[client_id].get("subject_type", self.subject_type_default))
        internal_req = InternalRequest(hash_type, client_id,
                                       self.provider.cdb[client_id].get("client_name"))

        return self.auth_req_callback_func(context, internal_req)
开发者ID:borgand,项目名称:SATOSA,代码行数:30,代码来源:oidc.py

示例11: _populate_attributes

 def _populate_attributes(self, config, record, context, data):
     """
     Use a record found in LDAP to populate attributes.
     """
     search_return_attributes = config['search_return_attributes']
     for attr in search_return_attributes.keys():
         if attr in record["attributes"]:
             if record["attributes"][attr]:
                 data.attributes[search_return_attributes[attr]] = record["attributes"][attr]
                 satosa_logging(
                     logger,
                     logging.DEBUG,
                     "Setting internal attribute {} with values {}".format(
                         search_return_attributes[attr],
                         record["attributes"][attr]
                         ),
                     context.state
                     )
             else:
                 satosa_logging(
                     logger,
                     logging.DEBUG,
                     "Not setting internal attribute {} because value {} is null or empty".format(
                         search_return_attributes[attr],
                         record["attributes"][attr]
                         ),
                     context.state
                     )
开发者ID:SUNET,项目名称:SATOSA,代码行数:28,代码来源:ldap_attribute_store.py

示例12: check_set_dict_defaults

def check_set_dict_defaults(dic, spec):
    for path, value in spec.items():
        keys = path.split('.')
        try:
            _val = dict_get_nested(dic, keys)
        except KeyError:
            if type(value) is list:
                value_default = value[0]
            else:
                value_default = value
            dict_set_nested(dic, keys, value_default)
        else:
            if type(value) is list:
                is_value_valid = _val in value
            elif type(value) is dict:
                # do not validate dict
                is_value_valid = bool(_val)
            else:
                is_value_valid = _val == value
            if not is_value_valid:
                satosa_logging(
                    logger, logging.WARNING,
                    "Incompatible configuration value '{}' for '{}'."
                    " Value shoud be: {}".format(_val, path, value),
                    {})
    return dic
开发者ID:SUNET,项目名称:SATOSA,代码行数:26,代码来源:util.py

示例13: create_authn_request

    def create_authn_request(self, state, oidc_state, nonce, acr_value=None, **kwargs):
        """
        Creates an oidc authentication request.
        :type state: satosa.state.State
        :type oidc_state: str
        :type nonce: str
        :type acr_value: list[str]
        :type kwargs: Any
        :rtype: satosa.response.Redirect

        :param state: Module state
        :param oidc_state: OIDC state
        :param nonce: A nonce
        :param acr_value: Authentication type
        :param kwargs: Whatever
        :return: A redirect to the OP
        """
        request_args = self.setup_authn_request_args(acr_value, kwargs, oidc_state, nonce)

        cis = self.construct_AuthorizationRequest(request_args=request_args)
        satosa_logging(LOGGER, logging.DEBUG, "request: %s" % cis, state)

        url, body, ht_args, cis = self.uri_and_body(AuthorizationRequest, cis,
                                                    method="GET",
                                                    request_args=request_args)

        satosa_logging(LOGGER, logging.DEBUG, "body: %s" % body, state)
        satosa_logging(LOGGER, logging.INFO, "URL: %s" % url, state)
        satosa_logging(LOGGER, logging.DEBUG, "ht_args: %s" % ht_args, state)

        resp = Redirect(str(url))
        if ht_args:
            resp.headers.extend([(a, b) for a, b in ht_args.items()])
        satosa_logging(LOGGER, logging.DEBUG, "resp_headers: %s" % resp.headers, state)
        return resp
开发者ID:borgand,项目名称:SATOSA,代码行数:35,代码来源:openid_connect.py

示例14: ping_endpoint

    def ping_endpoint(self, context):
        """
        """
        logprefix = PingFrontend.logprefix
        satosa_logging(logger, logging.DEBUG, "{} ping returning 200 OK".format(logprefix), context.state)

        msg = " "

        return Response(msg)
开发者ID:SUNET,项目名称:SATOSA,代码行数:9,代码来源:ping.py

示例15: _metadata

    def _metadata(self, context):
        """
        Endpoint for retrieving the backend metadata
        :type context: satosa.context.Context
        :rtype: satosa.backends.saml2.MetadataResponse

        :param context: The current context
        :return: response with metadata
        """
        satosa_logging(LOGGER, logging.DEBUG, "Sending metadata response", context.state)
        return MetadataResponse(self.sp.config)
开发者ID:borgand,项目名称:SATOSA,代码行数:11,代码来源:saml2.py


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