Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
46c1b421
提交
46c1b421
authored
10月 20, 2017
作者:
Luis Azedo
提交者:
lazedo
3月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10746 [mod_sofia] allow authoritative proxy to provide token
上级
d19e3bb3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
50 行增加
和
29 行删除
+50
-29
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+1
-0
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+49
-29
没有找到文件。
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
46c1b421
...
@@ -309,6 +309,7 @@ typedef enum {
...
@@ -309,6 +309,7 @@ typedef enum {
PFLAG_FIRE_BYE_RESPONSE_EVENTS
,
PFLAG_FIRE_BYE_RESPONSE_EVENTS
,
PFLAG_AUTO_INVITE_100
,
PFLAG_AUTO_INVITE_100
,
PFLAG_UPDATE_REFRESHER
,
PFLAG_UPDATE_REFRESHER
,
PFLAG_AUTH_REQUIRE_USER
,
/* No new flags below this line */
/* No new flags below this line */
PFLAG_MAX
PFLAG_MAX
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
46c1b421
...
@@ -4591,6 +4591,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
...
@@ -4591,6 +4591,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
sofia_clear_pflag
(
profile
,
PFLAG_MAKE_EVERY_TRANSFER_A_NIGHTMARE
);
sofia_clear_pflag
(
profile
,
PFLAG_MAKE_EVERY_TRANSFER_A_NIGHTMARE
);
sofia_clear_pflag
(
profile
,
PFLAG_FIRE_TRANFER_EVENTS
);
sofia_clear_pflag
(
profile
,
PFLAG_FIRE_TRANFER_EVENTS
);
sofia_clear_pflag
(
profile
,
PFLAG_BLIND_AUTH_ENFORCE_RESULT
);
sofia_clear_pflag
(
profile
,
PFLAG_BLIND_AUTH_ENFORCE_RESULT
);
sofia_clear_pflag
(
profile
,
PFLAG_AUTH_REQUIRE_USER
);
profile
->
shutdown_type
=
"false"
;
profile
->
shutdown_type
=
"false"
;
profile
->
local_network
=
"localnet.auto"
;
profile
->
local_network
=
"localnet.auto"
;
sofia_set_flag
(
profile
,
TFLAG_ENABLE_SOA
);
sofia_set_flag
(
profile
,
TFLAG_ENABLE_SOA
);
...
@@ -5486,6 +5487,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
...
@@ -5486,6 +5487,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
profile
->
nonce_ttl
=
atoi
(
val
);
profile
->
nonce_ttl
=
atoi
(
val
);
}
else
if
(
!
strcasecmp
(
var
,
"max-auth-validity"
)
&&
!
zstr
(
val
))
{
}
else
if
(
!
strcasecmp
(
var
,
"max-auth-validity"
)
&&
!
zstr
(
val
))
{
profile
->
max_auth_validity
=
atoi
(
val
);
profile
->
max_auth_validity
=
atoi
(
val
);
}
else
if
(
!
strcasecmp
(
var
,
"auth-require-user"
))
{
if
(
switch_true
(
val
))
{
sofia_set_pflag
(
profile
,
PFLAG_AUTH_REQUIRE_USER
);
}
else
{
sofia_clear_pflag
(
profile
,
PFLAG_AUTH_REQUIRE_USER
);
}
}
else
if
(
!
strcasecmp
(
var
,
"accept-blind-reg"
))
{
}
else
if
(
!
strcasecmp
(
var
,
"accept-blind-reg"
))
{
if
(
switch_true
(
val
))
{
if
(
switch_true
(
val
))
{
sofia_set_pflag
(
profile
,
PFLAG_BLIND_REG
);
sofia_set_pflag
(
profile
,
PFLAG_BLIND_REG
);
...
@@ -10232,54 +10239,57 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
...
@@ -10232,54 +10239,57 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
* ip header and see if it matches against the inbound acl
* ip header and see if it matches against the inbound acl
*/
*/
if
(
network_ip_is_proxy
)
{
if
(
network_ip_is_proxy
)
{
const
char
*
x_auth_ip
=
sofia_glue_get_unknown_header
(
sip
,
"X-AUTH-IP"
);
const
char
*
x_auth_token
=
sofia_glue_get_unknown_header
(
sip
,
"X-AUTH-Token"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"network ip is a proxy
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"network ip is a proxy
\n
"
);
for
(
un
=
sip
->
sip_unknown
;
un
;
un
=
un
->
un_next
)
{
if
(
!
zstr
(
x_auth_token
)
&&
!
zstr
(
x_auth_ip
))
{
if
(
!
strcasecmp
(
un
->
un_name
,
"X-AUTH-IP"
))
{
switch_copy_string
(
proxied_client_ip
,
x_auth_ip
,
sizeof
(
proxied_client_ip
));
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"found auth ip [%s] header of [%s]
\n
"
,
un
->
un_name
,
un
->
un_value
);
token
=
x_auth_token
;
if
(
!
zstr
(
un
->
un_value
))
{
ok
=
1
;
for
(
x
=
0
;
x
<
profile
->
acl_count
;
x
++
)
{
}
else
if
(
!
zstr
(
x_auth_ip
))
{
last_acl
=
profile
->
acl
[
x
];
for
(
x
=
0
;
x
<
profile
->
acl_count
;
x
++
)
{
if
((
ok
=
switch_check_network_list_ip_token
(
un
->
un_value
,
last_acl
,
&
token
)))
{
last_acl
=
profile
->
acl
[
x
];
switch_copy_string
(
proxied_client_ip
,
un
->
un_value
,
sizeof
(
proxied_client_ip
));
if
((
ok
=
switch_check_network_list_ip_token
(
x_auth_ip
,
last_acl
,
&
token
)))
{
break
;
switch_copy_string
(
proxied_client_ip
,
x_auth_ip
,
sizeof
(
proxied_client_ip
));
}
break
;
}
}
}
}
}
}
}
}
if
(
!
ok
)
{
if
(
!
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
))
{
if
(
!
ok
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"IP %s Rejected by acl
\"
%s
\"\n
"
,
network_ip
,
switch_str_nil
(
last_acl
));
if
(
!
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"IP %s Rejected by acl
\"
%s
\"\n
"
,
x_auth_ip
,
switch_str_nil
(
last_acl
));
if
(
!
acl_context
)
{
nua_respond
(
nh
,
SIP_403_FORBIDDEN
,
TAG_END
());
nua_respond
(
nh
,
SIP_403_FORBIDDEN
,
TAG_END
());
goto
fail
;
goto
fail
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"IP %s Rejected by acl
\"
%s
\"
. Falling back to Digest auth.
\n
"
,
x_auth_ip
,
switch_str_nil
(
last_acl
));
}
}
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"IP %s Rejected by acl
\"
%s
\"
. Falling back to Digest auth.
\n
"
,
if
(
token
)
{
network_ip
,
switch_str_nil
(
last_acl
));
switch_set_string
(
acl_token
,
token
);
}
}
}
else
{
if
(
token
)
{
switch_set_string
(
acl_token
,
token
);
}
if
(
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"IP %s Approved by acl
\"
%s[%s]
\"
. Access Granted.
\n
"
,
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"IP %s Approved by acl
\"
%s[%s]
\"
. Access Granted.
\n
"
,
proxied_client_ip
,
switch_str_nil
(
last_acl
),
acl_token
);
proxied_client_ip
,
switch_str_nil
(
last_acl
),
acl_token
);
switch_set_string
(
sip_acl_authed_by
,
last_acl
);
switch_set_string
(
sip_acl_authed_by
,
last_acl
);
switch_set_string
(
sip_acl_token
,
acl_token
);
switch_set_string
(
sip_acl_token
,
acl_token
);
is_auth
=
1
;
is_auth
=
1
;
}
}
else
{
if
(
!
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_WARNING
,
"IP %s Rejected by acl
\"
%s
\"\n
"
,
network_ip
,
switch_str_nil
(
last_acl
));
nua_respond
(
nh
,
SIP_403_FORBIDDEN
,
TAG_END
());
goto
fail
;
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"IP %s Rejected by acl
\"
%s
\"
. Falling back to Digest auth.
\n
"
,
network_ip
,
switch_str_nil
(
last_acl
));
}
}
}
}
}
}
}
}
if
(
!
is_auth
&&
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
)
&&
sofia_test_pflag
(
profile
,
PFLAG_BLIND_AUTH
))
{
if
(
!
is_auth
&&
sofia_test_pflag
(
profile
,
PFLAG_AUTH_CALLS
)
&&
sofia_test_pflag
(
profile
,
PFLAG_BLIND_AUTH
))
{
char
*
user
;
char
*
user
;
switch_status_t
blind_result
=
SWITCH_STATUS_FALSE
;
switch_status_t
blind_result
=
SWITCH_STATUS_FALSE
;
...
@@ -10343,10 +10353,20 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
...
@@ -10343,10 +10353,20 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
if
(
*
acl_token
)
{
if
(
*
acl_token
)
{
switch_channel_set_variable
(
channel
,
"acl_token"
,
acl_token
);
switch_channel_set_variable
(
channel
,
"acl_token"
,
acl_token
);
if
(
strchr
(
acl_token
,
'@'
))
{
if
(
strchr
(
acl_token
,
'@'
))
{
if
(
switch_ivr_set_user
(
session
,
acl_token
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_create
(
&
v_event
,
SWITCH_EVENT_REQUEST_PARAMS
);
for
(
un
=
sip
->
sip_unknown
;
un
;
un
=
un
->
un_next
)
{
switch_event_add_header_string
(
v_event
,
SWITCH_STACK_BOTTOM
,
un
->
un_name
,
un
->
un_value
);
};
if
(
switch_ivr_set_user_extended
(
session
,
acl_token
,
v_event
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_destroy
(
&
v_event
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Authenticating user %s
\n
"
,
acl_token
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"Authenticating user %s
\n
"
,
acl_token
);
}
else
{
}
else
{
switch_event_destroy
(
&
v_event
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"Error Authenticating user %s
\n
"
,
acl_token
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_WARNING
,
"Error Authenticating user %s
\n
"
,
acl_token
);
if
(
sofia_test_pflag
(
profile
,
PFLAG_AUTH_REQUIRE_USER
))
{
nua_respond
(
nh
,
SIP_480_TEMPORARILY_UNAVAILABLE
,
TAG_END
());
goto
fail
;
}
}
}
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论