http-cas-client provides a comprehensive Central Authentication Service (CAS) client middleware for Node.js environments, supporting CAS 1.0, 2.0+, and 3.0+ protocols. As of version 0.4.3, it offers core features like Single Sign-On (SSO), CAS Proxy capabilities (including proxy chain checking), and Single Logout (SLO). The library is designed to be framework-agnostic, providing direct integration with Node's native `http` module and specific wrappers for popular frameworks like Koa2, with support for both session-based and no-session modes. While actively maintained, the package is still in a pre-1.0 state, indicating potential for further evolution before a stable API is declared. Key differentiators include its explicit support for various CAS protocol versions and its flexibility in integration patterns, including cluster-friendliness (though this feature is marked 'TODO' in the README) and principal adaptation for debugging.
npm install http-cas-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic CAS client integration with Node.js's native HTTP server, authenticating users and accessing their principal information.
Ensure `koa-bodyparser` is registered *before* the `http-cas-client` middleware in your Koa application's middleware chain.
For modern ESM projects, use `import` statements and ensure your `tsconfig.json` and `package.json` (type: 'module') are configured correctly for module resolution. If issues arise, consider transpilation or using the `require` syntax temporarily if your project supports both.
Set `serverName` to the complete base URL of your application, e.g., `'http://localhost:3000'` or `'https://your-domain.com'`. Ensure it's reachable by the CAS server.
Pin your dependency to an exact version (`~0.4.3` instead of `^0.4.3`) and review release notes carefully when upgrading to newer minor versions.
Ensure you are importing the correct module: `const httpCasClient = require('http-cas-client');` for native HTTP, or `const koaCasClient = require('http-cas-client/wrap/koa2');` for Koa.Double-check that `casServerUrlPrefix` points to the correct base URL of your CAS server and `serverName` is the exact, publicly accessible URL of your Node.js application.
Install Koa (`npm install koa`) and ensure it's imported at the top of your file (`const Koa = require('koa');` or `import Koa from 'koa';`).