1.1.7 • Published 5 years ago

osu-auth v1.1.7

Weekly downloads
9
License
ISC
Repository
-
Last release
5 years ago

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.

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago