[sr-dev] git:master:3ce13be0: auth: exported has_credentials() to kemi framework
Daniel-Constantin Mierla
miconda at gmail.com
Thu May 4 08:04:22 CEST 2017
Module: kamailio
Branch: master
Commit: 3ce13be06217e7d49a5e4362bf5cf6e53ec584ac
URL: https://github.com/kamailio/kamailio/commit/3ce13be06217e7d49a5e4362bf5cf6e53ec584ac
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-05-04T07:31:41+02:00
auth: exported has_credentials() to kemi framework
---
Modified: src/modules/auth/auth_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/3ce13be06217e7d49a5e4362bf5cf6e53ec584ac.diff
Patch: https://github.com/kamailio/kamailio/commit/3ce13be06217e7d49a5e4362bf5cf6e53ec584ac.patch
---
diff --git a/src/modules/auth/auth_mod.c b/src/modules/auth/auth_mod.c
index cc66651..bdb0d7a 100644
--- a/src/modules/auth/auth_mod.c
+++ b/src/modules/auth/auth_mod.c
@@ -444,33 +444,40 @@ int w_consume_credentials(struct sip_msg* msg, char* s1, char* s2)
/**
*
*/
-int w_has_credentials(sip_msg_t *msg, char* realm, char* s2)
+int ki_has_credentials(sip_msg_t *msg, str* srealm)
{
- str srealm = {0, 0};
hdr_field_t *hdr = NULL;
int ret;
- if (fixup_get_svalue(msg, (gparam_t*)realm, &srealm) < 0) {
- LM_ERR("failed to get realm value\n");
- return -1;
- }
-
- ret = find_credentials(msg, &srealm, HDR_PROXYAUTH_T, &hdr);
+ ret = find_credentials(msg, srealm, HDR_PROXYAUTH_T, &hdr);
if(ret==0) {
- LM_DBG("found www credentials with realm [%.*s]\n", srealm.len, srealm.s);
+ LM_DBG("found www credentials with realm [%.*s]\n", srealm->len, srealm->s);
return 1;
}
- ret = find_credentials(msg, &srealm, HDR_AUTHORIZATION_T, &hdr);
+ ret = find_credentials(msg, srealm, HDR_AUTHORIZATION_T, &hdr);
if(ret==0) {
- LM_DBG("found proxy credentials with realm [%.*s]\n", srealm.len, srealm.s);
+ LM_DBG("found proxy credentials with realm [%.*s]\n", srealm->len, srealm->s);
return 1;
}
- LM_DBG("no credentials with realm [%.*s]\n", srealm.len, srealm.s);
+ LM_DBG("no credentials with realm [%.*s]\n", srealm->len, srealm->s);
return -1;
}
/**
+ *
+ */
+int w_has_credentials(sip_msg_t *msg, char* realm, char* s2)
+{
+ str srealm = {0, 0};
+
+ if (fixup_get_svalue(msg, (gparam_t*)realm, &srealm) < 0) {
+ LM_ERR("failed to get realm value\n");
+ return -1;
+ }
+ return ki_has_credentials(msg, &srealm);
+}
+/**
* @brief do WWW-Digest authentication with password taken from cfg var
*/
int pv_authenticate(struct sip_msg *msg, str *realm, str *passwd,
@@ -1220,6 +1227,11 @@ static sr_kemi_t sr_kemi_auth_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_INT,
SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("auth"), str_init("has_credentials"),
+ SR_KEMIP_INT, ki_has_credentials,
+ { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};
More information about the sr-dev
mailing list