def sign_request(ikey, skey, akey, username):
    """Generate a signed request for Duo authentication.
    The returned value should be passed into the Duo.init() call 
    in the rendered web page used for Duo authentication.
    
    Arguments:
    
    ikey      -- Duo integration key
    skey      -- Duo secret key
    akey      -- Application secret key
    username  -- Primary-authenticated username
    """
    if not username:
        return ERR_USER
    if not ikey or len(ikey) != IKEY_LEN:
        return ERR_IKEY
    if not skey or len(skey) != SKEY_LEN:
        return ERR_SKEY
    if not akey or len(akey) < AKEY_LEN:
        return ERR_AKEY

    vals = [ username, ikey ]

    try:
        duo_sig = _sign_vals(skey, vals, DUO_PREFIX, DUO_EXPIRE)
        app_sig = _sign_vals(akey, vals, APP_PREFIX, APP_EXPIRE)
    except:
        return ERR_UNKNOWN

    return '%s:%s' % (duo_sig, app_sig)
dataset/ETHPy150Open GluuFederation/community-edition-setup/static/auth/lib/duo_web.py/sign_request/original