Mon, 12 Oct 2015 14:36:16 +0200
added possibility to configure authentication methods via coma separated list in config.xml
dav/config.c | file | annotate | diff | comparison | revisions | |
dav/config.h | file | annotate | diff | comparison | revisions | |
dav/main.c | file | annotate | diff | comparison | revisions |
--- a/dav/config.c Thu Oct 08 14:25:53 2015 +0200 +++ b/dav/config.c Mon Oct 12 14:36:16 2015 +0200 @@ -161,6 +161,7 @@ repo->decrypt_name = false; repo->decrypt_content = true; repo->ssl_version = CURL_SSLVERSION_DEFAULT; + repo->authmethods = CURLAUTH_BASIC; return repo; } @@ -202,7 +203,7 @@ ucx_map_cstr_put(repos, repo->name, repo); } -int repo_add_config(Repository *repo, char *key, char *value) { +int repo_add_config(Repository *repo, char *key, char *value) { if(xstreq(key, "name")) { repo->name = strdup(value); } else if(xstreq(key, "url")) { @@ -253,6 +254,30 @@ else { fprintf(stderr, "Unknown ssl version: %s\n", value); } + } else if(xstreq(key, "authmethods")) { + repo->authmethods = CURLAUTH_NONE; + const char *delims = " ,\r\n"; + char *meths = strdup(value); + char *meth = strtok(meths, delims); + while (meth) { + if(xstrEQ(value, "basic")) { + repo->authmethods |= CURLAUTH_BASIC; + } else if(xstrEQ(value, "digest")) { + repo->authmethods |= CURLAUTH_DIGEST; + } else if(xstrEQ(value, "negotiate")) { + repo->authmethods |= CURLAUTH_GSSNEGOTIATE; + } else if(xstrEQ(value, "ntlm")) { + repo->authmethods |= CURLAUTH_NTLM; + } else if(xstrEQ(value, "any")) { + repo->authmethods = CURLAUTH_ANY; + } else if(xstrEQ(value, "none")) { + /* skip */ + } else { + fprintf(stderr, "Unknown authentication method: %s\n", value); + } + meth = strtok(NULL, delims); + } + free(meths); } else { return -1; }
--- a/dav/config.h Thu Oct 08 14:25:53 2015 +0200 +++ b/dav/config.h Mon Oct 12 14:36:16 2015 +0200 @@ -63,6 +63,7 @@ bool decrypt_content; bool decrypt_name; int ssl_version; + unsigned long authmethods; }; struct Proxy {
--- a/dav/main.c Thu Oct 08 14:25:53 2015 +0200 +++ b/dav/main.c Mon Oct 12 14:36:16 2015 +0200 @@ -344,6 +344,7 @@ DavSession *sn = dav_session_new_auth(ctx, repo->url, repo->user, repo->password); sn->flags = get_repository_flags(repo); sn->key = dav_context_get_key(ctx, repo->default_key); + curl_easy_setopt(sn->handle, CURLOPT_HTTPAUTH, repo->authmethods); curl_easy_setopt(sn->handle, CURLOPT_SSLVERSION, repo->ssl_version); return sn; }