osu-auth

1.1.7 • Public • Published

osu-auth

This is a React component that will check whether a user is authenticated by grabbing a jwt_token from cdt-auth-generator. It provides methods to retrieve the token for API calls as well as displaying the roles of the user the token is associated with. If the token is expired or a new token is needed due to refresh, they will be pushed to an authorization endpoint which is maintained in https://github.com/osuecampus/cdt-auth-generator.

React Installation

Run the install!

npm i osu-auth

Go to the index.js file that attaches the React app to your html page, and modify it as so:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import {Auth, AuthMessage} from 'osu-auth';

if(!Auth()){ReactDOM.render(<AuthMessage />, document.getElementById("root"));}
else {ReactDOM.render(<App />, document.getElementById("root"));}

This will allow the authentication to take place before loading the app at all.

The methods exposed for use inside the application are:
getToken(): returns a stringified JWT for use in API calls
getRoles(): returns a string array with the roles the user has
getOnid(): returns the ONID of the current user

Other JS Implementations

It's as easy as...

npm i osu-auth

Then calling Auth() which returns either true for authenticated, or false for not being authenticated.

Authors

The large bulk of this component was written by Ian Band and Eli Laudi.

Readme

Keywords

none

Package Sidebar

Install

npm i osu-auth

Weekly Downloads

1

Version

1.1.7

License

ISC

Unpacked Size

173 kB

Total Files

7

Last publish

Collaborators

  • osuecampus