1.0.0-rc.30 • Published 3 months ago

@exobase/use-basic-auth v1.0.0-rc.30

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

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

1.0.0-rc.30

3 months ago

1.0.0-rc.29

3 months ago

1.0.0-rc.28

3 months ago

1.0.0-rc.27

3 months ago

1.0.0-rc.25

1 year ago

1.0.0-rc.24

1 year ago

1.0.0-rc.23

1 year ago

1.0.0-rc.22

1 year ago

1.0.0-rc.20

1 year ago

1.0.0-rc.21

1 year ago

1.0.0-rc.17

1 year ago

1.0.0-rc.16

1 year ago

1.0.0-rc.15

1 year ago

1.0.0-rc.14

1 year ago

1.0.0-rc.19

1 year ago

1.0.0-rc.18

1 year ago

1.0.0-rc.13

1 year ago

1.0.0-rc.12

1 year ago

1.0.0-rc.11

1 year ago

1.0.0-rc.10

1 year ago

1.0.0-rc.9

1 year ago

1.0.0-rc.8

1 year ago

1.0.0-rc.7

1 year ago

1.0.0-rc.6

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.4

2 years ago

1.0.0-rc.3

2 years ago

1.0.0-rc.2

2 years ago