Use python module to inject parameters to radius context

Anuruddha Premalal anuruddhapremalal at gmail.com
Tue May 17 02:28:43 CEST 2016


Hi Devs,

I'm trying to urlencode a string and put that value in a vendor specific
attribute via python; and later refer that in  site configuration.

Here's a snippet of the site configuration authenticate section

authenticate {
Auth-Type PAP {
    python_custom
             update reply {
                    User-Name = "%{User-Name}"
                    My-Redirection-URL = "%{*My-URL-Param*}"
                    My-ACL-Policy = "default_unauth_sla"
                    My-QoS-Policy = "32M_Full"
                    Calling-Station-Id = "%{Calling-Station-Id}"
             }

            }
}
digest
eap
}


Here's the python code snippet in python_custom module

def authenticate(p):
    username = ''
    clientmac = ''
    apmac =''
    ssid = 'Benu_Test'

    for authdata in p:
        if authdata[0] == 'User-Name':
            username = authdata[1]
        if authdata[0] == 'Calling-Station-Id':
            clientmac = authdata[1]
        if authdata[0] == 'Called-Station-Id':
            apmac = authdata[1]
    # how can I inject this VSA to radius context so that it can
referenced in the site configuration?
    My-URL-Param = "http://my.org" + urllib.quote('?clientmac=' +
clientmac + '&apmac=' + apmac + '&ssid=' + ssid )

    return radiusd.RLM_MODULE_OK


Appreciate your help in finding a solution for this.

Thanks & Regards,
-- 
*Anuruddha Premalala (MIEEE)Mobile : +94717213122 <%2B94717213122>E-mail  :
anuruddhapremalal at gmail.com <anuruddhapremalal at gmail.com>web      :
www.anuruddha.org <http://www.anuruddha.org>Sri Lanka.*


More information about the Freeradius-Devel mailing list