Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
cantina-app-users
Advanced tools
Provides a basic, extensible user system for a cantina application. Includes the user model (with an extensible default schema), authentication, and default email templates for basic user account-related emails.
Most of the provided defaults are easily overridden via configuration (etc
) or
application hooks (app.hook
). Default email templates can be overridden by
providing an alternative template having the same name.
Provides the default user schema.
module.exports = function (app) {
app.Schema.extend(app.schemas.user, {
properties: {
someprop: {
type: 'string',
default: '',
required: true
}
}
});
};
Provides the default admin user, Web Team dev@terraeclipse.com, with password "admin".
# In etc/app/users.yml
admin:
attributes:
username: webteam
password: ryd9ebyz
Provides schemas for cantina-models
See cantina-models-schemas for details.
Provides a standard implementation of the functionality required by cantina-auth, as well as session management.
module.exports = function (app) {
var controller = app.controller();
controller.post('/login', function (req, res, next) {
if (!req.body) {
return next(new Error('Invalid post data'));
}
if (!req.body.email || !req.body.pass) {
res.formError('login', 'Email and password are both required.');
return next();
}
app.collections.users.findByAuth(req.body.email.trim(), req.body.pass, function (err) {
if (err) {
res.formError('login', err.message);
return next();
}
res.redirect('/');
});
}
controller.post('/logout', function (req, res, next) {
app.auth.logOut(req, function (err) {
if (err) return res.renderError(err);
res.redirect('/login');
});
});
return controller;
};
module.exports = function (app) {
app.hook('model:destroy:user', function (user, next) {
// Kill the user's active sessions
app.auth.killSession(user, next);
});
};
Provides templates and hooks for cantina-email user account related emails.
Provides defaults for:
Your application may override any of these by providing its own template with the same name.
Adds a hook to email:send:before
for the email templates above.
The hook will perform the following:
prefix
: Defaults to "password-reset"
for users/password_reset
template, "account"
for all others. Your application may override this
by setting vars.preset
in the app.email.send
vars.expire
: Defaults to 24 hours for users/password_reset
template,
7 days for all others. Your application may override this by setting
vars.expire
in the app.email.send
vars.vars.app
app.conf.get('app')
.app.title
app.email
vars.app
in the
app.email.send
vars.vars.url
app.protocol
, app.domain
, and a pathname
appended with the generated token. The pathnames are:
/forgot/{token}
/account-confirm/{token}
/email-confirm/{token}
/account-invitation/{token}
Your application may override this by setting vars.pathname
or vars.url
in the
app.email.send
vars.app.collections.users
Exentded namespace for user models
app.collections.users.findByAuth(email, password, cb)
Load user with matching email from the database and verifies password. Returns a sanitized user model, if match is found.
app.auth
Namespace for authentication-related API
app.auth.logIn(user, req, res, next)
Invokes req.logIn
and adds the req.sessionID
to a set of sessionIDs for the
user in redis.
app.auth.setPassword(user, password, cb)
Sets the auth property on the user model to be a bcrypt
hash of the password
app.auth.checkPassword(user, password, cb)
Checks the password against the user's auth property using bcrypt.compare
app.auth.killSession(user, sessionID, cb)
Destroys the session and removes the sessionID from user's set in redis.
app.auth.killAllSessions(user, cb)
Loads the user's sessionIDs from redis and destroys each. Deletes the user's set of sessionIDs in redis.
app.auth.logOut(req, cb)
Invokes req.logOut
and app.auth.killSession
for the authenticated user
app.serializeUser(user, cb)
Implements user serialization for cantina-auth. Returns the user model's id
property.
app.deserializeUser(id, cb)
Implements user deserialization for cantina-auth. Loads and returns the user
with matching id
in app.collections.user
.
app.verifyTwitterUser(token, tokenSecret, profile, done)
Implements account verification for cantina-auth-twitter. Creates or updates
the existing user account with matching email
on app.collections.user
.
app.verifyFacebookUser(token, tokenSecret, profile, done)
Implements account verification for cantina-auth-facebook. Creates or updates
the existing user account with matching email
on app.collections.user
.
Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.
FAQs
Drop-in users system for Cantina apps
The npm package cantina-app-users receives a total of 3 weekly downloads. As such, cantina-app-users popularity was classified as not popular.
We found that cantina-app-users demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.