mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
Make auth handers receive connection info
This commit is contained in:
parent
2fd2f15d23
commit
eed9619063
@ -352,12 +352,12 @@ void config_handler(WS_CONNINFO *pwsc) {
|
||||
* \param user username passed in the auth request
|
||||
* \param password password passed in the auth request
|
||||
*/
|
||||
int config_auth(char *hostname, char *user, char *password) {
|
||||
int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
|
||||
char *adminpassword;
|
||||
int res;
|
||||
|
||||
#ifdef WIN32
|
||||
if((hostname) && (os_islocaladdr(hostname)))
|
||||
if((pwsc->hostname) && (os_islocaladdr(pwsc->hostname)))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "daapd.h"
|
||||
#include "webserver.h"
|
||||
|
||||
extern int config_auth(char *hostname, char *user, char *password);
|
||||
extern int config_auth(WS_CONNINFO *pwsc, char *user, char *password);
|
||||
extern void config_handler(WS_CONNINFO *pwsc);
|
||||
extern void config_set_status(WS_CONNINFO *pwsc, int session, char *fmt, ...);
|
||||
extern int config_get_session_count(void);
|
||||
|
@ -127,7 +127,7 @@ void dispatch_cleanup(DBQUERYINFO *pqi) {
|
||||
* @param password The password passed by iTunes
|
||||
* @returns 1 if auth successful, 0 otherwise
|
||||
*/
|
||||
int daap_auth(char *hostname, char *username, char *password) {
|
||||
int daap_auth(WS_CONNINFO *pwsc, char *username, char *password) {
|
||||
char *readpassword;
|
||||
|
||||
readpassword = conf_alloc_string("general","password",NULL);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "db-generic.h"
|
||||
|
||||
extern void daap_handler(WS_CONNINFO *pwsc);
|
||||
extern int daap_auth(char *hostname, char *username, char *password);
|
||||
extern int daap_auth(WS_CONNINFO *pwsc, char *username, char *password);
|
||||
extern void dispatch_stream_id(WS_CONNINFO *pwsc, DBQUERYINFO *pqi, char *id);
|
||||
|
||||
#endif
|
||||
|
@ -316,6 +316,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
/* load plugins before we drop privs? Maybe... let the
|
||||
* plugins do stuff they might need to */
|
||||
plugin_init();
|
||||
if((plugindir=conf_alloc_string("plugins","plugin_dir",NULL)) != NULL) {
|
||||
if(conf_get_array("plugins","plugins",&pluginarray)==TRUE) {
|
||||
index = 0;
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
#include "webserver.h"
|
||||
|
||||
extern int plugin_init(void);
|
||||
extern int plugin_load(char **pe, char *path);
|
||||
extern int plugin_deinit(void);
|
||||
|
||||
/* Interfaces for web */
|
||||
extern int plugin_url_candispatch(WS_CONNINFO *pwsc);
|
||||
|
@ -64,7 +64,7 @@
|
||||
typedef struct tag_ws_handler {
|
||||
regex_t regex;
|
||||
void (*req_handler)(WS_CONNINFO*);
|
||||
int(*auth_handler)(char *, char *, char *);
|
||||
int(*auth_handler)(WS_CONNINFO*, char *, char *);
|
||||
int addheaders;
|
||||
struct tag_ws_handler *next;
|
||||
} WS_HANDLER;
|
||||
@ -107,11 +107,11 @@ char *ws_getarg(ARGLIST *root, char *key);
|
||||
int ws_testarg(ARGLIST *root, char *key, char *value);
|
||||
int ws_findhandler(WS_PRIVATE *pwsp, WS_CONNINFO *pwsc,
|
||||
void(**preq)(WS_CONNINFO*),
|
||||
int(**pauth)(char *, char *, char *),
|
||||
int(**pauth)(WS_CONNINFO*, char *, char *),
|
||||
int *addheaders);
|
||||
int ws_registerhandler(WSHANDLE ws, char *regex,
|
||||
void(*handler)(WS_CONNINFO*),
|
||||
int(*auth)(char *, char *, char *),
|
||||
int(*auth)(WS_CONNINFO*, char *, char *),
|
||||
int addheaders);
|
||||
int ws_decodepassword(char *header, char **username, char **password);
|
||||
int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value);
|
||||
@ -766,7 +766,7 @@ void *ws_dispatcher(void *arg) {
|
||||
time_t now;
|
||||
struct tm now_tm;
|
||||
void (*req_handler)(WS_CONNINFO*);
|
||||
int(*auth_handler)(char *, char *, char *);
|
||||
int(*auth_handler)(WS_CONNINFO*, char *, char *);
|
||||
|
||||
DPRINTF(E_DBG,L_WS,"Thread %d: Entering ws_dispatcher (Connection from %s)\n",
|
||||
pwsc->threadno, pwsc->hostname);
|
||||
@ -933,12 +933,12 @@ void *ws_dispatcher(void *arg) {
|
||||
* username and password of NULL, then don't bother
|
||||
* authing.
|
||||
*/
|
||||
if((auth_handler) && (auth_handler(pwsc->hostname,NULL,NULL)==0)) {
|
||||
if((auth_handler) && (auth_handler(pwsc,NULL,NULL)==0)) {
|
||||
/* do the auth thing */
|
||||
auth=ws_getarg(&pwsc->request_headers,"Authorization");
|
||||
if(auth) {
|
||||
ws_decodepassword(auth,&username,&password);
|
||||
if(auth_handler(pwsc->hostname,username,password))
|
||||
if(auth_handler(pwsc,username,password))
|
||||
can_dispatch=1;
|
||||
ws_addarg(&pwsc->request_vars,"HTTP_USER",username);
|
||||
ws_addarg(&pwsc->request_vars,"HTTP_PASSWD",password);
|
||||
@ -1320,7 +1320,7 @@ char *ws_urldecode(char *string, int space_as_plus) {
|
||||
*/
|
||||
int ws_registerhandler(WSHANDLE ws, char *regex,
|
||||
void(*handler)(WS_CONNINFO*),
|
||||
int(*auth)(char *, char *, char *),
|
||||
int(*auth)(WS_CONNINFO *, char *, char *),
|
||||
int addheaders) {
|
||||
WS_HANDLER *phandler;
|
||||
WS_PRIVATE *pwsp = (WS_PRIVATE *)ws;
|
||||
@ -1357,7 +1357,7 @@ int ws_registerhandler(WSHANDLE ws, char *regex,
|
||||
*/
|
||||
int ws_findhandler(WS_PRIVATE *pwsp, WS_CONNINFO *pwsc,
|
||||
void(**preq)(WS_CONNINFO*),
|
||||
int(**pauth)(char *, char *, char *),
|
||||
int(**pauth)(WS_CONNINFO *, char *, char *),
|
||||
int *addheaders) {
|
||||
WS_HANDLER *phandler=pwsp->handlers.next;
|
||||
|
||||
|
@ -70,13 +70,13 @@ typedef struct tag_ws_conninfo {
|
||||
*/
|
||||
|
||||
#define WS_REQ_HANDLER void (*)(WS_CONNINFO *)
|
||||
#define WS_AUTH_HANDLER int (*)(char *, char *, char *)
|
||||
#define WS_AUTH_HANDLER int (*)(WS_CONNINFO*, char *, char *)
|
||||
|
||||
extern WSHANDLE ws_start(WSCONFIG *config);
|
||||
extern int ws_stop(WSHANDLE ws);
|
||||
extern int ws_registerhandler(WSHANDLE ws, char *regex,
|
||||
void(*handler)(WS_CONNINFO*),
|
||||
int(*auth)(char *, char *, char *),
|
||||
int(*auth)(WS_CONNINFO*, char *, char *),
|
||||
int addheaders);
|
||||
|
||||
extern void ws_lock_local_storage(WS_CONNINFO *pwsc);
|
||||
|
Loading…
Reference in New Issue
Block a user