Beispiel #1
0
def doPreauth():

    result = None
    POSTVarsNames = [ ]

    hotspotType = getHotspotType(request)

    #FIX. Must be changed
    if hotspotType == 'mikrotik':
        POSTVarsNames = MT_PREAUTH_VARS
    elif hotspotType == 'ubiquity':    
        POSTVarsNames = UNI_PREAUTH_VARS         
    elif hotspotType == 'aruba':    
        POSTVarsNames = ARUBA_PREAUTH_VARS  
    elif hotspotType == 'ruckus':    
        POSTVarsNames = RUCKUS_PREAUTH_VARS 
    elif hotspotType == 'openwrt':    
        POSTVarsNames = OPENWRT_PREAUTH_VARS 
    elif hotspotType == 'outage': #test case
        hotspotType = None
        POSTVarsNames = MT_PREAUTH_VARS

    session['hotspotType'] = hotspotType    
    session['POSTVarsNames'] = POSTVarsNames    

    varsOk = preauthGoodVars(request) 
    session['model'] = getPreauthModel(request)        #getPreauthModel

    if hotspotType is not None:        
        waitTime = idleCheck(request)
        
        if waitTime != False and waitTime:
            extradata = {'wait_time': waitTime}
            logIt( app.logger.debug, DEB_PREFIX, 'render idle template' )
            return render_template('preauth_idle.html', extradata = extradata)

        if doSaveSessionData(request) != True:
            logIt( app.logger.debug, DEB_PREFIX, 'Can\'t save session. Render error template' )    
            return render_template('error.html') 

        extradata = session['model']
        logIt( app.logger.debug, DEB_PREFIX, 'OK. Render preauth template' )
        return render_template('preauth.html', extradata = extradata, url = app.config.get('SHOPSTER_URL'), hotspottype = hotspotType )

    elif varsOk:                                #didnt get hotspot type and vars are ok then shopster system is down
        logIt( app.logger.debug, DEB_PREFIX, 'Auth service is down. Render outage template' )
        result = render_template('shopster_outage.html')
        return result

    logIt( app.logger.debug, DEB_PREFIX, 'Default exit. Render error template' )    
    return render_template('error.html')
Beispiel #2
0
def doPostPostauth():

    logIt( app.logger.debug, DEB_PREFIX, 'request args', request.values.to_dict(flat = False) )

    hotspotType = session.get('hotspotType')

    logIt( app.logger.debug, DEB_PREFIX, 'hotspot type is', hotspotType )    

    waitTime = idleCheck(request)
    
    if waitTime != False and waitTime:
        extradata = {'wait_time': waitTime}
        return render_template('postpostauth_idle.html', extradata = extradata)            

    model = session.get('model', None)
    
    #if model != None
    formData = getFormData(request)

    if None not in ( formData, model ) and idleCheck(request) == 0:
        if hotspotType == 'mikrotik':
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render mikrotik template' )            
            return render_template('postpostauth_mikrotik.html', formdata = formData)

        if hotspotType == 'aruba':
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render aruba template' )
            return render_template('postpostauth_aruba.html', formdata = formData)

        if hotspotType == 'openwrt':
            openwrtSecret = app.config.get('OPENWRT_SECRET_KEY')
            challAsBinString = unhexlify( model.get('challenge') )
            #md5 digest of a concatenated challenge sent by chilli and chilli uamsecret setting.              
            challWithSecret =  md5( '{}{}'.format( challAsBinString, openwrtSecret ) ).digest()
            passLen = len( formData.get('password') )
            #16 bytes aligned password
            alignedPass = '******'.format( formData.get('password'), '\x00' * ( HASH_LEN - passLen ) )            
            xoredPass = xorString( alignedPass, challWithSecret )
            url = 'http://{}:{}/logon?username={}&password={}&userurl={}'.format( 
                formData.get('hotspot_login_url'), model.get('uamport'),
                formData.get('username'), hexlify( xoredPass ),
                formData.get('origin_url')
            )
            logIt( app.logger.debug, DEB_PREFIX, 'challWithSecret is {}'.format( hexlify( challWithSecret ) ) )
            logIt( app.logger.debug, DEB_PREFIX, 'aligned pass is {}'.format( hexlify( alignedPass ) ) )
            logIt( app.logger.debug, DEB_PREFIX, 'xored pass is {}'.format( hexlify( xoredPass ) ) )
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render openwrt template' )
            return render_template('postpostauth_openwrt.html', url = url ) 

        if hotspotType == 'ubiquity':
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render ubiquity template' )
            return render_template('postpostauth_ubiquity.html', url = formData.get('origin_url') )           

        if hotspotType == 'cisco':
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render cisco template' )
            return render_template('postpostauth_cisco.html', formdata = formData )

        if hotspotType == 'ruckus' and not session.get('zone_director_passed'):
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render ruckus intermediate template' )
            return render_template('postpostauth_ruckus.html',\
               url = 'http://{0}:9997/login?username={1}&password={2}'.format( formData.get('hotspot_login_url'), 
                formData.get('username'), formData.get('password') )
            )
               
        elif hotspotType == 'ruckus':
            session['zone_director_passed'] = False                   
            r = make_response( 
                    render_template( 'postpostauth_ruckus.html', url = formData.get('origin_url') ) 
            )
            logIt( app.logger.debug, DEB_PREFIX, 'OK. Render ruckus intermediate template' )
            return r                
    logIt( app.logger.debug, DEB_PREFIX, 'Default exit. Render error template' )    
 
    return render_template('error.html')