sso-sunbird-helper
v1.0.18
Published
The sso-sunbird-helper npm package is a comprehensive toolkit designed to streamline and simplify the implementation of State Sign-On (SSO) flows within the Sunbird Education platform. This package offers a range of utility functions, tools, and resources
Downloads
26
Maintainers
Readme
Sunbird-SSO-Helper
Introduction
The sso-sunbird-helper
package is a utility tool designed to simplify the integration of State Sign-On (SSO) with Sunbird-ed, an open-source learning platform. It provides developers with streamlined functions and methods to facilitate the implementation of SSO authentication within their applications.
Installation
To get started with sso-sunbird-helper
, you need to install the package using either npm or yarn package managers:
Using npm:
npm install sso-sunbird-helper
Using yarn:
yarn add sso-sunbird-helper
initializeRoute
: This function is used to initiate the State Sign-On (SSO) login process for a user. To log in a user, the client must provide a link that makes a GET request to the auto-login endpoint/v2/user/session/create?token=<jwt_token>
, where<jwt_token>
is the JSON Web Token (JWT) representing the user's authentication.handleVerifiedContactRoute
: Use this function to handle the route that deals with verified contact information. After a user's contact information has been verified during the SSO process, this function is responsible for managing the flow and actions associated with it.handleSuccessRedirect
: This function is used When a user successfully authenticates via SSO and is already registered in your application, this function is configured to redirect the user directly to a resource page.It streamlines the user experience by skipping redundant registration steps.
Importing the Package
You can incorporate the necessary methods from the package into your project using either CommonJS or ES6 module syntax.
CommonJS Syntax
If your project utilizes CommonJS modules, import the methods into your JavaScript file as demonstrated below:
const { initializeRoute, handleVerifiedContactRoute, handleSuccessRedirect } = require('sso-sunbird-helper/src');
ES6 Module Syntax
For projects that support ES6 modules, use the following syntax to import the methods:
import { initializeRoute, handleVerifiedContactRoute, handleSuccessRedirect } from 'sso-sunbird-helper/src';
Integration into Existing ssoRoutes.js
In your ssoRoutes.js
file in your Sunbird Ed project, you can integrate the SSO functionality into this existing file. Here's how to do it:
Open your existing
ssoRoutes.js
file located atsrc/app/routes/ssoRoutes.js
.Add the following code to your existing
ssoRoutes.js
file:
// Import methods from sso-sunbird-helper
const { initializeRoute, handleVerifiedContactRoute, handleSuccessRedirect } = require('sso-sunbird-helper/src');
// Initialize SSO route
app.get('/v2/user/session/create', initializeRoute());
// Handle verified contact route
app.get('/v1/sso/contact/verified', handleVerifiedContactRoute());
// Handle success redirect route
app.get('/v1/sso/success/redirect', handleSuccessRedirect());
- Save the changes to your
ssoRoutes.js
file.
Example Routes
/v2/user/session/create
: Initializes the SSO route./v1/sso/contact/verified
: Handles the verified contact route./v1/sso/success/redirect
: Handles the success redirect route.
Make sure to configure your Express app and routes accordingly to suit your project's needs.
By following these steps, you can seamlessly incorporate the functionalities of the sso-sunbird-helper
package into your project, facilitating the integration of SSO authentication within your Sunbird-ed applications.