Node.js server authentication application for Couchdb NoSQL database
- Session based setup each login is given an access token
name:passwhich the user can use to access the database directly, this token can be later revoked, disallowing access for the specified application/device. - Simplified and easily extendable setup can be used with other NoSQL databases
- Using the latest and fastest API's for Node.js including fastify web framework and undici HTTP client
- Using fastify's auto directory scan for auto page addition
- Account creation, activation, modification and deletion.
Copy the source code to your Node.js project then install the packages used.
Modify .env and it declared options
ADDRESS = "http://127.0.0.1:5984" //| address of database
USERS_DB = "x-users" //| database name to be used for sessions
COUCHDB_AUTH = "YWRtaW46YWRtaW4=" //| base64 encoded `name:password` of the admin// POST /auth/register
{
name,
email,
password
}
// RETURN
{
ok: true
}// POST /auth/login
{
email,
password
}
// RETURN session generated info
{
ok: true,
token: name::password
}will delete all active session for the user.
// POST auth/delete/sessions
{
name,
password
}will generat delete token that can be emailed for confirmation
// POST auth/delete/account
{
name,
password
}More can be seen inside /routes directory.