hx-with-sso-hoc

2.10.6 • Public • Published

hx-with-sso-hoc

The withSSO hoc can be used to wrap any Helixa react application that needs SSO auth. the HOC handles all the redirects and tokens needed in order to auth the hosting application.

See React HOC

A higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per se. They are a pattern that emerges from React’s compositional nature.


Usage

Install the package

npm i hx-with-sso-hoc --save

Then import the HOC

import withSSO from 'hx-with-sso-hoc'

Then the current app needs to be wrapped with needed parameters.

Es:

class App extends React.Component {
  render() {
    const { logged, singleSignOff } = this.props;
    return(
        <div>{logged}</div>
   )
  }
}

export default withSSO({
  appID: process.env.REACT_APP_APP_ID,
  idServerBase: process.env.REACT_APP_ID_SERVER_BASE,
  idServerBaseSignIn: process.env.REACT_APP_ID_SERVER_AUTH,
  idTokenKey: 'HELIXA_ID_TOKEN',
  accessTokenKey: 'HELIXA_ACCESS_TOKEN',
})(App);

Config example of the envs:

REACT_APP_ID_SERVER_BASE=//accounts.helixa.ai
REACT_APP_ID_SERVER_AUTH=//accounts.helixa.ai/login
REACT_APP_APP_ID=hx-engine-ui

Readme

Keywords

Package Sidebar

Install

npm i hx-with-sso-hoc

Weekly Downloads

27

Version

2.10.6

License

ISC

Unpacked Size

41.7 kB

Total Files

7

Last publish

Collaborators

  • hx-dev
  • esantucci