コード例 #1
0
ファイル: app_server.py プロジェクト: hellios78/TACTIC
    def handle_security(my, security):
        # set the seucrity object
        WebContainer.set_security(security)

        # see if there is an override
        web = WebContainer.get_web()
        ticket_key = web.get_form_value("login_ticket")
        # attempt to login in with a ticket
        if not ticket_key:
            ticket_key = web.get_cookie("login_ticket")


        # We can define another place to look at ticket values and use
        # that. ie: Drupal session key
        session_key = Config.get_value("security", "session_key")

        login = web.get_form_value("login")
        password = web.get_form_value("password")

        if session_key:
            ticket_key = web.get_cookie(session_key)
            if ticket_key:
                security.login_with_session(ticket_key, add_access_rules=False)
        elif login and password:
            if login == "guest":
                pass
            else:
                from pyasm.widget import WebLoginCmd
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()
                # clear the password
                web.set_form_value('password','')
        elif ticket_key:
            security.login_with_ticket(ticket_key, add_access_rules=False)


        if not security.is_logged_in():
            reset_password = web.get_form_value("reset_password") == 'true'
            if reset_password:
                from tactic.ui.widget import ResetPasswordCmd
                reset_cmd = ResetPasswordCmd(reset=True)
                try:
                    reset_cmd.execute()
                except TacticException, e:
                    print "Reset failed. %s" %e.__str__()
            else:
                from pyasm.widget import WebLoginCmd
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()
コード例 #2
0
    def handle_security(my, security, allow_guest=False):
        # set the seucrity object

        WebContainer.set_security(security)

        # see if there is an override
        web = WebContainer.get_web()
        ticket_key = web.get_form_value("login_ticket")
        # attempt to login in with a ticket
        if not ticket_key:
            ticket_key = web.get_cookie("login_ticket")

        # We can define another place to look at ticket values and use
        # that. ie: Drupal session key
        session_key = Config.get_value("security", "session_key")

        login = web.get_form_value("login")
        password = web.get_form_value("password")

        site_obj = Site.get()
        path_info = site_obj.get_request_path_info()
        if path_info:
            site = path_info['site']
            if site == "default":
                site = web.get_form_value("site")
            if not site:
                site = "default"

        else:
            site = web.get_form_value("site")

        if session_key:
            ticket_key = web.get_cookie(session_key)
            if ticket_key:
                security.login_with_session(ticket_key, add_access_rules=False)
        elif login and password:

            # get the site for this user
            login_site = site_obj.get_by_login(login)
            if login_site:
                site = login_site

            if site:
                site_obj.set_site(site)

            if login == "guest":
                pass
            else:
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()

        elif ticket_key:

            if site:
                site_obj.set_site(site)

            login = security.login_with_ticket(ticket_key,
                                               add_access_rules=False,
                                               allow_guest=allow_guest)

        if not security.is_logged_in():
            reset_password = web.get_form_value("reset_password") == 'true'
            if reset_password:
                from tactic.ui.widget import ResetPasswordCmd
                reset_cmd = ResetPasswordCmd(reset=True)
                try:
                    reset_cmd.execute()
                except TacticException, e:
                    print "Reset failed. %s" % e.__str__()

            # FIXME: not sure why this is here???
            """
コード例 #3
0
    def handle_security(self, security, allow_guest=False):
        # set the seucrity object

        WebContainer.set_security(security)

        # see if there is an override
        web = WebContainer.get_web()
        is_from_login = web.get_form_value("is_from_login")

        ticket_key = web.get_form_value("login_ticket")
        # attempt to login in with a ticket
        if not ticket_key and is_from_login != 'yes':
            ticket_key = web.get_cookie("login_ticket")

        # We can define another place to look at ticket values and use
        # that. ie: Drupal session key
        session_key = Config.get_value("security", "session_key")

        login = web.get_form_value("login")
        password = web.get_form_value("password")

        site_obj = Site.get()
        path_info = site_obj.get_request_path_info()
        if path_info:
            site = path_info['site']
            if site == "default":
                site = web.get_form_value("site")
            if not site:
                site = "default"

        else:
            site = web.get_form_value("site")

        if session_key:
            ticket_key = web.get_cookie(session_key)
            if ticket_key:
                security.login_with_session(ticket_key, add_access_rules=False)
        elif login and password:

            # get the site for this user
            login_site = site_obj.get_by_login(login)
            if login_site:
                site = login_site

            if site:
                site_obj.set_site(site)

            if login == "guest":
                pass
            else:
                login_cmd = WebLoginCmd()
                login_cmd.execute()

                ticket_key = security.get_ticket_key()

                if not ticket_key:
                    if site:
                        site_obj.pop_site()
                    return security

        elif ticket_key:

            if site:
                site_obj.set_site(site)

            login = security.login_with_ticket(ticket_key,
                                               add_access_rules=False,
                                               allow_guest=allow_guest)

            # In the midst of logging out, login is None
            if not login:
                if site:
                    site_obj.pop_site()
                return security

        if not security.is_logged_in():
            reset_password = web.get_form_value("reset_password") == 'true'
            if reset_password:
                from tactic.ui.widget import ResetPasswordCmd
                reset_cmd = ResetPasswordCmd(reset=True)
                try:
                    reset_cmd.execute()
                except TacticException as e:
                    print("Reset failed. %s" % e.__str__())

            # let empty username or password thru to get feedback from WebLoginCmd
            else:
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()

        # clear the password
        web.set_form_value('password', '')

        if session_key:
            web.set_cookie("login_ticket", ticket_key)
        elif ticket_key:
            web.set_cookie("login_ticket", ticket_key)

        # TEST TEST TEST
        """
        try:
            ticket = security.get_ticket()
            if ticket:
                site_obj.handle_ticket(ticket)
        except Exception as e:
            print("ERROR in handle_ticket: ", e)
        """

        # set up default securities
        #self.set_default_security(security)

        # for now apply the access rules after
        security.add_access_rules()

        return security
コード例 #4
0
ファイル: app_server.py プロジェクト: jayvdb/TACTIC
    def handle_security(my, security, allow_guest=False):
        # set the seucrity object

        WebContainer.set_security(security)

        # see if there is an override
        web = WebContainer.get_web()
        ticket_key = web.get_form_value("login_ticket")
        # attempt to login in with a ticket
        if not ticket_key:
            ticket_key = web.get_cookie("login_ticket")


        # We can define another place to look at ticket values and use
        # that. ie: Drupal session key
        session_key = Config.get_value("security", "session_key")

        login = web.get_form_value("login")
        password = web.get_form_value("password")


        site_obj = Site.get()
        path_info = site_obj.get_request_path_info()
        if path_info:
            site = path_info['site']
            if site == "default":
                site = web.get_form_value("site")
            if not site:
                site = "default"

        else:
            site = web.get_form_value("site")


        if session_key:
            ticket_key = web.get_cookie(session_key)
            if ticket_key:
                security.login_with_session(ticket_key, add_access_rules=False)
        elif login and password:

            # get the site for this user
            login_site = site_obj.get_by_login(login)
            if login_site:
                site = login_site

            if site:
                site_obj.set_site(site)

            if login == "guest":
                pass
            else:
                from web_login_cmd import WebLoginCmd
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()

        elif ticket_key:

            if site:
                site_obj.set_site(site)

            login = security.login_with_ticket(ticket_key, add_access_rules=False, allow_guest=allow_guest)


        if not security.is_logged_in():
            reset_password = web.get_form_value("reset_password") == 'true'
            if reset_password:
                from tactic.ui.widget import ResetPasswordCmd
                reset_cmd = ResetPasswordCmd(reset=True)
                try:
                    reset_cmd.execute()
                except TacticException, e:
                    print "Reset failed. %s" %e.__str__()
            else:
                from web_login_cmd import WebLoginCmd
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()
コード例 #5
0
ファイル: app_server.py プロジェクト: mincau/TACTIC
    def handle_security(self, security, allow_guest=False):
        # set the seucrity object

        WebContainer.set_security(security)

        # see if there is an override
        web = WebContainer.get_web()
        is_from_login = web.get_form_value("is_from_login")
        
        ticket_key = web.get_form_value("login_ticket")
        # attempt to login in with a ticket
        if not ticket_key and is_from_login !='yes':
            ticket_key = web.get_cookie("login_ticket")


        # We can define another place to look at ticket values and use
        # that. ie: Drupal session key
        session_key = Config.get_value("security", "session_key")

        login = web.get_form_value("login")
        password = web.get_form_value("password")


        site_obj = Site.get()
        path_info = site_obj.get_request_path_info()
        if path_info:
            site = path_info['site']
            if site == "default":
                site = web.get_form_value("site")
            if not site:
                site = "default"

        else:
            site = web.get_form_value("site")


        if session_key:
            ticket_key = web.get_cookie(session_key)
            if ticket_key:
                security.login_with_session(ticket_key, add_access_rules=False)
        elif login and password:

            # get the site for this user
            login_site = site_obj.get_by_login(login)
            if login_site:
                site = login_site

            if site:
                site_obj.set_site(site)

            if login == "guest":
                pass
            else:
                login_cmd = WebLoginCmd()
                login_cmd.execute()

                ticket_key = security.get_ticket_key()
              
                if not ticket_key:
                    if site:
                        site_obj.pop_site()
                    return security


        elif ticket_key:
          
            if site:
                site_obj.set_site(site)

            login = security.login_with_ticket(ticket_key, add_access_rules=False, allow_guest=allow_guest)
           
            # In the midst of logging out, login is None
            if not login:
                if site:
                    site_obj.pop_site()
                return security


        if not security.is_logged_in():
            reset_password = web.get_form_value("reset_password") == 'true'
            if reset_password:
                from tactic.ui.widget import ResetPasswordCmd
                reset_cmd = ResetPasswordCmd(reset=True)
                try:
                    reset_cmd.execute()
                except TacticException as e:
                    print("Reset failed. %s" %e.__str__())

            # let empty username or password thru to get feedback from WebLoginCmd
            else:
                login_cmd = WebLoginCmd()
                login_cmd.execute()
                ticket_key = security.get_ticket_key()

        # clear the password
        web.set_form_value('password','')

        if session_key:
            web.set_cookie("login_ticket", ticket_key)
        elif ticket_key:
            web.set_cookie("login_ticket", ticket_key)



        # TEST TEST TEST
        """
        try:
            ticket = security.get_ticket()
            if ticket:
                site_obj.handle_ticket(ticket)
        except Exception as e:
            print("ERROR in handle_ticket: ", e)
        """



        # set up default securities
        #self.set_default_security(security)

        # for now apply the access rules after
        security.add_access_rules()
        
        return security