2.0.5 • Published 4 years ago

@ssskram/authz v2.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Auth

This repo contains an implementation of the Auth0 client library that is wrapped in a nice little React component. It can be placed anywhere on the tree, and it will treat all children as protected resources.

Installation

This package is currently served from my personal npm account. This will change once we get our own npm/gpr account set up.

yarn add @ssskram/authz

Usage

.env

REACT_APP_AUTH0_DOMAIN={Auth0 domain}
REACT_APP_AUTH0_ID={Auth0 client ID}

Ask Paul for these :)

Without a store

The simplest implementation just pushes the user through the authentication flow, and then delivers the Auth object to the child as a property which can be drilled down as needed:

import Auth from '@ssskram/authz'
import Spinner from '.'
import Layout from '.'

const App = () => {
    return (
        <Auth
          appVersion={version}
          intercomBubble={<IntercomBubble />}
          required={true}
          loadingScreen={<LoadingScreen />}
        >
            <Layout>
        </Auth>
    )
};
type props = {
  auth?: Auth;
};

const Layout = (props: props) => {
  // props.auth contains the user info and actions
  return <></>;
};

With a store

If, on return from Auth0, the user data & actions need to be persisted in a state container (mobx, redux), this can be faciltated through explicit props:

import Auth from '@ssskram/authz';
import useRootStore from 'utils/useRootStore';
import Spinner from '.';
import Layout from '.';

const App = () => {
  const { auth } = useRootStore();

  return (
    <Auth
      appVersion={version}
      intercomBubble={<IntercomBubble />}
      required={true}
      loadingScreen={<LoadingScreen />}
      logout={(l: () => void) => userStore.setLogoutAction(l)}
      idToken={(t: string) => firebaseAuth(t)}
    >
      <Layout />
    </Auth>
  );
};

Props

PropTypeRequiredDescription
requiredbooleanYesIf auth & access control are required, will automatically kick off the flow. Otherwise it needs to be triggered manually
appVersionstringYesCurrent app version to display in badge on loading screen
loadingScreencomponentYesSomething to render while it's working
intercomBubblecomponentYesWrapper for intercom service, so it's available on the auth screens as well
logoutfuncNoPassed a function to ingest logout action into app state
idTokenfuncNoPassed a function to ingest Auth0 ID JWT for Firebase auth

Develop

Install dependencies

yarn

Run Storybook

yarn storybook

Build & Release

Build

yarn build

Release

yarn release

License

MIT © Modulz

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

0.9.0-local

4 years ago

0.5.0-local

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.7.0-local

4 years ago

0.9.8

4 years ago

0.9.7

4 years ago

0.9.9

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.8.0-local

4 years ago

0.4.0

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.0

5 years ago