
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
nanoweb-auth
Advanced tools
Nanoweb authorization package for utilizing users functions in different storage providers such as files, SQL and NOSQL databases.
Sure! Here's a comprehensive documentation for the nanoweb-auth project:
nanoweb-auth is a modular authentication library designed to provide a flexible and extensible authentication system. It supports multiple storage backends, such as file system, MariaDB, and Redis, and allows for easy integration into existing applications.
npm install nanoweb-auth
First, set up the provider you want to use. nanoweb-auth comes with three built-in providers: FileSystemProvider, MariadbProvider, and RedisProvider.
const { FileSystemProvider } = require('nanoweb-auth/providers');
const provider = new FileSystemProvider('/path/to/storage/directory');
const mariadb = require('mariadb');
const { MariadbProvider } = require('nanoweb-auth/providers');
const connection = await mariadb.createConnection({
host: 'localhost',
user: 'root',
password: 'password',
database: 'auth_db'
});
const provider = new MariadbProvider(connection);
const redis = require('redis');
const { RedisProvider } = require('nanoweb-auth/providers');
const client = redis.createClient();
await client.connect();
const provider = new RedisProvider(client);
Create a new instance of the Manager class with the chosen provider.
const { Manager } = require('nanoweb-auth');
const manager = new Manager(provider);
const userData = {
login: 'john_doe',
name: 'John Doe',
email: 'john.doe@example.com',
password: 'securepassword',
accessMap: { '*': 'r' } // Read-only access to all endpoints
};
const user = await manager.addUser(userData);
console.log('User added:', user);
const updatedUserData = {
name: 'Johnathan Doe',
email: 'john.doe@example.com',
password: 'newsecurepassword',
accessMap: { '*': 'rw' } // Read-write access to all endpoints
};
const updatedUser = await manager.updateUser('john_doe', updatedUserData);
console.log('User updated:', updatedUser);
const success = await manager.deleteUser('john_doe');
console.log('User deleted:', success);
const user = await manager.loadUser('john_doe');
const token = manager.createToken(user);
console.log('Token created:', token);
const refreshedToken = manager.refreshToken('existing_token_id');
console.log('Token refreshed:', refreshedToken);
const user = await manager.loadUser('john_doe');
const hasAccess = user.hasAccess('/some/protected/resource', 'r'); // Check for read access
console.log('User has access:', hasAccess);
Manager instance with the specified provider.FileSystemProvider instance with the specified directory and context.MariadbProvider instance with the specified connection.RedisProvider instance with the specified client.The nanoweb-auth library includes comprehensive tests for each provider. To run the tests, use the following command:
npm test
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
This project is licensed under the MIT License. See the LICENSE file for details.
This documentation provides a comprehensive overview of the nanoweb-auth project, including installation instructions, usage examples, API reference, and testing guidelines.
FAQs
Nanoweb authorization package for utilizing users functions in different storage providers such as files, SQL and NOSQL databases.
We found that nanoweb-auth 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
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.