@uconn-its/passport-uconn
v1.2.1
Published
Passport Strategy for UConn CAS Authentication
Downloads
6
Readme
passport-uconn
This is a custom Passport.js authentication strategy for integrating with UConn's SSO implementation.
Installation
Use npm to install passport-uconn.
npm install @uconn-its/passport-uconn
Usage
import passport from 'passport';
import { CasStrategy } from '@uconn-its/passport-uconn';
passport.use(new CasStrategy({
serverBaseURL: 'https://endpoints.its.uconn.edu',
serviceURL: 'https://endpoints.its.uconn.edu/login',
passReqToCallback: false
}, async (req, profile, done) => {
// Do any additional verification on the CAS user with the profile variable (ex: check groups)
// Deny User
if (profile.user === 'jpr21010') {
return done(null, false, {
message: 'You are banned from this app'
});
}
// Error during logic
if (anErrorHappens) {
return done(new Error('An error occurred while getting something'), null);
}
// Approve User
return done(null, {
netId: profile.user,
someCustomSessionProp: profile.someValue,
foo: 'bar'
});
}));
passport.authenticate('cas', ...);
Publishing
To publish an update to this package follow these steps;
- Make sure your git directory is clean by commiting or stashing all changes.
- Move the
.env.example
to.env
and change theNPMRC_TOKEN
variable to a token with access to@uconn-its
(Found in LastPass underITS WebDev -- NPM/uconn-its NPM Access Token
). - Increment the package version by either manually changing the
package.json
file or runningnpm version <major/minor/patch>
. - Publish the package to the registry by running
npm publish
. (Note: If you get a 404 error, simply runnpm publish
again.)