Module: kamailio
Branch: 6.0
Commit: 244caf8c20ee61312b31aaa912529785e929c766
URL: 
https://github.com/kamailio/kamailio/commit/244caf8c20ee61312b31aaa912529785e929c766

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2025-11-27T17:37:04+01:00

auth: add defines for authenticate flags

(cherry picked from commit cd88ca4bb64a8d44e2ea9f73be53b24d3b3a93fa)

---

Modified: src/modules/auth/api.h
Modified: src/modules/auth/auth_mod.c

---

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

---

diff --git a/src/modules/auth/api.h b/src/modules/auth/api.h
index 89b273479f4..397edeb446a 100644
--- a/src/modules/auth/api.h
+++ b/src/modules/auth/api.h
@@ -60,6 +60,22 @@ typedef enum auth_cfg_result
 #define AUTH_CHECK_ID_F 1 << 0
 #define AUTH_CHECK_SKIPFWD_F 1 << 1
 
+/**
+ * flags to control auth functions
+ */
+/* password parameter is HA1 format */
+#define AUTH_FLAG_PASSWDHA1 1
+/* challenge header with no qop and add it to avp */
+#define AUTH_FLAG_HDRQOPNONE 2
+/* challenge header with qop=auth and add it to avp */
+#define AUTH_FLAG_HDRQOPAUTH 4
+/* challenge header with qop=auth-int and add it to avp */
+#define AUTH_FLAG_HDRQOPAUTHINT 8
+/* challenge header with stale=true */
+#define AUTH_FLAG_CLGSTALE 16
+/* do not invalidate nc on authentication failure */
+#define AUTH_FLAG_NOINVNC 32
+
 /**
  * return codes to auth API functions
  */
diff --git a/src/modules/auth/auth_mod.c b/src/modules/auth/auth_mod.c
index b1da97aea94..57b393c36be 100644
--- a/src/modules/auth/auth_mod.c
+++ b/src/modules/auth/auth_mod.c
@@ -617,7 +617,7 @@ int pv_authenticate(struct sip_msg *msg, str *realm, str 
*passwd, int flags,
        cred = (auth_body_t *)h->parsed;
 
        /* compute HA1 if needed */
-       if((flags & 1) == 0) {
+       if((flags & AUTH_FLAG_PASSWDHA1) == 0) {
                /* Plaintext password is stored in PV, calculate HA1 */
                calc_HA1(
                                HA_MD5, &cred->digest.username.whole, realm, 
passwd, 0, 0, ha1);
@@ -647,7 +647,7 @@ int pv_authenticate(struct sip_msg *msg, str *realm, str 
*passwd, int flags,
 
 #ifdef USE_NC
        /* On success we need to update the nonce if flag 32 is set */
-       if(nc_enabled && ret == AUTH_OK && (flags & 32)) {
+       if(nc_enabled && ret == AUTH_OK && (flags & AUTH_FLAG_NOINVNC)) {
                if(check_nonce(cred, &secret1, &secret2, msg, 1) < 0) {
                        LM_ERR("check_nonce failed after post_auth");
                        ret = AUTH_ERROR;
@@ -663,9 +663,9 @@ int pv_authenticate(struct sip_msg *msg, str *realm, str 
*passwd, int flags,
                /* check if required to add challenge header as avp */
                if(!(flags & 14))
                        return ret;
-               if(flags & 8) {
+               if(flags & AUTH_FLAG_HDRQOPAUTHINT) {
                        qop = &auth_qauthint;
-               } else if(flags & 4) {
+               } else if(flags & AUTH_FLAG_HDRQOPAUTH) {
                        qop = &auth_qauth;
                }
                if(get_challenge_hf(msg, (cred ? cred->stale : 0), realm, NULL,

_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to