Git Product home page Git Product logo

sasljs's Introduction

SASL

Bindings to GSASL for node.js. Made to implement XMPP, but can be used anywhere.

At the moment the only plan is to support basic server side auth with callbacks

Since I do not currently require any other parts of the SASL API, they will not be implemented. You are welcome to add them though, please notify me when you do, so that I can pull.

Usage

  1. Create a new SASL session using

    var sasl = require('sasljs'); var session = sasl.createServerSession("", callback );

callback is a callback function which should accept the property name and session object and set properties as requested.

  1. Start the session with a mechanism. The list of supported mechanisms is available as session.mechanisms.

    session.start("DIGEST-MD5");

  2. Step through the authentication procedure by calling step() with input from the client.

    session.step("");

step() returns an object with two members:

{
    status: Integer status code,
    data: Error or reply
}

If status is sasl.GSASL_OK, authentication succeeded. For sasl.GSASL_NEEDS_MORE send the data back to the client. For others, compare against available error codes and decide what to do. Usually abort.

  1. Use callback

    function callback(property, session) { // since realm is not currently set above if( property == sasl.GSASL_REALM ) { session.setProperty("realm", "MyHomePage"); return sasl.GSASL_OK; }

     if( property == sasl.GSASL_PASSWORD ) {
         // get password for user, using property()
         var pass = getPassword(session.property('authid'));
         session.setProperty('password', pass);
         return sasl.GSASL_OK;
     }
    

    }

You have to return GSASL_OK if you handled the callback! As you can see, setProperty() accepts string keys. For a list of keys, see lib/sasljs.cc towards the end.


Nikhil Marathe

sasljs's People

Contributors

nikhilm avatar

Watchers

Amit Kumar avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.