The next-generation security, governance, permissions, and multiβuser control system for ComfyUI.
Version 1.9.0 β Latest release includes Extension Tabs API, IP filtering improvements, and performance optimizations
- Overview
- Key Features
- Architecture
- Installation
- Folder Structure
- RBAC Roles
- UI Enforcement Layer
- Workflow Protection
- IP Rules System
- User Environment Tools
- Settings Panel
- API Endpoints
- Backend Components
- Troubleshooting
- License
ComfyUI Usgromana is a comprehensive security layer that adds:
- RoleβBased Access Control (RBAC)
- UI element gating
- Workflow save/delete blocking
- Transparent user folder isolation
- IP whitelist and blacklist enforcement
- User environment management utilities
- A modern administrative panel with multiple tabs
- Dynamic theme integration with the ComfyUI dark mode
- Live UI popups, toast notifications, and visual enforcement
- NSFW Guard API - Public API for NSFW detection and enforcement
- Gallery integration - Manual image flagging and metadata-based tagging
- Extension Tabs API - Allow other extensions to add custom tabs to the admin panel
It replaces the older Sentinel system with a faster, cleaner, more modular architectureβfully rewritten for reliability and future expansion.
Four roles: Admin, Power, User, Guest
Each with configurable permissions stored in usgromana_groups.json.
The guest account and login can be disabled by editing config.json and changing enable_guest_account to false
Nonβprivileged roles cannot:
- Save workflows
- Export workflows
- Overwrite existing workflows
- Delete workflow files
All blocked actions trigger:
- A serverβside 403
- A UI toast popup explaining the denial
Usgromana hides or disables:
- Topβmenu items
- Sidebar tabs
- Settings categories
- Extension panels
- File menu operations
Enforcement occurs every 1 second to catch lateβloading UI elements.
Complete backend implementation:
- Whitelist mode
- Blacklist mode
- Live editing in Usgromana settings tab
- Persistent storage via
ip_filter.py
From user_env.py:
- Purge a userβs folders
- List user-owned files
- Promote user workflow to default (all user view)
- Delete single user workflow
- Toggle galleryβfolder mode
The administrative modal features:
- Transparent blurred glass background
- Neon accent tabs
- Integrated logo watermark
- Scrollable permission tables
- Responsive layout
A new middleware that detects:
- Forbidden workflow saves
- Forbidden deletes
And triggers UI-side toast popups through a custom fetch wrapper.
A comprehensive public API that allows other ComfyUI extensions to:
- Check user NSFW viewing permissions
- Validate image tensors, PIL Images, or file paths for NSFW content
- Integrate NSFW protection into custom nodes and extensions
- Metadata-based tagging system - Images are tagged with NSFW metadata stored alongside files
- Gallery integration endpoint -
/usgromana-gallery/mark-nsfwfor manual image flagging - Automatic scanning - Background scanning of output directory with caching
- Per-user enforcement - SFW restrictions apply per-user based on role permissions
See API_USAGE.md for complete documentation and examples.
Quick Example:
from api import check_tensor_nsfw, is_sfw_enforced_for_user
# In your custom node
if is_sfw_enforced_for_user():
if check_tensor_nsfw(image_tensor):
# Block or replace NSFW content
image_tensor = torch.zeros_like(image_tensor)Gallery Integration:
// Mark an image as NSFW from gallery UI
fetch('/usgromana-gallery/mark-nsfw', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
filename: 'image.png',
is_nsfw: true,
score: 1.0,
label: 'manual'
})
});ComfyUI
β
βββ Usgromana Core
β βββ access_control.py β RBAC, path blocking, folder isolation
β βββ __init__.py β Route registration, middleware setup
β βββ api.py β NSFW Guard API (public interface)
β βββ globals.py β Shared server instances, route table
β βββ constants.py β Configuration paths
β βββ routes/
β β βββ auth.py β Login/Register/Token endpoints
β β βββ admin.py β User & Group management, NSFW admin tools
β β βββ user.py β User environment, mark-nsfw endpoint
β β βββ static.py β Asset serving
β β βββ workflow_routes.py β Workflow protection, NSFW enforcement
β βββ utils/
β β βββ ip_filter.py β Whitelist/blacklist system
β β βββ user_env.py β User folder management
β β βββ sanitizer.py β Input scrubbing
β β βββ logger.py β Logging hooks
β β βββ timeout.py β Rate limiting
β β βββ sfw_intercept/
β β β βββ nsfw_guard.py β NSFW detection, metadata tagging
β β β βββ node_interceptor.py β Node-level image interception
β β βββ reactor_sfw_intercept.py β ReActor SFW patch
β βββ web/
β βββ js/usgromana_settings.js β UI enforcement + settings panel
β βββ css/usgromana.css β Themed UI
β βββ assets/dark_logo_transparent.png
β
βββ ComfyUI (upstream)
- Extract Usgromana into:
ComfyUI/custom_nodes/Usgromana/
-
Restart ComfyUI.
-
On first launch, register the initial admin.
-
Open settings β Usgromana to configure.
Usgromana/
β
βββ __init__.py β Main entry point, route registration
βββ api.py β NSFW Guard API (public interface)
βββ globals.py β Shared server instances, route table
βββ constants.py β Configuration paths
βββ access_control.py β RBAC, path blocking, folder isolation
β
βββ routes/
β βββ auth.py β Login/Register/Token endpoints
β βββ admin.py β User & Group management, NSFW admin tools
β βββ user.py β User environment, mark-nsfw endpoint
β βββ static.py β Asset serving
β βββ workflow_routes.py β Workflow protection, NSFW enforcement
β
βββ utils/
β βββ ip_filter.py β Whitelist/blacklist system
β βββ user_env.py β User folder management
β βββ sanitizer.py β Input scrubbing
β βββ logger.py β Logging hooks
β βββ timeout.py β Rate limiting
β βββ sfw_intercept/
β β βββ nsfw_guard.py β NSFW detection, metadata tagging
β β βββ node_interceptor.py β Node-level image interception
β βββ reactor_sfw_intercept.py β ReActor SFW patch
β
βββ web/
β βββ js/usgromana_settings.js β UI enforcement + settings panel
β βββ css/usgromana.css β Themed UI
β βββ assets/dark_logo_transparent.png
β
βββ users/
βββ users.json
βββ usgromana_groups.json
| Role | Description |
|---|---|
| Admin | Full access to all ComfyUI and Usgromana features. |
| Power | Elevated user with additional permissions but no admin panel access. |
| User | Standard user who can run workflows but cannot modify system behavior. |
| Guest | Fully restricted by defaultβcannot run, upload, save, or manage. |
Permissions are stored in:
users/usgromana_groups.json
and editable through the settings panel.
Usgromana dynamically modifies the UI by:
- Injecting CSS rules to hide elements
- Removing menu entries (Save, Load, Manage Extensions)
- Blocking iTools, Crystools, rgthree, ImpactPack for restricted roles
- Guarding PrimeVue dialogs (Save workflow warnings)
- Intercepting hotkeys (Ctrl+S, Ctrl+O)
All logic is contained in:
web/js/usgromana_settings.js
If a user lacking permission tries to save:
- Backend blocks the operation (
can_modify_workflows) - watcher.py detects the 403 with code
"WORKFLOW_SAVE_DENIED" - UI shows a centered toast popup:
βYou do not have permission to save workflows.β
Same for delete operations.
Located in:
utils/ip_filter.py
- Whitelist mode: Only listed IPs allowed
- Blacklist mode: Block specific IPs
- Configurable through new βIP Rulesβ tab in settings
- Changes applied instantly to middleware
From:
utils/user_env.py
Features:
- Purge a userβs input/output/temp folders
- List all user-bound files
- Toggle whether their folder functions as a gallery
Exposed through the βUser Envβ tab in the Usgromana settings modal.
Access via: Settings β Usgromana
Tabs:
- Users & Roles
- Permissions & UI
- IP Rules
- User Environment
- NSFW Management
Other ComfyUI extensions can register custom tabs in the Usgromana admin panel to manage their own permissions and settings. See EXTENSION_TABS_API.md for complete documentation.
Quick Example:
window.UsgromanaAdminTabs.register({
id: "myextension",
label: "My Extension",
order: 50,
render: async (container, context) => {
const { usersList, groupsConfig, currentUser } = context;
container.innerHTML = `<h3>My Extension Settings</h3>`;
// Render your content here
}
});- Integrated logout button in the settings entry
- Transparent blurred panel
- Neon-accented tab bar
- Logo watermark in top-right
The NSFW Guard API provides programmatic access to NSFW detection and enforcement. See API_USAGE.md for complete documentation.
Key Functions:
check_tensor_nsfw(images_tensor, threshold=0.5)- Check image tensorscheck_image_path_nsfw(image_path, username=None)- Check image filescheck_pil_image_nsfw(pil_image, threshold=0.5)- Check PIL Imagesis_sfw_enforced_for_user(username=None)- Check user restrictionsset_image_nsfw_tag(image_path, is_nsfw, score=1.0, label="manual")- Tag imagesget_image_nsfw_tag(image_path)- Get existing tags
POST /usgromana-gallery/mark-nsfw
Manually mark an image as NSFW or SFW. Designed for integration with gallery extensions.
Request Body:
{
"filename": "image.png",
"is_nsfw": true,
"score": 1.0, // optional, default 1.0
"label": "manual" // optional, default "manual"
}Response:
{
"status": "ok",
"message": "Image marked as NSFW",
"filename": "image.png",
"is_nsfw": true
}Features:
- Recursively searches output directory subdirectories
- Security checks prevent path traversal
- Integrates with metadata tagging system
- Returns 404 if file not found, 403 for invalid paths
POST /usgromana/api/login - User login
POST /usgromana/api/register - User registration
POST /usgromana/api/guest-login - Guest login
POST /usgromana/api/refresh-token - Token refresh
GET/PUT /usgromana/api/users - User management
GET/PUT /usgromana/api/groups - Group/permission management
PUT /usgromana/api/ip-lists - IP whitelist/blacklist
POST /usgromana/api/nsfw-management - NSFW admin tools (scan, fix, clear)
POST /usgromana/api/user-env - User folder operations (purge, list, promote)
Extension Tabs API - JavaScript API for extensions to add custom tabs to the admin panel. See EXTENSION_TABS_API.md for complete documentation.
- Main entry point for ComfyUI extension
- Route registration and middleware setup
- Server instance initialization
- NSFW Guard API - Public interface for other extensions
- Functions:
check_tensor_nsfw(),check_image_path_nsfw(),is_sfw_enforced_for_user() - Metadata tagging:
set_image_nsfw_tag(),get_image_nsfw_tag() - User context management for worker threads
- Folder isolation
- RBAC
- Middleware for blocking paths
- Workflow protection
- Extension gating
- JWT authentication endpoints
- Login, registration, token refresh
- Guest login support
- User & group management
- Permission editing
- NSFW management tools (scan, fix, clear)
- IP rules management
- User environment operations
- Gallery integration:
/usgromana-gallery/mark-nsfwendpoint - File management (purge, list, promote workflows)
- Workflow save/delete protection
- Global NSFW enforcement on
/viewendpoint - Workflow listing and loading
- Asset serving (CSS, JS, images)
- Logo and UI resources
- NSFW detection using AI models
- Metadata-based tagging system
- Background scanning and caching
- Per-user enforcement logic
- Node-level image interception
- Real-time NSFW blocking in custom nodes
- ReActor extension SFW patch
- Per-user SFW enforcement for face swap operations
- Whitelist & blacklist logic
- Persistent storage
- Folder operations
- Metadata tools
- User file management
Ensure the file exists:
Usgromana/web/assets/dark_logo_transparent.png
Clear browser cache or disable caching dev tools.
Check:
can_run = true
in usgromana_groups.json.
- Ensure the image file exists in the output directory or subdirectories
- Check that the filename doesn't contain path traversal characters (
..,/,\) - Verify the file is within the output directory (security check)
- Ensure
ComfyUI-Usgromanais loaded before your extension - Check that the API is available:
from api import is_available; print(is_available()) - Verify user context is set in worker threads using
set_user_context()
- Check that metadata files (
.nsfw_metadata.json) are being created alongside images - Verify write permissions in the output directory
- Ensure metadata files aren't being deleted by cleanup scripts
MIT License
You may modify and redistribute freely.
All notable changes to ComfyUI Usgromana are documented here.
This project follows a semantic-style versioning flow adapted for active development.
- **Metadata tag wipe
- Resolved an issue which caused the metadata to be removed from images after being tagged as NSFW.
=======
- Metadata-based tagging system
- Images are now tagged with NSFW metadata stored alongside files (
.nsfw_metadata.json)
- Images are now tagged with NSFW metadata stored alongside files (
- Gallery integration endpoint
- New
/usgromana-gallery/mark-nsfwendpoint for manual image flagging from gallery UIs
- New
- Recursive file search
- mark-nsfw endpoint now searches subdirectories to find images
- Enhanced API functions
- Added
set_image_nsfw_tag()for programmatic tagging
- Added
- Background scanning
- Automatic scanning of output directory with intelligent caching
- Per-user enforcement
- SFW restrictions apply per-user based on role permissions
- ComfyUI-Usgromana-Gallery compatibility
- Full integration with gallery extension
- Manual flagging
- Users can manually mark images as NSFW/SFW through gallery UI
- Metadata persistence
- NSFW tags persist across server restarts via metadata files
- Explicit route registration
- Routes are now explicitly registered to ensure availability
- Middleware whitelisting
- Gallery routes are properly whitelisted in workflow middleware
- Route verification
- Startup verification ensures all routes are properly registered
- Modular route structure
- Routes organized into dedicated modules (
routes/directory)
- Routes organized into dedicated modules (
- Separation of concerns
- NSFW logic separated into
utils/sfw_intercept/module
- NSFW logic separated into
- Public API module
api.pyprovides clean public interface for other extensions
- resolved an issue which barred admins from deleting default workflows
- resolved and issue with extension name causing UI block to fail
- Resolved an issue which caused duplicate extensions to be listed
- List now accounts for explicitly listed extensions
- Admin can now toggle SFW on/off per user
utils/reactor_sfw_intercept.py(added new file)
- Monolith Addition: Added options to select and delete individual files & Promote Workflows
routes/user.py(Updated information passage)web/usgromana_settings.js(updated the middleware and UI architecture)
- Monolith Split: Deconstructed the massive
usgromana.pyinto modular route handlers:routes/auth.py(Login/Register/Token)routes/admin.py(User & Group management)routes/user.py(User environment & status)routes/static.py(Asset serving)
- Circular Dependency Resolution: Introduced
globals.pyto handle shared server instances andconstants.pyto centralize configuration paths. - Logic Decoupling: Moved business logic out of HTTP handlers into dedicated utilities (
utils/admin_logic.py,utils/json_utils.py,utils/bootstrap.py).
- Startup Resilience: Added auto-creation logic for missing static folders (
web/css,web/js,web/html) to preventaiohttpcrash on first run. - Windows Pathing: Fixed
FileNotFoundErrorand path resolution issues on Windows environments. - Middleware Fixes: Restored missing
create_folder_access_control_middlewareand fixed import errors inwatcher.py. - Config Correction: Resolved missing
MAX_TOKEN_EXPIRE_MINUTESconstant that prevented server startup.
- Restructured
web/directory for cleaner separation of concerns. - Consolidated ComfyUI extension scripts (
usgromana_settings.js,logout.js,injectCSS.js) to ensure reliable auto-loading. - Moved HTML templates to
web/html/and updated static route mappings. - Removed legacy
admin.jsto prevent conflicts with the integrated Settings UI.
- Added multi-tab Usgromana Settings Panel
- Users & Roles
- Permissions & UI
- IP Rules
- User Environment
- Introduced logout button inside Usgromana settings.
- Implemented transparent glass UI theme with background blur.
- Added Usgromana logo watermark support in upper-right corner.
- Full save/delete workflow blocking for restricted roles.
- New
watcher.pymiddleware to detect backend 403s and send structured UI warnings. - Unified blocking under
WORKFLOW_SAVE_DENIEDandWORKFLOW_DELETE_DENIEDcodes. - Strengthened RBAC defaults for guest accounts.
- Added extension UI gating via CSS + runtime menu removal.
- New IP filtering system (
ip_filter.py) with whitelist + blacklist modes. - New User Environment tools (
user_env.py) including:- Folder purge
- File listing
- Gallery-mode toggles
- Added
create_usgromana_middleware()unified security layer. - Path blocking now includes extension routes, workflow endpoints, manager access, and asset paths.
- Added dynamic scanning of:
- PrimeVue menus
- Sidebar buttons
- Settings categories
- Enforcement now applies every second to catch late UI loads.
- Added hotkey interception (Ctrl+S / Ctrl+O) for restricted roles.
- Rebuilt
patchSaveConfirmDialogto override PrimeVue dialogs.
- Resolved issues where guests could open extension settings.
- Added safe defaults for undefined permissions per role.
- Added per-user:
- input directory
- output directory
- temp directory
- Automatic directory creation with fallback to βpublicβ user.
- Added
filename_prefixrewriting for isolated naming.
- Corrected queue ownership tracking.
- Fixed history objects containing mixed-user entries.
- Added JWT login, registration, expiration, and cookie storage.
- Implemented guest login with auto-created βguestβ user.
- Created protections to ensure guest cannot escalate privileges.
- Refactored user database operations.
- Added detection for first-time admin setup.
- Base RBAC system
- Permission flags stored in
usgromana_groups.json - Middleware for execution, upload, manager access
- Basic UI blocking
- Initial Usgromana settings entry (pre-tabs)
- Live audit logging panel
- Real-time session viewer
- Admin ability to force logout users
- Per-user storage quotas
- Automated workflow sandboxing
- Theme customization panel



