Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

caccl-authorizer

Package Overview
Dependencies
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caccl-authorizer

Acquires Canvas tokens through via OAuth, stores refresh tokens, and refreshes access tokens when they expire.

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
235
increased by245.59%
Maintainers
1
Weekly downloads
 
Created
Source

caccl-authorizer

Handles app authorization, redirecting users to the "Authorize this App" page, acquiring access tokens, and refreshing access tokens when they expire.

Your LTI app accepts launches at your launchPath via POST. caccl-authorizer uses that same path to kick off the Canvas authorization process: direct users to your launchPath via GET and they'll be authorized and then redirected to the defaultAuthorizedRedirect path.

Part of the CACCL library

Canvas
App
Complete
Connection
Library

Quickstart

After creating your express app but before adding routes, initialize caccl-authorizer to add routes and middleware to make authorization possible.

const initAuthorization = require('caccl-authorizer');

// TODO: create express app

initAuthorization({
    app: /* express app with express-session enabled*/,
    developerCredentials: {
        client_id: /* developer client id */,
        client_secret: /* developer client secret */,
    },
    canvasHost: /* your canvas host name */,
});

// TODO: add routes to express app

To authorize a user, redirect them to the launchPath via GET. caccl-authorizer will handle the entire authorization process then redirect them to the defaultAuthorizedRedirect path. After authorization, the user's access token will appear in their session: req.session.accessToken.

Important: you must initialize caccl-authorizer before adding refreshed routes (see autoRefreshRoutes below).

Configuration Options

When initializing caccl-authorizer, you can pass in many different configuration options to customize CACCL's behavior or turn on/off certain functionality.

Note: configuration options are optional unless otherwise stated

Main Configuration Options

Important configuration options you probably should include.

Config OptionTypeDescriptionDefault/Required
appexpress appthe server express app with express-session enabledrequired
developerCredentialsobjectcanvas app developer credentials in the form: { client_id, client_secret }required
canvasHoststringcanvas host to use for oauth exchangecanvas.instructure.com
allowAuthorizationWithoutLaunchbooleanif true, allows user to be authorized even without a launch (when no LTI launch occurred and simulateLaunchOnAuthorize is false)false

App Information

Optional information about your app.

Config OptionTypeDescriptionDefault
appNamestringthe name of the app for use in simulated launches and in errors"this app"
launchPathstringredirect users to this path via GET to kick off the authorization process"/launch"

Authorization Configuration

Options that change how authorization functions. By default, when authorization is complete, the user will be redirected to /, and when the access token expires (after 1hr), it will automatically be refreshed when the user visits any route (*). The refresh tokens are stored in a memory token store. All of these features can be customized via the config options below.

Config OptionTypeDescriptionDefault
defaultAuthorizedRedirectstringthe default route to visit after authorization is complete (you can override this for a specific authorization call by including query.next. example: /launch?next=/profile)"/"
autoRefreshRoutesstring[]list of routes to automatically refresh the access token for (if the access token has expired), these routes must be added after caccl-authorizer has been initialized["*"]
tokenStoreTokenStorenull to turn off storage of refresh tokens, exclude to use memory token store, or include a custom token store (see these docs)memory store

Tip: we recommend setting autoRefreshRoutes to all the paths where you will need access to the Canvas API. Then, the accessToken will never have expired when the user visits one of those paths.

Simulated Launch Options

Enabling this feature allows users to visit the launchPath (GET), go through the authorization process, and then caccl-authorizer simulates an LTI launch. This essentially makes it possible for users to launch your app without visiting Canvas, simply by visiting the launchPath.

To enable this feature,

Config OptionTypeDescriptionDefault
simulateLaunchOnAuthorizebooleanif true, simulates an LTI launch upon successful authorization (if the user hasn't already launched via LTI)false

Keywords

FAQs

Package last updated on 27 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc