Giter Club home page Giter Club logo

papers-lti's Introduction

papers-lti

Build Status Code Climate Test Coverage

Passport-flavored LTI authentication middleware for express.

LTIStrategy

Options :

  • createProvider : createProvider is an optional function, which delegate the check of a Tool Consumer's identity to an higher level.

    This function is assumed to request a database to retrieve the consumer secret based on the consumer key, and call the callback parameter with an LTI provider, or a standard node error in err if a system error occured, or a string error if the error is handled at an higher level, and the process is just intended to stop. Use either this function or the hardcoded key / secret. This one gets priority over the hardcoded key / secret.

    @param {Function} createProvider 
    	@param {Object} req
    	@param {Function} callback
    		@param {Object || String} err
    		@param {Object} provider
    
  • consumerKey : Hardcoded consumer key.

  • consumerSecret : Hardcoded consumer secret.

Usage

With hardcoded key / secret

var papers = require('papers');
var LTIStrategy = require('papers-lti');
var strategy = new LTIStrategy({
	consumerKey: 'testconsumerkey',
	consumerSecret: 'testconsumersecret'
	// pass the req object to callback
	// passReqToCallback: true,
	// https://github.com/omsmith/ims-lti#nonce-stores
	// nonceStore: new RedisNonceStore('testconsumerkey', redisClient)
}, function(lti, done) {
	// LTI launch parameters
	// console.dir(lti);
	// Perform local authentication if necessary
	return done(null, user);
});
papers.use(strategy);

With dynamic provider

var papers = require('papers');
var lti = require("ims-lti");
var LTIStrategy = require('papers-lti');
var strategy = new LTIStrategy({
	createProvider : function (req, done) {
		// Lookup your LTI customer in your DB with req's params, and get its secret
		// Dummy DB lookup
		DAO.getConsumer(
			req.body.oauth_consumer_key,
			function callback (err, consumer){
				if(err){
					// Standard error, will crash the process
					return done(err);
				}
	
				if(consumer.is_authorized){
					var consumer = new lti.Provider(consumer_db.oauth_consumer_key, consumer_db.oauth_consumer_secret);
					return done(null, consumer);
				}
				else {
					// String error, will fail the strategy (and not crash it)
					return done("not_authorized");
				}
	    	}
		);
	}
);

papers.use(strategy);

Tests

$ npm test

papers-lti's People

Contributors

reharik avatar

Stargazers

Sonya avatar

Watchers

James Cloos avatar  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.