瀏覽代碼

Updated example config for S-CSCF

Carsten Bock 12 年之前
父節點
當前提交
94e7ae77a6
共有 1 個文件被更改,包括 32 次插入10 次删除
  1. 32 10
      examples/scscf/kamailio.cfg

+ 32 - 10
examples/scscf/kamailio.cfg

@@ -430,16 +430,38 @@ route[XMLRPC] {
 # Route for handling Registrations:
 ######################################################################
 route[REGISTER] {
-	xlog("L_ERR", "Enter register block");
-	t_newtran();
-	
-	ims_www_authenticate(NETWORKNAME);
-
-	#check to see if user is authenticated - ie sip header has auth information - (already challenged)
-	if ($avp(maa_return_code) == 1) {
-		# user has not been authenticated. Lets send a challenge via 401 Unauthorized
-		ims_www_challenge("$td"); 
-		exit;
+        if (!ims_www_authenticate(NETWORKNAME)) {
+                if ($? == -2) {
+                        t_reply("403", "Authentication Failed");
+                        exit;
+                } else if ($? == -3) {
+                        t_reply("400", "Bad Request");
+                        exit;
+                } else {
+                        #user has not been authenticated. Lets send a challenge via 401 Unauthorized
+                        xlog("L_DBG","About to challenge! auth_ims\n");
+                        ims_www_challenge("$td");
+                        #this is async so to know status we have to check the reply avp
+                        xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");
+
+                        switch ($avp(s:maa_return_code)){
+                                case 1: #success
+                                        xlog("L_DBG", "MAR success - 401/407 response sent from module");
+                                        break;
+                                case -1: #failure
+                                        xlog("L_ERR", "MAR failure - error response sent from module");
+                                        break;
+                                case -2: #error
+                                        xlog("L_ERR", "MAR error - sending error response now");
+                                        t_reply("500", "MAR failed");
+                                        break;
+                                default:
+                                        xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]");
+                                        t_reply("500", "Unknown response code from MAR");
+                                        break;
+                        }
+                        exit;
+                }
 	} else {
 		# We need to check if this user is registered or not
 		if (!impu_registered("location")) {