1.0.0 • Published 2 years ago

@barejs/auth-provider v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 years ago

@barejs/auth-provider

An authentication provider for bareASGI-auth-server.

When the component is mounted it attempts to gather credentials for the whoamiPath link. If this fails the app is redirected to the loginPath link with the current url passed as the query arg to allow the login app to redirect back to this page.

On success the renderer prop is called with authFetch (a fetch implementation that will redirect if the app server responds with 401 - unauthenticated) and authCredentials (the authentication credentials provided by a GET to whoamiPath).

Example

import React, { Component } from 'react'

import { createTheme, ThemeProvider } from '@mui/material/styles'

import { AuthenticatedApp } from '@barejs/auth-provider'

const Site = (authFetch, authCredentials) => <div>An authenticated site</div>

const theme = createTheme()

class App extends Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <AuthenticatedApp
          loginPath="/auth/ui/login"
          whoamiPath="/auth/api/whoami"
          renderer={props => <Site {...props} />}
        />
      </ThemeProvider>
    )
  }
}

export default App
1.0.0

2 years ago

1.0.0-rc1

2 years ago

1.0.0-rc2

2 years ago

1.0.0-rc3

2 years ago

0.5.0

2 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago