Beispiel #1
0
    def __after__(response):
        '''
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        '''

        if request_context.get('reponse_redirect', False):
            # FIXME: does this really do a redirect???
            return response

        param = request.params
        action = request_context['action']

        try:
            if c.audit['action'] in ['selfservice/index']:
                if isSelfTest():
                    log.debug("[__after__] Doing selftest!")

                    if "selftest_user" in param:
                        (c.user, _foo,
                         c.realm) = param["selftest_user"].rpartition('@')
                    else:
                        c.realm = ""
                        c.user = "******"
                        env = request.environ
                        uuser = env.get('REMOTE_USER')
                        if uuser is not None:
                            (c.user, _foo, c.realm) = uuser.rpartition('@')

                log.debug("[__after__] authenticating as %s in realm %s!" %
                          (c.user, c.realm))

                c.audit['user'] = c.user
                c.audit['realm'] = c.realm
                c.audit['success'] = True

                if 'serial' in param:
                    c.audit['serial'] = param['serial']
                    c.audit['token_type'] = getTokenType(param['serial'])

                audit = config.get('audit')
                audit.log(c.audit)

            return response

        except flap.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.exception("[__after__::%r] webob.exception %r" % (action, acc))
            Session.rollback()
            Session.close()
            # FIXME: verify that this really works
            raise acc

        except Exception as e:
            log.exception("[__after__] failed with error: %r" % e)
            Session.rollback()
            Session.close()
            return sendError(response, e, context='after')
Beispiel #2
0
 def __after__(self):
     c.audit['administrator'] = getUserFromRequest(request).get("login")
     if 'serial' in self.request_params:
         serial = self.request_params['serial']
         c.audit['serial'] = serial
         c.audit['token_type'] = getTokenType(serial)
     audit.log(c.audit)
Beispiel #3
0
 def __after__(self):
     c.audit['administrator'] = getUserFromRequest(request).get("login")
     if 'serial' in self.request_params:
         serial = self.request_params['serial']
         c.audit['serial'] = serial
         c.audit['token_type'] = getTokenType(serial)
     audit.log(c.audit)
Beispiel #4
0
    def __after__(
        self,
        action,
    ):
        '''

        '''
        param = request.params

        try:
            if c.audit['action'] in ['selfservice/index']:
                if isSelfTest():
                    log.debug("[__after__] Doing selftest!")
                    suser = getParam(param, "selftest_user", True)
                    if suser is not None:
                        (c.user, _foo, c.realm) = getParam(param,
                                                           "selftest_user",
                                                           True)\
                            .rpartition('@')
                    else:
                        c.realm = ""
                        c.user = "******"
                        env = request.environ
                        uuser = env.get('REMOTE_USER')
                        if uuser is not None:
                            (c.user, _foo, c.realm) = uuser.rpartition('@')

                log.debug("[__after__] authenticating as %s in realm %s!" %
                          (c.user, c.realm))

                c.audit['user'] = c.user
                c.audit['realm'] = c.realm
                c.audit['success'] = True

                if 'serial' in param:
                    c.audit['serial'] = param['serial']
                    c.audit['token_type'] = getTokenType(param['serial'])

                audit.log(c.audit)

            return response

        except webob.exc.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.exception("[__after__::%r] webob.exception %r" % (action, acc))
            Session.rollback()
            Session.close()
            raise acc

        except Exception as e:
            log.exception("[__after__] failed with error: %r" % e)
            Session.rollback()
            Session.close()
            return sendError(response, e, context='after')

        finally:
            log.debug('[__after__] done')
Beispiel #5
0
    def __after__(self):

        if c.audit["action"] in ["manage/tokenview_flexi", "manage/userview_flexi"]:
            c.audit["administrator"] = getUserFromRequest(request).get("login")
            if request.params.has_key("serial"):
                c.audit["serial"] = request.params["serial"]
                c.audit["token_type"] = getTokenType(request.params["serial"])

            audit.log(c.audit)
Beispiel #6
0
    def __after__(self, action,):
        '''

        '''
        param = request.params

        try:
            if c.audit['action'] in ['selfservice/index']:
                if isSelfTest():
                    log.debug("[__after__] Doing selftest!")
                    suser = getParam(param, "selftest_user", True)
                    if suser is not None:
                        (c.user, _foo, c.realm) = getParam(param,
                                                           "selftest_user",
                                                           True)\
                                                           .rpartition('@')
                    else:
                        c.realm = ""
                        c.user = "******"
                        env = request.environ
                        uuser = env.get('REMOTE_USER')
                        if uuser is not None:
                            (c.user, _foo, c.realm) = uuser.rpartition('@')

                log.debug("[__after__] authenticating as %s in realm %s!"
                          % (c.user, c.realm))

                c.audit['user'] = c.user
                c.audit['realm'] = c.realm
                c.audit['success'] = True

                if 'serial' in param:
                    c.audit['serial'] = param['serial']
                    c.audit['token_type'] = getTokenType(param['serial'])

                audit.log(c.audit)

            return response

        except webob.exc.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.error("[__after__::%r] webob.exception %r" % (action, acc))
            log.error("[__after__] %s" % traceback.format_exc())
            Session.rollback()
            Session.close()
            raise acc

        except Exception as e:
            log.error("[__after__] failed with error: %r" % e)
            log.error("[__after__] %s" % traceback.format_exc())
            Session.rollback()
            Session.close()
            return sendError(response, e, context='after')

        finally:
            log.debug('[__after__] done')
Beispiel #7
0
    def __after__(self):

        if c.audit['action'] in [ 'manage/tokenview_flexi',
                                'manage/userview_flexi' ]:
            c.audit['administrator'] = getUserFromRequest(request).get("login")
            if request.params.has_key('serial'):
                    c.audit['serial'] = request.params['serial']
                    c.audit['token_type'] = getTokenType(request.params['serial'])

            audit.log(c.audit)
Beispiel #8
0
    def __after__(self):

        if c.audit['action'] in [ 'manage/tokenview_flexi',
                                'manage/userview_flexi' ]:
            c.audit['administrator'] = getUserFromRequest(request).get("login")
            if request.params.has_key('serial'):
                    c.audit['serial'] = request.params['serial']
                    c.audit['token_type'] = getTokenType(request.params['serial'])

            audit.log(c.audit)
Beispiel #9
0
    def __after__(self):
        if c.audit['action'] in ['manage/tokenview_flexi',
                                 'manage/userview_flexi' ]:
            c.audit['administrator'] = getUserFromRequest(request).get("login")
            if 'serial' in self.request_params:
                serial = self.request_params['serial']
                c.audit['serial'] = serial
                c.audit['token_type'] = getTokenType(serial)

            c.audit['action_detail'] += linotp.lib.audit.base.get_token_num_info()
            audit.log(c.audit)
Beispiel #10
0
    def __after__(self):
        if c.audit['action'] in ['manage/tokenview_flexi',
                                 'manage/userview_flexi' ]:
            c.audit['administrator'] = getUserFromRequest(request).get("login")
            if 'serial' in self.request_params:
                serial = self.request_params['serial']
                c.audit['serial'] = serial
                c.audit['token_type'] = getTokenType(serial)

            c.audit['action_detail'] += linotp.lib.audit.base.get_token_num_info()
            audit.log(c.audit)
Beispiel #11
0
    def __after__(response):
        """
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        """

        if request_context.get("reponse_redirect", False):
            # FIXME: does this really do a redirect???
            return response

        param = request.params
        action = request_context["action"]

        try:
            if g.audit["action"] in ["selfservice/index"]:
                log.debug(
                    "[__after__] authenticating as %s in realm %s!",
                    c.user,
                    c.realm,
                )

                g.audit["user"] = c.user
                g.audit["realm"] = c.realm
                g.audit["success"] = True

                if "serial" in param:
                    g.audit["serial"] = param["serial"]
                    g.audit["token_type"] = getTokenType(param["serial"])

                current_app.audit_obj.log(g.audit)

            return response

        except flap.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.error("[__after__::%r] webob.exception %r", action, acc)
            db.session.rollback()
            # FIXME: replace authorization exception handling with flasks preferred
            # error handling
            raise acc

        except Exception as exx:
            log.error("[__after__] failed with error: %r", exx)
            db.session.rollback()
            return sendError(response, exx, context="after")
Beispiel #12
0
    def __after__(response):
        '''
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        '''

        g.audit['administrator'] = getUserFromRequest(request).get("login")
        if 'serial' in request.params:
            serial = request.params['serial']
            g.audit['serial'] = serial
            g.audit['token_type'] = getTokenType(serial)

        current_app.audit_obj.log(g.audit)

        return response
Beispiel #13
0
    def __after__(response):
        """
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        """

        g.audit["administrator"] = getUserFromRequest()
        if "serial" in request.params:
            serial = request.params["serial"]
            g.audit["serial"] = serial
            g.audit["token_type"] = getTokenType(serial)

        current_app.audit_obj.log(g.audit)

        return response
Beispiel #14
0
    def __after__(response):
        '''
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        '''

        c.audit['administrator'] = getUserFromRequest(request).get("login")
        if 'serial' in request.params:
            serial = request.params['serial']
            c.audit['serial'] = serial
            c.audit['token_type'] = getTokenType(serial)

        audit = config.get('audit')
        audit.log(c.audit)

        return response
Beispiel #15
0
    def __after__(response):
        '''
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        '''

        if request_context.get('reponse_redirect', False):
            # FIXME: does this really do a redirect???
            return response

        param = request.params
        action = request_context['action']

        try:
            if g.audit['action'] in ['selfservice/index']:
                log.debug("[__after__] authenticating as %s in realm %s!"
                          % (c.user, c.realm))

                g.audit['user'] = c.user
                g.audit['realm'] = c.realm
                g.audit['success'] = True

                if 'serial' in param:
                    g.audit['serial'] = param['serial']
                    g.audit['token_type'] = getTokenType(param['serial'])

                current_app.audit_obj.log(g.audit)

            return response

        except flap.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.exception("[__after__::%r] webob.exception %r" % (action, acc))
            db.session.rollback()
            # FIXME: replace authorization exception handling with flasks preferred
            # error handling
            raise acc

        except Exception as e:
            log.exception("[__after__] failed with error: %r" % e)
            db.session.rollback()
            return sendError(response, e, context='after')
Beispiel #16
0
    def __after__(response):
        '''
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        '''

        if c.audit['action'] in ['manage/tokenview_flexi',
                                 'manage/userview_flexi' ]:
            c.audit['administrator'] = getUserFromRequest(request).get("login")
            if 'serial' in request.params:
                serial = request.params['serial']
                c.audit['serial'] = serial
                c.audit['token_type'] = getTokenType(serial)

            c.audit['action_detail'] += linotp.lib.audit.base.get_token_num_info()
            audit = config.get('audit')
            audit.log(c.audit)

        return response
Beispiel #17
0
    def __after__(response):
        """
        __after__ is called after every action

        :param response: the previously created response - for modification
        :return: return the response
        """

        if g.audit["action"] in [
            "manage/tokenview_flexi",
            "manage/userview_flexi",
        ]:
            g.audit["administrator"] = getUserFromRequest()
            if "serial" in request.params:
                serial = request.params["serial"]
                g.audit["serial"] = serial
                g.audit["token_type"] = getTokenType(serial)

            g.audit[
                "action_detail"
            ] += linotp.lib.audit.base.get_token_num_info()
            current_app.audit_obj.log(g.audit)

        return response
Beispiel #18
0
 def __after__(self):
     c.audit['administrator'] = getUserFromRequest(request).get("login")
     if request.params.has_key('serial'):
         c.audit['serial'] = request.params['serial']
         c.audit['token_type'] = getTokenType(request.params['serial'])
     audit.log(c.audit)
Beispiel #19
0
    def __after__(self, action,):
        '''

        '''
        param = request.params

        try:
            if c.audit['action'] in ['selfservice/index']:
                if isSelfTest():
                    log.debug("[__after__] Doing selftest!")
                    suser = getParam(param, "selftest_user", True)
                    if suser is not None:
                        (c.user, _foo, c.realm) = getParam(param,
                                                           "selftest_user",
                                                           True)\
                                                           .rpartition('@')
                    else:
                        c.realm = ""
                        c.user = "******"
                        env = request.environ
                        uuser = env.get('REMOTE_USER')
                        realms = getAllUserRealms(User(uuser, "", ""))
                        if (realms):
                            c.user = uuser
                            c.realm = realms[0]
    ### This makes no sense...
    #                c.audit['user'] = c.user
    #                c.audit['realm'] =  c.realm
    #            else:
    #                user = getUserFromRequest(request).get("login")
    #                c.audit['user'] ,c.audit['realm'] = user.split('@')
    #                uc = user.split('@')
    #                c.audit['realm'] = uc[-1]
    #                c.audit['user'] = '******'.join(uc[:-1])

                log.debug("[__after__] authenticating as %s in realm %s!" % (c.user, c.realm))

                c.audit['user'] = c.user
                c.audit['realm'] = c.realm
                c.audit['success'] = True

                if 'serial' in param:
                    c.audit['serial'] = param['serial']
                    c.audit['token_type'] = getTokenType(param['serial'])

                audit.log(c.audit)

            return response

        except webob.exc.HTTPUnauthorized as acc:
            # the exception, when an abort() is called if forwarded
            log.error("[__after__::%r] webob.exception %r" % (action, acc))
            log.error("[__after__] %s" % traceback.format_exc())
            Session.rollback()
            Session.close()
            raise acc

        except Exception as e:
            log.error("[__after__] failed with error: %r" % e)
            log.error("[__after__] %s" % traceback.format_exc())
            Session.rollback()
            Session.close()
            return sendError(response, e, context='after')

        finally:
            log.debug('[__after__] done')
Beispiel #20
0
 def __after__(self):
     c.audit["administrator"] = getUserFromRequest(request).get("login")
     if request.params.has_key("serial"):
         c.audit["serial"] = request.params["serial"]
         c.audit["token_type"] = getTokenType(request.params["serial"])
     audit.log(c.audit)
Beispiel #21
0
 def __after__(self):
     c.audit['administrator'] = getUserFromRequest(request).get("login")
     if request.params.has_key('serial'):
             c.audit['serial'] = request.params['serial']
             c.audit['token_type'] = getTokenType(request.params['serial'])
     audit.log(c.audit)