Skip to content
Newer
Older
100644 73 lines (52 sloc) 1.96 KB
f38d511 @nikhilm Initial import. Implemented basic wrapper.
authored Apr 5, 2010
1 SASL
2 ====
3
0c0e701 @nikhilm Markdowned readme and put in note about dependency switch
authored Apr 9, 2010
4 Bindings to [GSASL](http://www.gnu.org/software/gsasl/) for node.js.
f38d511 @nikhilm Initial import. Implemented basic wrapper.
authored Apr 5, 2010
5 Made to implement XMPP, but can be used anywhere.
6
0c0e701 @nikhilm Markdowned readme and put in note about dependency switch
authored Apr 8, 2010
7 At the moment the only plan is to support basic server side auth with callbacks
f38d511 @nikhilm Initial import. Implemented basic wrapper.
authored Apr 5, 2010
8
9 Since I do not currently require any other parts of the SASL API, they will not be implemented.
10 You are welcome to add them though, please notify me when you do, so that I can pull.
11
518051d @nikhilm Updated README with usage
authored Apr 18, 2010
12 Usage
13 -----
14
15 1) Create a new SASL session using
16
17 var sasl = require('sasljs');
18 var session = sasl.createServerSession("<realm>",
19 callback );
20
21 `callback` is a callback function which should accept
22 the property name and session object and set
23 properties as requested.
24
25 2) Start the session with a mechanism. The list of
26 supported mechanisms is available as
27 `session.mechanisms`.
28
29 session.start("DIGEST-MD5");
30
31 3) Step through the authentication procedure by
32 calling `step()` with input from the client.
33
34 session.step("<client input>");
35
36 `step()` returns an object with two members:
37
38 {
39 status: Integer status code,
40 data: Error or reply
41 }
42
43 If `status` is `sasl.GSASL_OK`, authentication
44 succeeded. For `sasl.GSASL_NEEDS_MORE` send the data
45 back to the client. For others, compare against
46 available error codes and decide what to do. Usually
47 abort.
48
49 4) Use callback
50
51 function callback(property, session) {
52 // since realm is not currently set above
53 if( property == sasl.GSASL_REALM ) {
54 session.setProperty("realm", "MyHomePage");
55 return sasl.GSASL_OK;
56 }
57
58 if( property == sasl.GSASL_PASSWORD ) {
59 // get password for user, using property()
60 var pass = getPassword(session.property('authid'));
61 session.setProperty('password', pass);
62 return sasl.GSASL_OK;
63 }
64 }
65
66 You *have* to return `GSASL_OK` if you handled the callback!
67 As you can see, `setProperty()` accepts string keys. For a list
68 of keys, see `lib/sasljs.cc` towards the end.
69
70
0c0e701 @nikhilm Markdowned readme and put in note about dependency switch
authored Apr 8, 2010
71 ----
f38d511 @nikhilm Initial import. Implemented basic wrapper.
authored Apr 5, 2010
72 Nikhil Marathe
Something went wrong with that request. Please try again.