Skip to content

ComfyUI Extension for Advanced Security. Implements login, multi-user registration, IP filtering, and user-specific input/output directories.

License

Notifications You must be signed in to change notification settings

LucipherDev/ComfyUI-Sentinel

Repository files navigation

ComfyUI Sentinel Logo

ComfyUI Sentinel

ComfyUI Extension for Advanced Security. Implements login, multi-user registration, IP filtering, and user-specific input/output directories.

☢️ This is still under development. Use at your own risk. ☢️

Jump to Section

Installation

  1. Navigate to your ComfyUI custom_nodes directory:
cd ComfyUI/custom_nodes
  1. Clone this repository:
git clone https://github.com/LucipherDev/ComfyUI-Sentinel
  1. Install dependencies:
cd ComfyUI-Sentinel
pip install -r requirements.txt

Or Install via ComfyUI Manager

Setup

  1. Edit config.json according to your preferences:

    • secret_key_env: Name of the environment variable for the secret key used to encrypt JWT tokens. If no secret key is set, a random key will be generated.
      • Type: str
      • Default: SECRET_KEY
    • users_db: Name of the user database file.
      • Type: str
      • Default: users_db.json
    • access_token_expiration_hours: Duration (in hours) for which JWT tokens remain valid.
      • Type: number
      • Default: 12
    • log: Name of the log file.
      • Type: str
      • Default: sentinel.log
    • log_levels: Message levels to log.
      • Type: str
      • Options: ["INFO", "WARNING", "ERROR", "DEBUG"]
      • Default: ["INFO"]
    • whitelist: List of allowed IPs.
      • Type: str
      • Default: whitelist.txt
    • blacklist: List of blocked IPs.
      • Type: str
      • Default: blacklist.txt
    • blacklist_after_attempts: Number of failed login attempts before an IP is blacklisted (0 to disable).
      • Type: int
      • Default: 0
    • free_memory_on_logout: Free memory when a user logs out.
      • Type: bool
      • Default: false
    • force_https: Force ComfyUI to use HTTPS.
      • Type: bool
      • Default: false
    • separate_users: Isolate user input/output and queue history. *Experimental
      • Type: bool
      • Default: false
    • manager_admin_only: Control who can access ComfyUI Manager
      • Type: bool
      • Default: false
  2. Run ComfyUI

  3. Access the GUI URL

  4. Register the admin account

Done!

Forgot Admin Password?

  • Delete the database file and start over.

OR

  • Remove the admin user and promote an existing user to admin by adding "admin": true to their profile.

To remove Sentinel, delete the ComfyUI-Sentinel folder or uninstall via ComfyUI Manager.

Features

  • Admin Registration

    • Upon the first run, register an admin user with full access and management capabilities.

admin-register-page

  • User Registration

    • Admins can register new users and assign credentials.

register-page

  • User Login

login-page

  • Logout

    • A discreet logout button is available.

logout-button

  • Timeout Protection

    • Implements a timeout for IP addresses after too many failed login/register attempts. Maximum timeout is 5 minutes unless blacklist_after_attempts > 0, in which case the IP will be blacklisted.

failed-attempts

  • IP Filtering

    • Filters IP addresses based on whitelist/blacklist rules.
      • If a whitelist exists, only those IPs will be allowed.
      • Otherwise, blacklisted IPs will be blocked.
  • Separate Users *Experimental

    • Each user has an isolated input/output directory and queue history. Folder access is restricted accordingly. Still under development but fairly functional. Use at your own risk
  • ComfyUI Manager Access

    • If turned on, only the admin user will be able to access the ComfyUI Manager Extension.

ToDo

  • Check custom nodes for malicious code

API Access

All API calls to the ComfyUI server require authentication. You can:

  • Include the authentication token in headers: Authorization: Bearer eyJhbGci...
  • Include it as a cookie named jwt_token in the request.

Register

Endpoint: POST /register

Request Body:

{
  "new_user_username": "your_username",
  "new_user_password": "your_password",
  "username": "admin_username",   // Required if admin exists
  "password": "admin_password"    // Required if admin exists
}

Login

Endpoint: POST /login

Request Body:

{
  "username": "your_username",
  "password": "your_password"
}

⚠️ Disclaimer

While ComfyUI Sentinel enhances security for ComfyUI, it does not guarantee absolute protection. Security is about risk mitigation, not elimination. Users are responsible for implementing their own security measures.

Use at your own discretion.

About

ComfyUI Extension for Advanced Security. Implements login, multi-user registration, IP filtering, and user-specific input/output directories.

Topics

Resources

License

Stars

Watchers

Forks