@exobase/use-basic-auth
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.31 • Public • Published

title: 'useBasicAuth' description: 'A basic authentication hook' group: 'Hooks' badge: 'Auth'

Provides a Exobase hook function that will parse out the client id and client secret of an incoming request

NOTE: This hook does not validate the values it parses, you'll need to do that on your own

Install

yarn add @exobase/use-basic-auth
# or
yarn add @exobase/hooks

Import

import { useBasicAuth } from '@exobase/use-basic-auth'
// or
import { useBasicAuth } from '@exobase/hooks'

Usage

You can use useBasicAuth to parse the client id and client secret from the request. You'll need to validate them yourself.

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useNext } from '@exobase/use-next'
import { useBasicAuth, BasicAuth } from '@exobase/use-basic-auth'

export const securePingEndpoint = async ({
  auth
}: Props<{}, {}, BasicAuth>) => {
  console.log(auth) // { clientId: 'abc', clientSecret: 'abc' }
  return {
    message: 'pong'
  }
}

export default compose(useNext(), useBasicAuth(), securePingEndpoint)

In order to keep auth logic out of your endpoints you'll probably want to create a custom hook function to validate

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.0-rc.3138latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.0-rc.3138
1.0.0-rc.3037
1.0.0-rc.290
1.0.0-rc.280
1.0.0-rc.270
1.0.0-rc.250
1.0.0-rc.240
1.0.0-rc.230
1.0.0-rc.220
1.0.0-rc.210
1.0.0-rc.200
1.0.0-rc.190
1.0.0-rc.180
1.0.0-rc.170
1.0.0-rc.160
1.0.0-rc.150
1.0.0-rc.140
1.0.0-rc.130
1.0.0-rc.121
1.0.0-rc.111
1.0.0-rc.100
1.0.0-rc.90
1.0.0-rc.80
1.0.0-rc.70
1.0.0-rc.60
1.0.0-rc.53
1.0.0-rc.40
1.0.0-rc.30
1.0.0-rc.20

Package Sidebar

Install

npm i @exobase/use-basic-auth

Weekly Downloads

77

Version

1.0.0-rc.31

License

MIT

Unpacked Size

18.3 kB

Total Files

17

Last publish

Collaborators

  • rayepps