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

hapi-ntlm

v1.0.9

Published

An hapi authentication strategy to hanlde NTLM-authentication.

Downloads

4

Readme

NPM version

hapi-ntlm

An hapi authentication strategy to hanlde NTLM-authentication.

This module use ntlm-ad-client under the hood and is heavily inspired by express-ntlm written by Fabio Poloni

install

$ npm install hapi-ntlm

example usage - auth.js

exports.register = (server, options, next) => {

  let domain = 'YOUR_DOMAIN';
  let hostname = 'YOUR_AD_HOSTNAME';
  let port = 'YOUR_AD_POST';
  let path = null;
  let use_tls = false;
  let tls_options = undefined;

  const generateInfo = async (request, reply, result) => {
    return await Promise.resolve('info');
  }

  let authOptions = {
      domain,
      hostname,
      port,
      path,
      use_tls,
      tls_options,
      generateInfo
  }

  server.auth.strategy('ntlm-auth-strategy', 'ntlm', false, authOptions);

  server.route({
      method: 'GET',
      path: '/',
      config: {
          auth: 'ntlm-auth-strategy'
      },
      handler: (request, reply) => {
          reply({
              'msg': request.auth.credentials
          }).code(201);
      }
  });

  next();
};

exports.register.attributes = {
  name: 'auth',
  version: '0.0.1'
}

example usage - server.js

const PORT = 3000
const HOSTNAME = '127.0.0.1'

const Hapi = require('hapi');
const server = new Hapi.Server();

function build(cb) {
    server.connection({
        host: HOSTNAME,
        port: PORT
    });

    server.register([
        require('hapi-ntlm'),
        require('./auth')  
    ], (err) => {
        cb(err, server);
    });
}

build((err, server) => {
    if (err) {
        console.error(err);
        throw err;
    }
    server.start((err) => {
        if (err) {
            throw err;
        }
        console.info('Server running at:', server.info.uri);
    });
});

options

| Name | type | description | |------|------|-------------| | hostname | string | Hostname of the Active Directory. | | port | string | Port of the Active Directory. | | domain | string | Default domain if the DomainName-field cannot be parsed. | | path | string | Base DN. not implemented yet | | use_tls | boolean | Indicates wether to use TLS or not. | | tls_options | object | An options object that will be passed to | | generateInfo | function | An async function to generate extra user info | tls.connect and tls.createSecureContext. Only required when using ldaps and the server's certificate is signed by a certificate authority not in Node's default list of CAs. (or use NODE_EXTRA_CA_CERTS environment variable)| | tls_options.ca | string / array / Buffer | Override the trusted CA certificates provided by Node. Refer to tls.createSecureContext |