npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

passport-negotiate

v0.1.4

Published

Negotiate (kerberos) authentication strategy for Passport.

Downloads

986

Readme

passport-negotiate

Negotiate (Kerberos) single-sign-on authentication strategy for Passport.

This Passport strategy implements authentication of users implementing "HTTP Negotiate", or SPNEGO auth-scheme, as described in RFC 4559.

For this to work, clients (browsers) must have access to a "credentials cache", which happens when logging in to a Domain in Windows, or in Linux/Unix either by using the "kinit" tool directly, or by using PAM modules which do this at login time, for example using sssd with a kerberos DC or Active Directory Domain Controller such as Samba 4.

When "Negotiate" is requested by the server, via a "WWW-Authenticate: Negotiate" header and a 401 response, the browser will obtain credentials in the form of a "ticket". The browser will then re-request the resource with the ticket data provided in the "Authorization: Negotiate .....". This happens transparently to the user.

Node.js can also be made to work as a negotiate enabled client, see this Gist.

Install

$ npm install passport-negotiate

Usage

Configure Strategy

The kerberos authentication strategy authenticates users using a username and password. The strategy requires a verify callback, which accepts the user's kerberos principal and calls done providing a user. Kerberos principals typically look like user@REALM.

var NegotiateStrategy = require("passport-negotiate");
passport.use(new NegotiateStrategy(function(principal, done) {
    User.findOne({ principal: principal }, function (err, user) {
        return done(err, user);
    });
  }
));

There are some quirks worth noting:

  1. You must not use failureRedirect when using the authentication method as middleware, because the strategy must generate a 401 status response with a specific header (WWW-Authenticate: Negotiate), which won't happen if failureRedirect is used.
  2. Kerberos authentication can succeed, but the supplied verify function cannot find a user object for the user. In this case, a noUserRedirect can be supplied which will in many respects work the way failureRedirect works for other strategies. The sample application examples/login demonstrates this. The strategy will set req.session.authenticatedPrincipal to the authenticated principal whenever kerberos authentication has succeeded regardless of the (in-)ability of the verify function to supply a user object.

S4U2Proxy (credential delegation)

The strategy can be configured to obtain delegated credentials on behalf of the authenticated user. Enable this by passing an options hash as the first argument to the strategy constructor:

passport.use(new NegotiateStrategy({enableConstrainedDelegation:true}, ...) 

The delegated credentials will be stored in a per-session credentials cache (the name of which will be set in req.session.delegatedCredentialsCache). Currently there is no code to monitor the lifetime of these credentials, so you will need to ensure the cache is not expired, and also to remove the cache file when the session is closed.

Note 1: S4U2Proxy support is currently WIP, and hasn't been rolled into an official release of the kerberos module that provides the underlying functionality. To get support for S4U2Proxy please use this fork. The authors are currently working on getting this code merged upstream.

Note 2: For S4U2Proxy credentials to be obtained, a credentials cache for the server principal (in addition to the keytab) must be established and maintained. For example, supposing the service keytab contains a credential for the principal HTTP/[email protected], then you could create a credentials cache in the default location using:

kinit -k HTTP/[email protected]

Alternatively, you could use k5start to ensure that the credentials cache is renewed and/or recreated so as to be valid over a long period of time

By default the service principal will NOT be enabled for S4U2Proxy. This wiki page on the kerberos website includes information on how to set up a principal to allow S4U2Proxy. Note: the UPN should be HTTP/myhost.example.com not host/myhost.example.com in all likelyhood.

Credits

License

The MIT License

Copyright (c) 2015 David Mansfield