예제 #1
0
    def handle_consent(self, context):
        consent_state = context.state[STATE_KEY]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)

        lang = context.request.get('lang', 'en')
        return self.render_consent(consent_state, internal_response, lang)
예제 #2
0
    def change_language(self, context):
        consent_state = context.state[consent.STATE_KEY]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)

        lang = context.request.get('lang', 'en')
        return self.render_consent(consent_state, internal_response, lang)
예제 #3
0
    def accept_consent(self, context):
        """
        Endpoint for handling accepted consent.
        :type context: satosa.context.Context
        :rtype: satosa.response.Response

        :param context: response context
        :return: response
        """
        consent_state = context.state[STATE_KEY]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)
        del context.state[STATE_KEY]

        log = {}
        log['router'] = context.state.state_dict['ROUTER']
        log['sessionid'] = context.state.state_dict['SESSION_ID']
        log['timestamp'] = saved_resp['auth_info'].get('timestamp')
        log['idp'] = saved_resp['auth_info'].get('issuer', None)
        log['rp'] = saved_resp.get('to', None)
        log['attr'] = saved_resp.get('attr', None)

        satosa_logging(logger, logging.INFO, "log: {}".format(log),
                       context.state)
        print(json.dumps(log), file=self.loghandle, end="\n")
        self.loghandle.flush()

        transaction_log(context.state,
                        self.config.get("consent_exit_order",
                                        1000), "user_consent", "accept",
                        "exit", "success", '', '', 'Consent given by the user')

        return super().process(context, internal_response)
예제 #4
0
파일: user_consent.py 프로젝트: SUNET/svs
    def change_language(self, context):
        consent_state = context.state[self.name]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)

        lang = context.request.get('lang', 'en')
        return self.render_consent(internal_response, lang)
예제 #5
0
 def _handle_endpoint(self, context):
     """
     The resume endpoint handler. It's main duty is restoring internal_response
     and checking the resume condition
     """
     logger.info("Handle BreakOut endpoint")
     breakout_state = context.state[STATE_KEY]
     saved_response = breakout_state["internal_resp"]
     logger.info("internal_resp: %s" % saved_response)
     internal_response = InternalResponse.from_dict(saved_response)
     self.resumed = True
     return self._check_requirement(context, internal_response)
예제 #6
0
    def _handle_al_response(self, context):
        """
        Endpoint for handling account linking service response

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

        :param context: The current context
        :return: response
        """
        saved_state = context.state.get(AccountLinkingModule.STATE_KEY)
        internal_response = InternalResponse.from_dict(saved_state)
        return self.manage_al(context, internal_response)
예제 #7
0
    def _handle_al_response(self, context):
        """
        Endpoint for handling account linking service response

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

        :param context: The current context
        :return: response
        """
        saved_state = context.state.get(AccountLinkingModule.STATE_KEY)
        internal_response = InternalResponse.from_dict(saved_state)
        return self.manage_al(context, internal_response)
예제 #8
0
파일: user_consent.py 프로젝트: SUNET/svs
    def accept_consent(self, context):
        """
        Endpoint for handling accepted consent.
        :type context: satosa.context.Context
        :rtype: satosa.response.Response

        :param context: response context
        :return: response
        """
        consent_state = context.state[self.name]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)
        del context.state[self.name]
        return super().process(context, internal_response)
예제 #9
0
    def accept_consent(self, context):
        """
        Endpoint for handling accepted consent.
        :type context: satosa.context.Context
        :rtype: satosa.response.Response

        :param context: response context
        :return: response
        """
        consent_state = context.state[consent.STATE_KEY]
        saved_resp = consent_state['internal_response']
        internal_response = InternalResponse.from_dict(saved_resp)
        del context.state[consent.STATE_KEY]
        return super().process(context, internal_response)
예제 #10
0
파일: consent.py 프로젝트: borgand/SATOSA
    def _handle_consent_response(self, context):
        """
        Endpoint for handling consent service response
        :type context: satosa.context.Context
        :rtype: satosa.response.Response

        :param context: response context
        :return: response
        """
        # Handle answer from consent service
        state = context.state
        consent_state = state.get(ConsentModule.STATE_KEY)
        saved_resp = consent_state["internal_resp"]

        # rebuild internal_response from state
        internal_response = InternalResponse.from_dict(saved_resp)

        requestor = internal_response.to_requestor

        hash_id = self._get_consent_id(requestor, internal_response.get_user_id(),
                                       internal_response.get_attributes())

        try:
            consent_attributes = self._verify_consent(hash_id)
        except ConnectionError:
            satosa_logging(LOGGER, logging.ERROR,
                           "Consent service is not reachable, no consent given.", state)
            # Send an internal_response without any attributes
            consent_attributes = None

        if consent_attributes is None:
            satosa_logging(LOGGER, logging.INFO, "Consent was NOT given", state)
            # If consent was not given, then don't send any attributes
            consent_attributes = []
        else:
            satosa_logging(LOGGER, logging.INFO, "Consent was given", state)

        internal_response = self._filter_attributes(internal_response, consent_attributes)
        return self._end_consent(context, internal_response)