1.0.18 • Published 8 months ago

sso-sunbird-helper v1.0.18

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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. Sunbird SSO Flow Diagram

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:

  1. Open your existing ssoRoutes.js file located at src/app/routes/ssoRoutes.js.

  2. 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());
  1. 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.

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago