Module: kamailio
Branch: master
Commit: f16ba6d4a5305be84d5a2b9d1e6c6a15368c8c76
URL: 
https://github.com/kamailio/kamailio/commit/f16ba6d4a5305be84d5a2b9d1e6c6a15368c8c76

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2023-04-26T20:36:36+02:00

auth: exported auth_get_www_authenticate() to kemi

---

Modified: src/modules/auth/auth_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/f16ba6d4a5305be84d5a2b9d1e6c6a15368c8c76.diff
Patch: 
https://github.com/kamailio/kamailio/commit/f16ba6d4a5305be84d5a2b9d1e6c6a15368c8c76.patch

---

diff --git a/src/modules/auth/auth_mod.c b/src/modules/auth/auth_mod.c
index 5538ffb4f03..8e74d33dd4e 100644
--- a/src/modules/auth/auth_mod.c
+++ b/src/modules/auth/auth_mod.c
@@ -1260,6 +1260,43 @@ static int fixup_auth_get_www_authenticate(void **param, 
int param_no)
        return 0;
 }
 
+/**
+ *
+ */
+static int ki_auth_get_www_authenticate(sip_msg_t* msg, str* realm,
+               int flags, str *pvdst)
+{
+       str hf = {0};
+       pv_spec_t *pvs;
+       pv_value_t val;
+       int ret;
+
+       pvs = pv_cache_get(pvdst);
+       if(pvs==NULL) {
+               LM_ERR("cannot get pv spec for [%.*s]\n", pvdst->len, pvdst->s);
+               return -1;
+       }
+
+       ret = auth_challenge_helper(NULL, realm, flags,
+                       HDR_AUTHORIZATION_T, &hf);
+
+       if(ret<0)
+               return ret;
+
+       val.rs.s = pv_get_buffer();
+       val.rs.len = 0;
+       if(hf.s!=NULL) {
+               memcpy(val.rs.s, hf.s, hf.len);
+               val.rs.len = hf.len;
+               val.rs.s[val.rs.len] = '\0';
+               pkg_free(hf.s);
+       }
+       val.flags = PV_VAL_STR;
+       pvs->setf(msg, &pvs->pvp, (int)EQ_T, &val);
+
+       return (ret==0)?1:ret;
+}
+
 /**
  *
  */
@@ -1295,6 +1332,11 @@ static sr_kemi_t sr_kemi_auth_exports[] = {
                { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
                        SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
        },
+       { str_init("auth"), str_init("auth_get_www_authenticate"),
+               SR_KEMIP_INT, ki_auth_get_www_authenticate,
+               { SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_STR,
+                       SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+       },
 
        { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to [email protected]

Reply via email to