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

authenticated

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

authenticated

ensure a request is authenticated

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

authenticated

ensure a request is authenticated

example usage

Default behavior is to redirect to login:

var authenticated = require('authenticated')

app.get('/secret-recipe',
  authenticated,
  function (req, res) {
    // note, you still might want to do
    // some sort of authorization, which
    // is out of this module's scope
    res.send(secrets)
  })

Respond with 401:

app.get('/secret-recipe',
  authenticated.or401,
  function (req, res) {
    res.send(secrets)
  })

Override custom behavior for unauthenticated requests:

app.get('/secret-recipe',
  authenticated.orElse(function (req, res) {
      // some other behavior
      res.send('decoy recipe')
  }),
  function (req, res) {
    res.send(secrets)
  })

note

We currently check for authenticated requests by looking for req.session.passport.user._id, which happens to work in our particular use case. This is super inflexible. Please open a GitHub thread with your use case or suggestion for making this check better.

installation

$ npm install authenticated

running the tests

From package root:

$ npm install
$ npm test

contributors

jden jason@denizac.org

license

MIT. (c) 2013 Agile Diagnosis hello@agilediagnosis.com. See LICENSE.md

Keywords

FAQs

Package last updated on 01 May 2013

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