Ejemplo n.º 1
0
int main_auth(WS_CONNINFO *pwsc, char *username, char *password) {
    DPRINTF(E_DBG,L_MAIN,"in main_auth\n");
    if(plugin_url_candispatch(pwsc)) {
        DPRINTF(E_DBG,L_MAIN,"Dispatching auth for %s to plugin\n",ws_uri(pwsc));
        return plugin_auth_handle(pwsc,username,password);
    }

    DPRINTF(E_DBG,L_MAIN,"Dispatching auth for %s to config auth\n",ws_uri(pwsc));
    return config_auth(pwsc, username, password);
}
Ejemplo n.º 2
0
void main_handler(WS_CONNINFO *pwsc) {
    DPRINTF(E_DBG,L_MAIN,"in main_handler\n");
    if(plugin_url_candispatch(pwsc)) {
        DPRINTF(E_DBG,L_MAIN,"Dispatching %s to plugin\n",ws_uri(pwsc));
        plugin_url_handle(pwsc);
        return;
    }

    DPRINTF(E_DBG,L_MAIN,"Dispatching %s to config handler\n",ws_uri(pwsc));
    config_handler(pwsc);
}
Ejemplo n.º 3
0
/**
 * Test password for the handled namespace
 *
 * @param pwsc the connection info (including uri) to check
 * @param username user attempting to login
 * @param pw password attempting
 * @returns TRUE if we want to handle it
 */
int plugin_auth_handle(WS_CONNINFO *pwsc, char *username, char *pw) {
    PLUGIN_ENTRY *ppi;
    int (*auth_fn)(WS_CONNINFO *pwsc, char *username, char *pw);
    int result;

    ppi = _plugin_list.next;
    while(ppi) {
        if(ppi->pinfo->type & PLUGIN_OUTPUT) {
            if((ppi->pinfo->output_fns)->can_handle(pwsc)) {
                /* we have a winner */
                DPRINTF(E_DBG,L_PLUG,"Dispatching %s to %s\n", ws_uri(pwsc),
                        ppi->pinfo->server);

                /* so functions must be a tag_plugin_output_fn */
                auth_fn=(ppi->pinfo->output_fns)->auth;
                if(auth_fn) {
                    result=auth_fn(pwsc,username,pw);
                    return result;
                } else {
                    return TRUE;
                }
            }
        }
        ppi = ppi->next;
    }

    /* should 500 here or something */
    ws_returnerror(pwsc, 500, "Can't find plugin handler");
    return FALSE;
}
Ejemplo n.º 4
0
/**
 * actually DISPATCH the hander we said we wanted
 *
 * @param pwsc the connection info (including uri) to check
 * @returns TRUE if we want to handle it
 */
void plugin_url_handle(WS_CONNINFO *pwsc) {
    PLUGIN_ENTRY *ppi;
    void (*disp_fn)(WS_CONNINFO *pwsc);

    ppi = _plugin_list.next;
    while(ppi) {
        if(ppi->pinfo->type & PLUGIN_OUTPUT) {
            if((ppi->pinfo->output_fns)->can_handle(pwsc)) {
                /* we have a winner */
                DPRINTF(E_DBG,L_PLUG,"Dispatching %s to %s\n", ws_uri(pwsc),
                        ppi->pinfo->server);

                /* so functions must be a tag_plugin_output_fn */
                disp_fn=(ppi->pinfo->output_fns)->handler;
                disp_fn(pwsc);
                return;
            }
        }
        ppi = ppi->next;
    }

    /* should 500 here or something */
    ws_returnerror(pwsc, 500, "Can't find plugin handler");
    return;
}