fastify-basic-auth icon indicating copy to clipboard operation
fastify-basic-auth copied to clipboard

Add example of how to add credentials to request to README

Open gertminov opened this issue 3 years ago • 1 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

Add a simple example of how to add credentials to a request, to make it easier for beginners to use the plugin.

It's my first Issue so im sorry if i did something wrong

Motivation

it is unclear, where this plugin gets its the username and password from, if one is not familiar with how authorisation works

Example

How to add Credentials to request

The basic-auth plugin retrieves the credentials from the Authorization header.

        const credentials: string = Buffer.from("username:password").toString('base64')
       request.header("Authorisazion", "Basic " + credentials)

gertminov avatar Mar 28 '22 18:03 gertminov

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

Eomm avatar Mar 28 '22 20:03 Eomm