1.1.2 • Published 4 years ago

@heinlein-video/react-redux-appauth v1.1.2

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
-
Last release
4 years ago

React AppAuth

About

Opinionated React component (AuthProvider) to provide OpenID Connect and OAuth2 protocol support. Has hooks :tada: Heavily inspired by oidc-react but without redux-oidc and the (as of now) unmaintained oidc-client-js.

Based on @openid/appauth-js.

Quickstart

Save as a dependency. PeerDependencies are:

  • "@reduxjs/toolkit"
  • "react"
  • "react-redux"
  • "redux"

Usage

const App = () => {
  const oidcConfig = useAppSelector(selectOidcConfig).config;
  const redirectPath = '/auth/callback';
  const popupRedirectPath = '/auth/popup_callback';
  const isAuthed = useSelector(selectIsAuthed)

return (
  <Router>
  <AuthProvider
    store={store}
    authority={oidcConfig.authority}
    clientId={oidcConfig.client_id}
    redirectUri={window.location.origin + redirectPath}
    popupRedirectUri={window.location.origin + popupRedirectPath}
    scope={oidcConfig.scope}
  >
  <Route path={redirectPath}>
            <AuthCallback history={history}>
              <p>You will be redirected</p>
            </AuthCallback>
          </Route>
          <Route path={popupRedirectPath}>
            <AuthCallback history={history} isPopup>
              <p>You will be redirected</p>
            </AuthCallback>
          </Route>
    <Route default>
      {isAuthed ? <p>Authed</p>:<p>Not Authed</p>}
    <Route>
  </AuthProvider>)
}
1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago