Esempio n. 1
0
def psmStatus():
    # Check whether PSM is online and reachable
    formresult=request.form
    psmvars=classes.obtainVars('syspsm')
    if isinstance(psmvars, str):
        psmvars=json.loads(psmvars)
    psmInfo=formresult.to_dict(flat=True)
    result=classes.checkPSM(psmvars, psmInfo['psmipaddress'], psmInfo['psmuser'], psmInfo['psmpassword'], psmInfo['psmtoken'])
    return result
Esempio n. 2
0
def afcStatus():
    # Check whether AFC is online and reachable
    formresult=request.form
    afcvars=classes.obtainVars('sysafc')
    if isinstance(afcvars, str):
        afcvars=json.loads(afcvars)
    afcInfo=formresult.to_dict(flat=True)
    result=classes.checkAFC(afcvars, afcInfo['afcipaddress'], afcInfo['afcuser'], afcInfo['afcpassword'], afcInfo['afctoken'])
    return result
def checkauthorization ():
    arubacentralvars=classes.obtainVars('sysarubacentral')
    if isinstance(arubacentralvars, str):
        arubacentralvars=json.loads(arubacentralvars)
    # Only verify if centralcustomerid, centralclienttoken and centralrefreshtoken variables exist
    # If arubacentraltokeninfo exists in the variables, we only have to check whether the token is still valid
    if "arubacentraltokeninfo" in arubacentralvars:
        response=classes.checkcentralToken("authorization")
    else:
        if "arubacentralclientid" in arubacentralvars and "arubacentralcustomerid" in arubacentralvars and "arubacentralcsrftoken" in arubacentralvars  and "arubacentralsession" in arubacentralvars:
            if arubacentralvars['arubacentralcustomerid'] and arubacentralvars['arubacentralclientid'] and arubacentralvars['arubacentralcsrftoken']  and arubacentralvars['arubacentralsession']:
                response=classes.centralAuthorization(arubacentralvars)
            else:
                response={"message":"Authorization unsuccessful"}
        else:
            response={"message":"Authorization pending"}
    return json.dumps(response)
Esempio n. 4
0
def syspsm():
    authOK=classes.checkAuth("sysadminaccess","submenu")
    if authOK!=0:
        sysvars=classes.globalvars()
        formresult=request.form
        try:
            if formresult['action']=="Submit changes":
                classes.submitIntegration(formresult)             
        except:
            pass
        if authOK['hasaccess']==True:
            authOK['hasaccess']="true"
            psmvars=classes.obtainVars('syspsm')
            if isinstance(psmvars, str):
                psmvars=json.loads(psmvars)
            sysvars=classes.globalvars()
            return render_template("syspsm.html",authOK=authOK, psmvars=psmvars, sysvars=sysvars)
        else:
            return render_template("noaccess.html",authOK=authOK)
    else:
        return render_template("login.html")
def checkauthentication ():
    sysvars=classes.globalvars()
    arubacentralvars=classes.obtainVars('sysarubacentral')
    if isinstance(arubacentralvars, str):
        arubacentralvars=json.loads(arubacentralvars)
    formresult=request.form
    # Only verify if centralcustomerid, centralclientid, centralclientsecret and centralurl variables exist
    # If arubacentraltokeninfo exists in the variables, we only have to check whether the token is still valid
    if "arubacentraltokeninfo" in arubacentralvars:
        response=classes.checkcentralToken("authentication")
    else:
        arubacentralvars.update({'arubacentralurl':formresult['arubacentralurl']})
        arubacentralvars.update({'arubacentralusername':formresult['arubacentralusername']})
        arubacentralvars.update({'arubacentraluserpassword':formresult['arubacentraluserpassword']})
        arubacentralvars.update({'arubacentralclientid':formresult['arubacentralclientid']})
        arubacentralvars.update({'arubacentralcustomerid':formresult['arubacentralcustomerid']})
        arubacentralvars.update({'arubacentralclientsecret':formresult['arubacentralclientsecret']})
        if formresult['arubacentralurl']!="" and formresult['arubacentralusername']!="" and formresult['arubacentraluserpassword']!="" and formresult['arubacentralclientid']!="" and formresult['arubacentralcustomerid']!="" and formresult['arubacentralclientsecret']!="":
            print("All parameters are there, perform centralAuthentication")
            response=classes.centralAuthentication(arubacentralvars)
        else:
            response={"message":"Authentication pending."}
    return json.dumps(response)