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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-cas

v1.0.12

Published

simple CAS for nodeJS

Readme

simple-cas

This module take inspiration from simple-cas-interface and connect-cas to create a middleware for express that is easy to use as well as dynamic in term of url redirection so that complicated route can be correctly redirected. simple-cas support basic authentication for CAS 1.0 to CAS 3.0. if none is declared in the configuration process, CAS 2.0 will be used.

CAS(Central Authentication Service) is a single-sign-on / single-sign-off protocol for the web.

We suppose you are already familiar with the CAS protocol, if not, please read this document before you use this.

Install

npm install simple-cas

Feature

  1. Non-proxy mode CAS login/logout
  2. Single sign off

Quick start

const express = require('express');
const url = require('url');
const session = require('express-session');
const CAS = require('simple-cas');

CAS.configure({ host: 'your.cas.domain.host', service: 'http://localhost:3000/' });
const app = express();

// Use cookie sessions for simplicity, you can use something else
app.use(session({
  secret: 'supersecuretext',
  resave: false,
  saveUninitialized: true,
}));

app.get('/', (req, res) => {
  if (req.session.cas && req.session.cas.user) {
    return res.send(`<p>You are logged in. Your username is ${req.session.cas.user}. <a href="/logout">Log Out</a></p>`);
  }
  return res.send('<p>You are not logged in. <a href="/login">Log in now.</a><p>');
});

app.get('/login', CAS.authenticate(CAS.configure(), 'login'), (req, res) => {
  res.redirect('/');
});

// you can also set CAS configurations dynamically within other middleware using req.data object
// you can set req.data.host, and req.data.service and req.data.protocolVersion
// your settings will remains for every request afterward, and everywhere else in this app.
app.get('/login', (req, res, next) => {
  req.data = {};
  req.data.host = 'your.cas.domain.host';
  req.data.service = 'http://localhost:3000/';
  next();
},CAS.authenticate(CAS.configure(), 'login') ,(req, res) => {
  res.redirect('/');
});

app.get('/logout', (req, res) => {
  if (!req.session) {
    return res.redirect('/');
  }
  // Forget our own login session
  if (req.session.destroy) {
    req.session.destroy();
  } else {
    // Cookie-based sessions have no destroy()
    req.session = null;
  }
  // Send the user to the official campus-wide logout URL
  const options = CAS.configure();
  // set logout url
  options.pathname = options.paths.logout;
  // set return url after logout
  options.query = options.query || {};
  options.query.service = options.service;
  return res.redirect(url.format(options));
});

app.listen(3000);

Configuration

To initialize simple-cas configurations.


const CAS = require('simple-cas');

CAS.configure({ host: 'your.cas.domain.host', service: 'http://localhost:3000/' });

simple-cas default configurations are as follow.

const defaults = {
  protocol: 'https',
  host: undefined,
  port: 443,
  service: undefined,
  protocolVersion: 2.0, // default to 2.0
  validateTicketProtocol: protocol2, // default to 2.0 CAS ticket parsing
  paths: {
    serviceValidate: '/cas/serviceValidate', // default to 2.0 route
    login: '/cas/login',
    logout: '/cas/logout',
  },
};

License

MIT