Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

authorize-me

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authorize-me

Supplies an express middleware function that determines whether an HTTP request needs further authentication

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

authorize-me

Supplies an Express middleware function that flags specified paths to which one can then react to differently than other paths. A common use-case for this package is identifying when and when not to require user authorization on an express server. Though this is the purpose for building this package, it has been abstracted to be more versatile.

Parameters

options - The options parameter is an object that may include any of the following properties: (NOTE: only the properties supplied will take effect. For example, An object with only a base_path property will do nothing.)

  • base_path: a string that supplies the base_path of the api before any path string.
  • paths: an array of strings of paths. The base_path will be concatenated before all paths if it is supplied. If supplied, it will raise the flag on any request matching the supplied path(s).
  • methods: an array of strings of http methods. They must be in all caps. If supplied, it will raise the flag on any request matching supplied method(s).
  • [any http method]: an array of strings of paths. The property here must be capitalized (ex: 'PUT') followed by an array of paths to flag. When a request is made that matches both the method and a path in the array, the flag will be raised.
  • execute: a function that executes for every flagged request received.
Example:
const auth = require('authorize-me');

app.use(auth.check({
  base_path: '/domains/foo/bar',
  GET: ['/:baz/logs'],
  PUT: ['/:baz'],
  POST: ['/'],
  DELETE: ['/:baz'],
  execute: () => console.log('Function executed')
}));

Any of the paths mentioned in the options passed in to the middleware function will cause the function to be executed and print "Function executed" to the console. The property "flagged" will appear on the request object with the following schema:

{
    [req.method]: [req.path]
}

If the request method and/or path do not match those specified, the "flagged" property will be null.

FAQs

Package last updated on 15 Sep 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc