Browse code

uac_auth: added UAS authentication of requests (internal API)

Stefan Sayer authored on 01/08/2013 15:54:16
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-uac_auth Client authentication 
1
+uac_auth Client / Server authentication 
2 2
 
3 3
 how to use uac_auth
4 4
 --------------------
... ...
@@ -30,3 +30,61 @@ How to
30 30
 
31 31
 see announce_auth app for example application
32 32
 
33
+
34
+How to use server auth
35
+----------------------
36
+
37
+To authenticate a request, use the "checkAuth" DI function.
38
+
39
+ Arguments:
40
+     args[0] - ArgObject pointing to the Request (AmSipRequest object)
41
+     args[1] - realm
42
+     args[2] - user
43
+     args[3] - password
44
+ Return values:
45
+     ret[0] - code: 200 for successful auth, 401 for unsuccessful (ie.
46
+     ret[1] - reason string
47
+     ret[2] - optional auth header
48
+
49
+Limitations
50
+-----------
51
+
52
+- URI in auth hdr is not checked
53
+- multiple Authorization headers are probably not properly processed (only the first one is used)
54
+
55
+code example:
56
+
57
+    AmDynInvokeFactory* fact = 
58
+      AmPlugIn::instance()->getFactory4Di("uac_auth");
59
+    if (NULL != fact) {
60
+      AmDynInvoke* di_inst = fact->getInstance();
61
+      if(di_inst) {
62
+	AmArg di_args, di_ret;
63
+	try {
64
+	  di_args.push(AmArg((AmObject*)&req));
65
+	  di_args.push("myrealm");
66
+	  di_args.push("myuser");
67
+	  di_args.push("mypwd");
68
+	  di_inst->invoke("checkAuth", di_args, di_ret);
69
+	  
70
+	  if (di_ret.size() >= 3) {
71
+	    if (di_ret[0].asInt() != 200) {
72
+	      DBG("Auth: replying %u %s - hdrs: '%s'\n",
73
+		  di_ret[0].asInt(), di_ret[1].asCStr(), di_ret[2].asCStr());
74
+	      dlg->reply(req, di_ret[0].asInt(), di_ret[1].asCStr(), NULL, di_ret[2].asCStr());
75
+	      return;
76
+	    } else {
77
+	      DBG("Successfully authenticated request.\n");
78
+	    }
79
+	  }
80
+	} catch (const AmDynInvoke::NotImplemented& ni) {
81
+	  ERROR("not implemented DI function 'checkAuth'\n");
82
+	} catch (const AmArg::OutOfBoundsException& oob) {
83
+	  ERROR("out of bounds in  DI call 'checkAuth'\n");
84
+	} catch (const AmArg::TypeMismatchException& oob) {
85
+	  ERROR("type mismatch  in  DI call checkAuth\n");
86
+	} catch (...) {
87
+	  ERROR("unexpected Exception  in  DI call checkAuth\n");
88
+	}
89
+     }
90
+  }
Browse code

simplified SIP uac auth (use AmUACAuth, see AmUACAuth.h)

Stefan Sayer authored on 24/11/2011 15:06:52
Showing 1 changed files
... ...
@@ -1,6 +1,5 @@
1 1
 uac_auth Client authentication 
2 2
 
3
-
4 3
 how to use uac_auth
5 4
 --------------------
6 5
 
... ...
@@ -14,30 +13,20 @@ How to
14 13
 1) provide credentials
15 14
  * Derive your Session object from CredentialHolder:
16 15
 
17
-  #include "../../core/plug-in/uac_auth/UACAuth.h"
16
+  #include "AmUACAuth.h"
18 17
   ...
19 18
 
20
-  class AnnouncementDialog : public AmSession,
21
-	  					     public CredentialHolder
19
+  class MyCall : public AmSession,
20
+	  	    public CredentialHolder
22 21
 
23 22
  * set credentials on session creation
24 23
 	AnnouncementDialog::AnnouncementDialog(...) 
25 24
     : CredentialHolder("myrealm", "myuser", "mypwd")
26 25
 
27 26
 
28
-2) add uac_auth SessionEventHandler to session
29
-	
30
- * get uac_auth factory interface (e.g. in onLoad):
31
-    uac_auth_f = AmPlugIn::instance()->getFactory4Seh("uac_auth");
32
-   
33
- * add when you create a new session:
34
-
35
-    if (uac_auth_f != NULL) {
36
-		DBG("UAC Auth enabled for new  session.\n");
37
-		AmSessionEventHandler* h = uac_auth_f->getHandler(dlg);
38
-		if (h != NULL )
39
-			dlg->addHandler(h);
40
-	}
27
+2) enable uac_auth (add SessionEventHandler to session)
28
+  MyCall* my_call=new MyCall();
29
+  AmUACAuth::enable(my_call);
41 30
 
42 31
 see announce_auth app for example application
43 32
 
Browse code

added .txt extension to Readme files

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1555 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Stefan Sayer authored on 22/10/2009 01:22:47
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+uac_auth Client authentication 
2
+
3
+
4
+how to use uac_auth
5
+--------------------
6
+
7
+Requests with 407/401 replies are authenticated and resent by the 
8
+uac_auth SessionComponent plugin, if 
9
+  1. Credentials are provided by the Session and 
10
+  2. uac_auth is added as SessionEventHandler to the session 
11
+    (so that the uac_auth gets incoming and outgoing messages).
12
+
13
+How to
14
+1) provide credentials
15
+ * Derive your Session object from CredentialHolder:
16
+
17
+  #include "../../core/plug-in/uac_auth/UACAuth.h"
18
+  ...
19
+
20
+  class AnnouncementDialog : public AmSession,
21
+	  					     public CredentialHolder
22
+
23
+ * set credentials on session creation
24
+	AnnouncementDialog::AnnouncementDialog(...) 
25
+    : CredentialHolder("myrealm", "myuser", "mypwd")
26
+
27
+
28
+2) add uac_auth SessionEventHandler to session
29
+	
30
+ * get uac_auth factory interface (e.g. in onLoad):
31
+    uac_auth_f = AmPlugIn::instance()->getFactory4Seh("uac_auth");
32
+   
33
+ * add when you create a new session:
34
+
35
+    if (uac_auth_f != NULL) {
36
+		DBG("UAC Auth enabled for new  session.\n");
37
+		AmSessionEventHandler* h = uac_auth_f->getHandler(dlg);
38
+		if (h != NULL )
39
+			dlg->addHandler(h);
40
+	}
41
+
42
+see announce_auth app for example application
43
+