hx-with-sso-hoc
v2.10.7
Published
React HOC for Helixa SSO
Downloads
26
Readme
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