提交 87ca6ed5 authored 作者: Anthony Minessale's avatar Anthony Minessale

add userauth <user>@<domain>:<pass> to event_socket to auth against user…

add userauth <user>@<domain>:<pass> to event_socket to auth against user directory uses esl-password esl-allowed-api esl-allowed-events and esl-allowed-log to control resource access

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16160 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 ad2d74c5
...@@ -227,18 +227,19 @@ static abyss_bool user_attributes (const char *user, const char *domain_name, ...@@ -227,18 +227,19 @@ static abyss_bool user_attributes (const char *user, const char *domain_name,
} }
} }
if (x_domain_root) {
switch_xml_free(x_domain_root);
}
if (ppasswd) if (ppasswd)
*ppasswd = passwd; *ppasswd = strdup(passwd);
if (pvm_passwd) if (pvm_passwd)
*pvm_passwd = vm_passwd; *pvm_passwd = strdup(vm_passwd);
if (palias) if (palias)
*palias = alias; *palias = strdup(alias);
if (pallowed_commands) if (pallowed_commands)
*pallowed_commands = allowed_commands; *pallowed_commands = strdup(allowed_commands);
if (x_domain_root) {
switch_xml_free(x_domain_root);
}
return TRUE; return TRUE;
} }
...@@ -293,7 +294,7 @@ static abyss_bool is_authorized (const TSession *r, const char *command) ...@@ -293,7 +294,7 @@ static abyss_bool is_authorized (const TSession *r, const char *command)
if (!allowed_commands) if (!allowed_commands)
return FALSE; return FALSE;
dup = strdup (allowed_commands); dup = allowed_commands;
argc = switch_separate_string (dup, ',', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string (dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
...@@ -319,6 +320,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) ...@@ -319,6 +320,7 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
const char *box = NULL; const char *box = NULL;
int at = 0; int at = 0;
char *dp; char *dp;
abyss_bool rval = FALSE;
p = RequestHeaderValue(r, "authorization"); p = RequestHeaderValue(r, "authorization");
...@@ -445,8 +447,8 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) ...@@ -445,8 +447,8 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
ResponseAddField(r, "freeswitch-user", (box ? box : user)); ResponseAddField(r, "freeswitch-user", (box ? box : user));
ResponseAddField(r, "freeswitch-domain", domain_name); ResponseAddField(r, "freeswitch-domain", domain_name);
rval = TRUE;
return TRUE; goto done;
} }
} }
} }
...@@ -456,7 +458,14 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name) ...@@ -456,7 +458,14 @@ static abyss_bool http_directory_auth(TSession *r, char *domain_name)
switch_snprintf(z, sizeof(z), "Basic realm=\"%s\"", domain_name ? domain_name : globals.realm); switch_snprintf(z, sizeof(z), "Basic realm=\"%s\"", domain_name ? domain_name : globals.realm);
ResponseAddField(r, "WWW-Authenticate", z); ResponseAddField(r, "WWW-Authenticate", z);
ResponseStatus(r, 401); ResponseStatus(r, 401);
return FALSE;
done:
switch_safe_free(mypass1);
switch_safe_free(mypass2);
switch_safe_free(box);
return rval;
} }
abyss_bool auth_hook(TSession * r) abyss_bool auth_hook(TSession * r)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论