1.0.0-rc.31 • Published 11 months ago

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

Weekly downloads
-
License
MIT
Repository
-
Last release
11 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.31

11 months ago

1.0.0-rc.30

1 year ago

1.0.0-rc.29

1 year ago

1.0.0-rc.28

1 year ago

1.0.0-rc.27

1 year ago

1.0.0-rc.25

2 years ago

1.0.0-rc.24

2 years ago

1.0.0-rc.23

2 years ago

1.0.0-rc.22

2 years ago

1.0.0-rc.20

2 years ago

1.0.0-rc.21

2 years ago

1.0.0-rc.17

2 years ago

1.0.0-rc.16

2 years ago

1.0.0-rc.15

2 years ago

1.0.0-rc.14

2 years ago

1.0.0-rc.19

2 years ago

1.0.0-rc.18

2 years ago

1.0.0-rc.13

3 years ago

1.0.0-rc.12

3 years ago

1.0.0-rc.11

3 years ago

1.0.0-rc.10

3 years ago

1.0.0-rc.9

3 years ago

1.0.0-rc.8

3 years ago

1.0.0-rc.7

3 years ago

1.0.0-rc.6

3 years ago

1.0.0-rc.5

3 years ago

1.0.0-rc.4

3 years ago

1.0.0-rc.3

3 years ago

1.0.0-rc.2

3 years ago