Socket
Socket
Sign inDemoInstall

joi-authorization-header

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    joi-authorization-header

Joi object for validating a request authorization header


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
8.30 kB
Created
Weekly downloads
 

Readme

Source

joi-authorization-header

A request authorization header validator for Joi.

Build Status

use

joi-authorization-header validates an object contains an "authorization" property whose value is a string of the specified length, optionally prefixed with "Bearer " or "bearer ". It's used just like you'd use any other Joi type.

var Joi = require('joi');
Joi.authHeader = require('joi-authorization-header')(Joi);
Joi.validate(request.headers, Joi.authHeader(64));

specifying value length

You must specify the length requirements of your authorization header value or an Error will be thrown. It's easiest to explain by showing some examples:

var Joi = require('joi');
Joi.authHeader = require('joi-authorization-header')(Joi);

Joi.authHeader(64);    // header must be exactly 64 characters in length
Joi.authHeader(2, 20); // header must be between 2 and 20 characters in length (inclusive)

The length validators do not include the optional "Bearer " value prefix.

// Joi.validate({ authorization: "Bearer 1234" }, Joi.authHeader(4)) // pass
// Joi.validate({ authorization: "Bearer 234" }, Joi.authHeader(4))  // fail
// Joi.validate({ authorization: "1234" }, Joi.authHeader(4)) // pass
// Joi.validate({ authorization: "234" }, Joi.authHeader(4))  // fail

Installation

npm install joi-authorization-header --save

Development

running tests
  • npm test

Sponsored by

Pebble Technology!

License

MIT

Keywords

FAQs

Last updated on 18 Sep 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc