esogr-custom

Custom n8n nodes for authentication, caching, and access control

Package Information

Downloads: 1,192 weekly / 1,192 monthly
Latest Version: 0.1.14
Author: Thomas Løvdahl

Documentation

n8n-nodes-custom-auth

Custom n8n nodes for authentication, caching, and access control.

Nodes

Menu Role Auth

A node that handles menu-based role authentication with Redis caching. This node:

  • Fetches menu role permissions from PostgreSQL database
  • Caches permissions in Redis for performance (default: 6 hours TTL)
  • Checks user access based on menu item IDs and user roles
  • Routes to two outputs: Access Granted or Access Denied
  • Returns access control flags (access, limit_org, limit_user, limit_readonly)

Operations

  1. Check Access - Check if user roles have access to specified menu items
  2. Refresh Cache - Force refresh the menu roles cache from database

Outputs

The node has two outputs:

  • Output 1 (Access Granted) - Items where access check passed
  • Output 2 (Access Denied) - Items where access check failed

This allows you to easily route denied requests to return a 403 response via webhook.

Input Parameters

Parameter Type Description
Menu Item IDs Array/String Menu item IDs to check access for
Roles Array/String User role short IDs to check
Cache Key String Redis key for caching (default: postgres_cache_base_menuroles)
Cache TTL Number Cache time-to-live in seconds (default: 21600 = 6 hours)
Schema String PostgreSQL schema name (default: public)
Table String Table name for menu roles (default: base_menuRoles)

Output

{
  "accesscontrol": {
    "access": true,
    "limit_org": false,
    "limit_user": false,
    "limit_readonly": false
  },
  // ... original input data (if passThrough enabled)
}

Credentials

This node uses n8n's built-in credentials:

  • Redis - Select from your existing Redis credentials
  • PostgreSQL - Select from your existing PostgreSQL credentials

No custom credential configuration needed - just select your pre-configured credentials from the dropdown.

Installation

Local Development

  1. Clone this repository
  2. Install dependencies: npm install
  3. Build the nodes: npm run build
  4. Link to your n8n installation:
    cd ~/.n8n/custom
    npm link /path/to/n8n-custom-nodes
    
  5. Restart n8n

Production

# In your n8n custom nodes directory
npm install @thomlov81/n8n-nodes-custom-auth

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Lint
npm run lint

# Format
npm run format

Database Schema

The node expects a base_menuRoles table with the following structure:

CREATE TABLE base_menuRoles (
  id SERIAL PRIMARY KEY,
  menuId INTEGER NOT NULL,
  role_short_id VARCHAR(50) NOT NULL,
  limit_org BOOLEAN DEFAULT false,
  limit_user BOOLEAN DEFAULT false,
  limit_readonly BOOLEAN DEFAULT false,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Example Workflow

[Webhook] → [Menu Role Auth] → [Access Granted] → [Your Logic]
                            ↘ [Access Denied] → [Respond 403]

License

MIT

Discussion