mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-30 14:36:46 +00:00
Compare commits
91 Commits
1.16.2-s.1
...
alerting-r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cce6e0820 | ||
|
|
2841c5ed4e | ||
|
|
9dc9b6a2c3 | ||
|
|
9808a48da0 | ||
|
|
8a6960d9c3 | ||
|
|
d966ef66e1 | ||
|
|
ed97cf5d97 | ||
|
|
a3b088f8d2 | ||
|
|
2828dee94c | ||
|
|
ee6fb34906 | ||
|
|
bff2ba7cc2 | ||
|
|
8e821b397f | ||
|
|
6f71af278e | ||
|
|
757bb39622 | ||
|
|
00ef6d617f | ||
|
|
d1b2105c80 | ||
|
|
50ee28b1f7 | ||
|
|
ba529ad14e | ||
|
|
6ab0555148 | ||
|
|
c6f269b3fa | ||
|
|
7bcb852dba | ||
|
|
ed604c8810 | ||
|
|
bea20674a8 | ||
|
|
177926932b | ||
|
|
04dfbd0a14 | ||
|
|
a143b7de7c | ||
|
|
63372b174f | ||
|
|
ad7d68d2b4 | ||
|
|
e05af54f76 | ||
|
|
13eadeaa8f | ||
|
|
19a686b3e4 | ||
|
|
d046084e84 | ||
|
|
e13a076939 | ||
|
|
b4ca6432db | ||
|
|
c80c7df1d0 | ||
|
|
99a064b77a | ||
|
|
9b84623d0c | ||
|
|
6bb6cf8a48 | ||
|
|
348fcbcabf | ||
|
|
1f4cde5f7f | ||
|
|
3e3b02021c | ||
|
|
17eb93d045 | ||
|
|
660420ddef | ||
|
|
395cab795c | ||
|
|
0fecbe704b | ||
|
|
ce59a8a52b | ||
|
|
2091b5f359 | ||
|
|
3525b367b3 | ||
|
|
0b5b6ed5a3 | ||
|
|
6fe9494df4 | ||
|
|
b2eab95a3b | ||
|
|
38d30b0214 | ||
|
|
212b7a104f | ||
|
|
d21dfb750e | ||
|
|
fff38aac85 | ||
|
|
7db58f920c | ||
|
|
e9b16b8801 | ||
|
|
5a2a97b23a | ||
|
|
5b894e8682 | ||
|
|
84925f724d | ||
|
|
7b78b91449 | ||
|
|
f9bff5954f | ||
|
|
2c6e9507b5 | ||
|
|
6471571bc6 | ||
|
|
fe40ea58c1 | ||
|
|
0d4edcd1c7 | ||
|
|
7d8797840a | ||
|
|
19f8c1772f | ||
|
|
37d331e813 | ||
|
|
c660df55cd | ||
|
|
60982bf19f | ||
|
|
7c8b865379 | ||
|
|
3cca0c09c0 | ||
|
|
e0fa5607e5 | ||
|
|
572c9bf319 | ||
|
|
52cac4aa21 | ||
|
|
e358d12765 | ||
|
|
02697e27a4 | ||
|
|
ce58e71c44 | ||
|
|
e15703164d | ||
|
|
8f33e25782 | ||
|
|
722595c131 | ||
|
|
c9be84a8a8 | ||
|
|
435cae06a2 | ||
|
|
18ed38889f | ||
|
|
84b082e194 | ||
|
|
b01fcc70fe | ||
|
|
35fed74e49 | ||
|
|
6cf1b9b010 | ||
|
|
dae169540b | ||
|
|
20e547a0f6 |
115
license.py
Normal file
115
license.py
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# --- Configuration ---
|
||||||
|
# The header text to be added to the files.
|
||||||
|
HEADER_TEXT = """/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
"""
|
||||||
|
|
||||||
|
def should_add_header(file_path):
|
||||||
|
"""
|
||||||
|
Checks if a file should receive the commercial license header.
|
||||||
|
Returns True if 'private' is in the path or file content.
|
||||||
|
"""
|
||||||
|
# Check if 'private' is in the file path (case-insensitive)
|
||||||
|
if 'server/private' in file_path.lower():
|
||||||
|
return True
|
||||||
|
|
||||||
|
# Check if 'private' is in the file content (case-insensitive)
|
||||||
|
# try:
|
||||||
|
# with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
|
||||||
|
# content = f.read()
|
||||||
|
# if 'private' in content.lower():
|
||||||
|
# return True
|
||||||
|
# except Exception as e:
|
||||||
|
# print(f"Could not read file {file_path}: {e}")
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
def process_directory(root_dir):
|
||||||
|
"""
|
||||||
|
Recursively scans a directory and adds headers to qualifying .ts or .tsx files,
|
||||||
|
skipping any 'node_modules' directories.
|
||||||
|
"""
|
||||||
|
print(f"Scanning directory: {root_dir}")
|
||||||
|
files_processed = 0
|
||||||
|
headers_added = 0
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(root_dir):
|
||||||
|
# --- MODIFICATION ---
|
||||||
|
# Exclude 'node_modules' directories from the scan to improve performance.
|
||||||
|
if 'node_modules' in dirs:
|
||||||
|
dirs.remove('node_modules')
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
if file.endswith('.ts') or file.endswith('.tsx'):
|
||||||
|
file_path = os.path.join(root, file)
|
||||||
|
files_processed += 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(file_path, 'r+', encoding='utf-8') as f:
|
||||||
|
original_content = f.read()
|
||||||
|
has_header = original_content.startswith(HEADER_TEXT.strip())
|
||||||
|
|
||||||
|
if should_add_header(file_path):
|
||||||
|
# Add header only if it's not already there
|
||||||
|
if not has_header:
|
||||||
|
f.seek(0, 0) # Go to the beginning of the file
|
||||||
|
f.write(HEADER_TEXT.strip() + '\n\n' + original_content)
|
||||||
|
print(f"Added header to: {file_path}")
|
||||||
|
headers_added += 1
|
||||||
|
else:
|
||||||
|
print(f"Header already exists in: {file_path}")
|
||||||
|
else:
|
||||||
|
# Remove header if it exists but shouldn't be there
|
||||||
|
if has_header:
|
||||||
|
# Find the end of the header and remove it (including following newlines)
|
||||||
|
header_with_newlines = HEADER_TEXT.strip() + '\n\n'
|
||||||
|
if original_content.startswith(header_with_newlines):
|
||||||
|
content_without_header = original_content[len(header_with_newlines):]
|
||||||
|
else:
|
||||||
|
# Handle case where there might be different newline patterns
|
||||||
|
header_end = len(HEADER_TEXT.strip())
|
||||||
|
# Skip any newlines after the header
|
||||||
|
while header_end < len(original_content) and original_content[header_end] in '\n\r':
|
||||||
|
header_end += 1
|
||||||
|
content_without_header = original_content[header_end:]
|
||||||
|
|
||||||
|
f.seek(0)
|
||||||
|
f.write(content_without_header)
|
||||||
|
f.truncate()
|
||||||
|
print(f"Removed header from: {file_path}")
|
||||||
|
headers_added += 1 # Reusing counter for modifications
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error processing file {file_path}: {e}")
|
||||||
|
|
||||||
|
print("\n--- Scan Complete ---")
|
||||||
|
print(f"Total .ts or .tsx files found: {files_processed}")
|
||||||
|
print(f"Files modified (headers added/removed): {headers_added}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Get the target directory from the command line arguments.
|
||||||
|
# If no directory is provided, it uses the current directory ('.').
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
target_directory = sys.argv[1]
|
||||||
|
else:
|
||||||
|
target_directory = '.' # Default to current directory
|
||||||
|
|
||||||
|
if not os.path.isdir(target_directory):
|
||||||
|
print(f"Error: Directory '{target_directory}' not found.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
process_directory(os.path.abspath(target_directory))
|
||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Изтрийте потребител",
|
"actionRemoveUser": "Изтрийте потребител",
|
||||||
"actionListUsers": "Изброяване на потребители",
|
"actionListUsers": "Изброяване на потребители",
|
||||||
"actionAddUserRole": "Добавяне на роля на потребител",
|
"actionAddUserRole": "Добавяне на роля на потребител",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Генериране на токен за достъп",
|
"actionGenerateAccessToken": "Генериране на токен за достъп",
|
||||||
"actionDeleteAccessToken": "Изтриване на токен за достъп",
|
"actionDeleteAccessToken": "Изтриване на токен за достъп",
|
||||||
"actionListAccessTokens": "Изброяване на токени за достъп",
|
"actionListAccessTokens": "Изброяване на токени за достъп",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Odstranit uživatele",
|
"actionRemoveUser": "Odstranit uživatele",
|
||||||
"actionListUsers": "Seznam uživatelů",
|
"actionListUsers": "Seznam uživatelů",
|
||||||
"actionAddUserRole": "Přidat uživatelskou roli",
|
"actionAddUserRole": "Přidat uživatelskou roli",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Generovat přístupový token",
|
"actionGenerateAccessToken": "Generovat přístupový token",
|
||||||
"actionDeleteAccessToken": "Odstranit přístupový token",
|
"actionDeleteAccessToken": "Odstranit přístupový token",
|
||||||
"actionListAccessTokens": "Seznam přístupových tokenů",
|
"actionListAccessTokens": "Seznam přístupových tokenů",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Benutzer entfernen",
|
"actionRemoveUser": "Benutzer entfernen",
|
||||||
"actionListUsers": "Benutzer auflisten",
|
"actionListUsers": "Benutzer auflisten",
|
||||||
"actionAddUserRole": "Benutzerrolle hinzufügen",
|
"actionAddUserRole": "Benutzerrolle hinzufügen",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Zugriffstoken generieren",
|
"actionGenerateAccessToken": "Zugriffstoken generieren",
|
||||||
"actionDeleteAccessToken": "Zugriffstoken löschen",
|
"actionDeleteAccessToken": "Zugriffstoken löschen",
|
||||||
"actionListAccessTokens": "Zugriffstoken auflisten",
|
"actionListAccessTokens": "Zugriffstoken auflisten",
|
||||||
|
|||||||
@@ -148,6 +148,11 @@
|
|||||||
"createLink": "Create Link",
|
"createLink": "Create Link",
|
||||||
"resourcesNotFound": "No resources found",
|
"resourcesNotFound": "No resources found",
|
||||||
"resourceSearch": "Search resources",
|
"resourceSearch": "Search resources",
|
||||||
|
"machineSearch": "Search machines",
|
||||||
|
"machinesSearch": "Search machine clients...",
|
||||||
|
"machineNotFound": "No machines found",
|
||||||
|
"userDeviceSearch": "Search user devices",
|
||||||
|
"userDevicesSearch": "Search user devices...",
|
||||||
"openMenu": "Open menu",
|
"openMenu": "Open menu",
|
||||||
"resource": "Resource",
|
"resource": "Resource",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
@@ -323,6 +328,41 @@
|
|||||||
"apiKeysDelete": "Delete API Key",
|
"apiKeysDelete": "Delete API Key",
|
||||||
"apiKeysManage": "Manage API Keys",
|
"apiKeysManage": "Manage API Keys",
|
||||||
"apiKeysDescription": "API keys are used to authenticate with the integration API",
|
"apiKeysDescription": "API keys are used to authenticate with the integration API",
|
||||||
|
"provisioningKeysTitle": "Provisioning Key",
|
||||||
|
"provisioningKeysManage": "Manage Provisioning Keys",
|
||||||
|
"provisioningKeysDescription": "Provisioning keys are used to authenticate automated site provisioning for your organization.",
|
||||||
|
"provisioningKeys": "Provisioning Keys",
|
||||||
|
"searchProvisioningKeys": "Search provisioning keys...",
|
||||||
|
"provisioningKeysAdd": "Generate Provisioning Key",
|
||||||
|
"provisioningKeysErrorDelete": "Error deleting provisioning key",
|
||||||
|
"provisioningKeysErrorDeleteMessage": "Error deleting provisioning key",
|
||||||
|
"provisioningKeysQuestionRemove": "Are you sure you want to remove this provisioning key from the organization?",
|
||||||
|
"provisioningKeysMessageRemove": "Once removed, the key can no longer be used for site provisioning.",
|
||||||
|
"provisioningKeysDeleteConfirm": "Confirm Delete Provisioning Key",
|
||||||
|
"provisioningKeysDelete": "Delete Provisioning key",
|
||||||
|
"provisioningKeysCreate": "Generate Provisioning Key",
|
||||||
|
"provisioningKeysCreateDescription": "Generate a new provisioning key for the organization",
|
||||||
|
"provisioningKeysSeeAll": "See all provisioning keys",
|
||||||
|
"provisioningKeysSave": "Save the provisioning key",
|
||||||
|
"provisioningKeysSaveDescription": "You will only be able to see this once. Copy it to a secure place.",
|
||||||
|
"provisioningKeysErrorCreate": "Error creating provisioning key",
|
||||||
|
"provisioningKeysList": "New provisioning key",
|
||||||
|
"provisioningKeysMaxBatchSize": "Max batch size",
|
||||||
|
"provisioningKeysUnlimitedBatchSize": "Unlimited batch size (no limit)",
|
||||||
|
"provisioningKeysMaxBatchUnlimited": "Unlimited",
|
||||||
|
"provisioningKeysMaxBatchSizeInvalid": "Enter a valid max batch size (1–1,000,000).",
|
||||||
|
"provisioningKeysValidUntil": "Valid until",
|
||||||
|
"provisioningKeysValidUntilHint": "Leave empty for no expiration.",
|
||||||
|
"provisioningKeysValidUntilInvalid": "Enter a valid date and time.",
|
||||||
|
"provisioningKeysNumUsed": "Times used",
|
||||||
|
"provisioningKeysLastUsed": "Last used",
|
||||||
|
"provisioningKeysNoExpiry": "No expiration",
|
||||||
|
"provisioningKeysNeverUsed": "Never",
|
||||||
|
"provisioningKeysEdit": "Edit Provisioning Key",
|
||||||
|
"provisioningKeysEditDescription": "Update the max batch size and expiration time for this key.",
|
||||||
|
"provisioningKeysUpdateError": "Error updating provisioning key",
|
||||||
|
"provisioningKeysUpdated": "Provisioning key updated",
|
||||||
|
"provisioningKeysUpdatedDescription": "Your changes have been saved.",
|
||||||
"apiKeysSettings": "{apiKeyName} Settings",
|
"apiKeysSettings": "{apiKeyName} Settings",
|
||||||
"userTitle": "Manage All Users",
|
"userTitle": "Manage All Users",
|
||||||
"userDescription": "View and manage all users in the system",
|
"userDescription": "View and manage all users in the system",
|
||||||
@@ -509,9 +549,12 @@
|
|||||||
"userSaved": "User saved",
|
"userSaved": "User saved",
|
||||||
"userSavedDescription": "The user has been updated.",
|
"userSavedDescription": "The user has been updated.",
|
||||||
"autoProvisioned": "Auto Provisioned",
|
"autoProvisioned": "Auto Provisioned",
|
||||||
|
"autoProvisionSettings": "Auto Provision Settings",
|
||||||
"autoProvisionedDescription": "Allow this user to be automatically managed by identity provider",
|
"autoProvisionedDescription": "Allow this user to be automatically managed by identity provider",
|
||||||
"accessControlsDescription": "Manage what this user can access and do in the organization",
|
"accessControlsDescription": "Manage what this user can access and do in the organization",
|
||||||
"accessControlsSubmit": "Save Access Controls",
|
"accessControlsSubmit": "Save Access Controls",
|
||||||
|
"singleRolePerUserPlanNotice": "Your plan only supports one role per user.",
|
||||||
|
"singleRolePerUserEditionNotice": "This edition only supports one role per user.",
|
||||||
"roles": "Roles",
|
"roles": "Roles",
|
||||||
"accessUsersRoles": "Manage Users & Roles",
|
"accessUsersRoles": "Manage Users & Roles",
|
||||||
"accessUsersRolesDescription": "Invite users and add them to roles to manage access to the organization",
|
"accessUsersRolesDescription": "Invite users and add them to roles to manage access to the organization",
|
||||||
@@ -887,7 +930,7 @@
|
|||||||
"defaultMappingsRole": "Default Role Mapping",
|
"defaultMappingsRole": "Default Role Mapping",
|
||||||
"defaultMappingsRoleDescription": "The result of this expression must return the role name as defined in the organization as a string.",
|
"defaultMappingsRoleDescription": "The result of this expression must return the role name as defined in the organization as a string.",
|
||||||
"defaultMappingsOrg": "Default Organization Mapping",
|
"defaultMappingsOrg": "Default Organization Mapping",
|
||||||
"defaultMappingsOrgDescription": "This expression must return the org ID or true for the user to be allowed to access the organization.",
|
"defaultMappingsOrgDescription": "When set, this expression must return the organization ID or true for the user to access that organization. When unset, defining an organization policy for that org is enough: the user is allowed in as long as a valid role mapping can be resolved for them within the organization.",
|
||||||
"defaultMappingsSubmit": "Save Default Mappings",
|
"defaultMappingsSubmit": "Save Default Mappings",
|
||||||
"orgPoliciesEdit": "Edit Organization Policy",
|
"orgPoliciesEdit": "Edit Organization Policy",
|
||||||
"org": "Organization",
|
"org": "Organization",
|
||||||
@@ -1040,7 +1083,6 @@
|
|||||||
"pageNotFoundDescription": "Oops! The page you're looking for doesn't exist.",
|
"pageNotFoundDescription": "Oops! The page you're looking for doesn't exist.",
|
||||||
"overview": "Overview",
|
"overview": "Overview",
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
"accessControl": "Access Control",
|
|
||||||
"settings": "Settings",
|
"settings": "Settings",
|
||||||
"usersAll": "All Users",
|
"usersAll": "All Users",
|
||||||
"license": "License",
|
"license": "License",
|
||||||
@@ -1150,6 +1192,7 @@
|
|||||||
"actionRemoveUser": "Remove User",
|
"actionRemoveUser": "Remove User",
|
||||||
"actionListUsers": "List Users",
|
"actionListUsers": "List Users",
|
||||||
"actionAddUserRole": "Add User Role",
|
"actionAddUserRole": "Add User Role",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Generate Access Token",
|
"actionGenerateAccessToken": "Generate Access Token",
|
||||||
"actionDeleteAccessToken": "Delete Access Token",
|
"actionDeleteAccessToken": "Delete Access Token",
|
||||||
"actionListAccessTokens": "List Access Tokens",
|
"actionListAccessTokens": "List Access Tokens",
|
||||||
@@ -1194,6 +1237,7 @@
|
|||||||
"actionViewLogs": "View Logs",
|
"actionViewLogs": "View Logs",
|
||||||
"noneSelected": "None selected",
|
"noneSelected": "None selected",
|
||||||
"orgNotFound2": "No organizations found.",
|
"orgNotFound2": "No organizations found.",
|
||||||
|
"search": "Search…",
|
||||||
"searchPlaceholder": "Search...",
|
"searchPlaceholder": "Search...",
|
||||||
"emptySearchOptions": "No options found",
|
"emptySearchOptions": "No options found",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
@@ -1266,6 +1310,7 @@
|
|||||||
"sidebarRoles": "Roles",
|
"sidebarRoles": "Roles",
|
||||||
"sidebarShareableLinks": "Links",
|
"sidebarShareableLinks": "Links",
|
||||||
"sidebarApiKeys": "API Keys",
|
"sidebarApiKeys": "API Keys",
|
||||||
|
"sidebarProvisioning": "Provisioning",
|
||||||
"sidebarSettings": "Settings",
|
"sidebarSettings": "Settings",
|
||||||
"sidebarAllUsers": "All Users",
|
"sidebarAllUsers": "All Users",
|
||||||
"sidebarIdentityProviders": "Identity Providers",
|
"sidebarIdentityProviders": "Identity Providers",
|
||||||
@@ -1277,10 +1322,96 @@
|
|||||||
"sidebarGeneral": "Manage",
|
"sidebarGeneral": "Manage",
|
||||||
"sidebarLogAndAnalytics": "Log & Analytics",
|
"sidebarLogAndAnalytics": "Log & Analytics",
|
||||||
"sidebarBluePrints": "Blueprints",
|
"sidebarBluePrints": "Blueprints",
|
||||||
|
"sidebarAlerting": "Alerting",
|
||||||
"sidebarOrganization": "Organization",
|
"sidebarOrganization": "Organization",
|
||||||
"sidebarManagement": "Management",
|
"sidebarManagement": "Management",
|
||||||
"sidebarBillingAndLicenses": "Billing & Licenses",
|
"sidebarBillingAndLicenses": "Billing & Licenses",
|
||||||
"sidebarLogsAnalytics": "Analytics",
|
"sidebarLogsAnalytics": "Analytics",
|
||||||
|
"alertingTitle": "Alerting rules",
|
||||||
|
"alertingDescription": "Define sources, triggers, and actions for notifications.",
|
||||||
|
"alertingRules": "Alert rules",
|
||||||
|
"alertingSearchRules": "Search rules…",
|
||||||
|
"alertingAddRule": "Create Rule",
|
||||||
|
"alertingColumnSource": "Source",
|
||||||
|
"alertingColumnTrigger": "Trigger",
|
||||||
|
"alertingColumnActions": "Actions",
|
||||||
|
"alertingColumnEnabled": "Enabled",
|
||||||
|
"alertingDeleteQuestion": "Delete this alert rule? This cannot be undone.",
|
||||||
|
"alertingDeleteRule": "Delete alert rule",
|
||||||
|
"alertingRuleDeleted": "Alert rule deleted",
|
||||||
|
"alertingRuleSaved": "Alert rule saved",
|
||||||
|
"alertingEditRule": "Edit alert rule",
|
||||||
|
"alertingCreateRule": "Create alert rule",
|
||||||
|
"alertingRuleCredenzaDescription": "Choose what to watch, when to fire, and how to notify your team.",
|
||||||
|
"alertingRuleNamePlaceholder": "Production site down",
|
||||||
|
"alertingRuleEnabled": "Rule enabled",
|
||||||
|
"alertingSectionSource": "Source",
|
||||||
|
"alertingSourceType": "Source type",
|
||||||
|
"alertingSourceSite": "Site",
|
||||||
|
"alertingSourceHealthCheck": "Health check",
|
||||||
|
"alertingPickSites": "Sites",
|
||||||
|
"alertingPickHealthChecks": "Health checks",
|
||||||
|
"alertingPickResources": "Resources",
|
||||||
|
"alertingSelectResources": "Select resources…",
|
||||||
|
"alertingResourcesSelected": "{count} resources selected",
|
||||||
|
"alertingResourcesEmpty": "No resources with targets in the first 10 results.",
|
||||||
|
"alertingSectionTrigger": "Trigger",
|
||||||
|
"alertingTrigger": "When to alert",
|
||||||
|
"alertingTriggerSiteOnline": "Site online",
|
||||||
|
"alertingTriggerSiteOffline": "Site offline",
|
||||||
|
"alertingTriggerHcHealthy": "Health check healthy",
|
||||||
|
"alertingTriggerHcUnhealthy": "Health check unhealthy",
|
||||||
|
"alertingSectionActions": "Actions",
|
||||||
|
"alertingAddAction": "Add action",
|
||||||
|
"alertingActionNotify": "Notify",
|
||||||
|
"alertingActionSms": "SMS",
|
||||||
|
"alertingActionWebhook": "Webhook",
|
||||||
|
"alertingActionType": "Action type",
|
||||||
|
"alertingNotifyUsers": "Users",
|
||||||
|
"alertingNotifyRoles": "Roles",
|
||||||
|
"alertingNotifyEmails": "Email addresses",
|
||||||
|
"alertingEmailPlaceholder": "Add email and press Enter",
|
||||||
|
"alertingSmsNumbers": "Phone numbers",
|
||||||
|
"alertingSmsPlaceholder": "Add number and press Enter",
|
||||||
|
"alertingWebhookMethod": "HTTP method",
|
||||||
|
"alertingWebhookSecret": "Signing secret (optional)",
|
||||||
|
"alertingWebhookSecretPlaceholder": "HMAC secret",
|
||||||
|
"alertingWebhookHeaders": "Headers",
|
||||||
|
"alertingAddHeader": "Add header",
|
||||||
|
"alertingSelectSites": "Select sites…",
|
||||||
|
"alertingSitesSelected": "{count} sites selected",
|
||||||
|
"alertingSelectHealthChecks": "Select health checks…",
|
||||||
|
"alertingHealthChecksSelected": "{count} health checks selected",
|
||||||
|
"alertingNoHealthChecks": "No targets with health checks enabled",
|
||||||
|
"alertingHealthCheckStub": "Health check source selection is not wired up yet — you can still configure triggers and actions.",
|
||||||
|
"alertingSelectUsers": "Select users…",
|
||||||
|
"alertingUsersSelected": "{count} users selected",
|
||||||
|
"alertingSelectRoles": "Select roles…",
|
||||||
|
"alertingRolesSelected": "{count} roles selected",
|
||||||
|
"alertingSummarySites": "Sites ({count})",
|
||||||
|
"alertingSummaryHealthChecks": "Health checks ({count})",
|
||||||
|
"alertingErrorNameRequired": "Enter a name",
|
||||||
|
"alertingErrorActionsMin": "Add at least one action",
|
||||||
|
"alertingErrorPickSites": "Select at least one site",
|
||||||
|
"alertingErrorPickHealthChecks": "Select at least one health check",
|
||||||
|
"alertingErrorTriggerSite": "Choose a site trigger",
|
||||||
|
"alertingErrorTriggerHealth": "Choose a health check trigger",
|
||||||
|
"alertingErrorNotifyRecipients": "Pick users, roles, or at least one email",
|
||||||
|
"alertingErrorSmsPhones": "Add at least one phone number",
|
||||||
|
"alertingErrorWebhookUrl": "Enter a valid webhook URL",
|
||||||
|
"alertingConfigureSource": "Configure Source",
|
||||||
|
"alertingConfigureTrigger": "Configure Trigger",
|
||||||
|
"alertingConfigureActions": "Configure Actions",
|
||||||
|
"alertingBackToRules": "Back to Rules",
|
||||||
|
"alertingDraftBadge": "Draft — save to store this rule",
|
||||||
|
"alertingSidebarHint": "Click a step on the canvas to edit it here.",
|
||||||
|
"alertingGraphCanvasTitle": "Rule Flow",
|
||||||
|
"alertingGraphCanvasDescription": "Visual overview of source, trigger, and actions. Select a node to edit it in the panel.",
|
||||||
|
"alertingNodeNotConfigured": "Not configured yet",
|
||||||
|
"alertingNodeActionsCount": "{count, plural, one {# action} other {# actions}}",
|
||||||
|
"alertingNodeRoleSource": "Source",
|
||||||
|
"alertingNodeRoleTrigger": "Trigger",
|
||||||
|
"alertingNodeRoleAction": "Action",
|
||||||
"blueprints": "Blueprints",
|
"blueprints": "Blueprints",
|
||||||
"blueprintsDescription": "Apply declarative configurations and view previous runs",
|
"blueprintsDescription": "Apply declarative configurations and view previous runs",
|
||||||
"blueprintAdd": "Add Blueprint",
|
"blueprintAdd": "Add Blueprint",
|
||||||
@@ -1939,6 +2070,25 @@
|
|||||||
"invalidValue": "Invalid value",
|
"invalidValue": "Invalid value",
|
||||||
"idpTypeLabel": "Identity Provider Type",
|
"idpTypeLabel": "Identity Provider Type",
|
||||||
"roleMappingExpressionPlaceholder": "e.g., contains(groups, 'admin') && 'Admin' || 'Member'",
|
"roleMappingExpressionPlaceholder": "e.g., contains(groups, 'admin') && 'Admin' || 'Member'",
|
||||||
|
"roleMappingModeFixedRoles": "Fixed Roles",
|
||||||
|
"roleMappingModeMappingBuilder": "Mapping Builder",
|
||||||
|
"roleMappingModeRawExpression": "Raw Expression",
|
||||||
|
"roleMappingFixedRolesPlaceholderSelect": "Select one or more roles",
|
||||||
|
"roleMappingFixedRolesPlaceholderFreeform": "Type role names (exact match per organization)",
|
||||||
|
"roleMappingFixedRolesDescriptionSameForAll": "Assign the same role set to every auto-provisioned user.",
|
||||||
|
"roleMappingFixedRolesDescriptionDefaultPolicy": "For default policies, type role names that exist in each organization where users are provisioned. Names must match exactly.",
|
||||||
|
"roleMappingClaimPath": "Claim Path",
|
||||||
|
"roleMappingClaimPathPlaceholder": "groups",
|
||||||
|
"roleMappingClaimPathDescription": "Path in the token payload that contains source values (for example, groups).",
|
||||||
|
"roleMappingMatchValue": "Match Value",
|
||||||
|
"roleMappingAssignRoles": "Assign Roles",
|
||||||
|
"roleMappingAddMappingRule": "Add Mapping Rule",
|
||||||
|
"roleMappingRawExpressionResultDescription": "Expression must evaluate to a string or string array.",
|
||||||
|
"roleMappingRawExpressionResultDescriptionSingleRole": "Expression must evaluate to a string (a single role name).",
|
||||||
|
"roleMappingMatchValuePlaceholder": "Match value (for example: admin)",
|
||||||
|
"roleMappingAssignRolesPlaceholderFreeform": "Type role names (exact per org)",
|
||||||
|
"roleMappingBuilderFreeformRowHint": "Role names must match a role in each target organization.",
|
||||||
|
"roleMappingRemoveRule": "Remove",
|
||||||
"idpGoogleConfiguration": "Google Configuration",
|
"idpGoogleConfiguration": "Google Configuration",
|
||||||
"idpGoogleConfigurationDescription": "Configure the Google OAuth2 credentials",
|
"idpGoogleConfigurationDescription": "Configure the Google OAuth2 credentials",
|
||||||
"idpGoogleClientIdDescription": "Google OAuth2 Client ID",
|
"idpGoogleClientIdDescription": "Google OAuth2 Client ID",
|
||||||
@@ -2345,6 +2495,12 @@
|
|||||||
"logRetentionEndOfFollowingYear": "End of following year",
|
"logRetentionEndOfFollowingYear": "End of following year",
|
||||||
"actionLogsDescription": "View a history of actions performed in this organization",
|
"actionLogsDescription": "View a history of actions performed in this organization",
|
||||||
"accessLogsDescription": "View access auth requests for resources in this organization",
|
"accessLogsDescription": "View access auth requests for resources in this organization",
|
||||||
|
"connectionLogs": "Connection Logs",
|
||||||
|
"connectionLogsDescription": "View connection logs for tunnels in this organization",
|
||||||
|
"sidebarLogsConnection": "Connection Logs",
|
||||||
|
"sourceAddress": "Source Address",
|
||||||
|
"destinationAddress": "Destination Address",
|
||||||
|
"duration": "Duration",
|
||||||
"licenseRequiredToUse": "An <enterpriseLicenseLink>Enterprise Edition</enterpriseLicenseLink> license or <pangolinCloudLink>Pangolin Cloud</pangolinCloudLink> is required to use this feature. <bookADemoLink>Book a demo or POC trial</bookADemoLink>.",
|
"licenseRequiredToUse": "An <enterpriseLicenseLink>Enterprise Edition</enterpriseLicenseLink> license or <pangolinCloudLink>Pangolin Cloud</pangolinCloudLink> is required to use this feature. <bookADemoLink>Book a demo or POC trial</bookADemoLink>.",
|
||||||
"ossEnterpriseEditionRequired": "The <enterpriseEditionLink>Enterprise Edition</enterpriseEditionLink> is required to use this feature. This feature is also available in <pangolinCloudLink>Pangolin Cloud</pangolinCloudLink>. <bookADemoLink>Book a demo or POC trial</bookADemoLink>.",
|
"ossEnterpriseEditionRequired": "The <enterpriseEditionLink>Enterprise Edition</enterpriseEditionLink> is required to use this feature. This feature is also available in <pangolinCloudLink>Pangolin Cloud</pangolinCloudLink>. <bookADemoLink>Book a demo or POC trial</bookADemoLink>.",
|
||||||
"certResolver": "Certificate Resolver",
|
"certResolver": "Certificate Resolver",
|
||||||
@@ -2511,9 +2667,9 @@
|
|||||||
"remoteExitNodeRegenerateCredentialsConfirmation": "Are you sure you want to regenerate the credentials for this remote exit node?",
|
"remoteExitNodeRegenerateCredentialsConfirmation": "Are you sure you want to regenerate the credentials for this remote exit node?",
|
||||||
"remoteExitNodeRegenerateCredentialsWarning": "This will regenerate the credentials. The remote exit node will stay connected until you manually restart it and use the new credentials.",
|
"remoteExitNodeRegenerateCredentialsWarning": "This will regenerate the credentials. The remote exit node will stay connected until you manually restart it and use the new credentials.",
|
||||||
"agent": "Agent",
|
"agent": "Agent",
|
||||||
"personalUseOnly": "Personal Use Only",
|
"personalUseOnly": "Personal Use Only",
|
||||||
"loginPageLicenseWatermark": "This instance is licensed for personal use only.",
|
"loginPageLicenseWatermark": "This instance is licensed for personal use only.",
|
||||||
"instanceIsUnlicensed": "This instance is unlicensed.",
|
"instanceIsUnlicensed": "This instance is unlicensed.",
|
||||||
"portRestrictions": "Port Restrictions",
|
"portRestrictions": "Port Restrictions",
|
||||||
"allPorts": "All",
|
"allPorts": "All",
|
||||||
"custom": "Custom",
|
"custom": "Custom",
|
||||||
@@ -2567,7 +2723,7 @@
|
|||||||
"automaticModeDescription": " Show maintenance page only when all backend targets are down or unhealthy. Your resource continues working normally as long as at least one target is healthy.",
|
"automaticModeDescription": " Show maintenance page only when all backend targets are down or unhealthy. Your resource continues working normally as long as at least one target is healthy.",
|
||||||
"forced": "Forced",
|
"forced": "Forced",
|
||||||
"forcedModeDescription": "Always show the maintenance page regardless of backend health. Use this for planned maintenance when you want to prevent all access.",
|
"forcedModeDescription": "Always show the maintenance page regardless of backend health. Use this for planned maintenance when you want to prevent all access.",
|
||||||
"warning:" : "Warning:",
|
"warning:": "Warning:",
|
||||||
"forcedeModeWarning": "All traffic will be directed to the maintenance page. Your backend resources will not receive any requests.",
|
"forcedeModeWarning": "All traffic will be directed to the maintenance page. Your backend resources will not receive any requests.",
|
||||||
"pageTitle": "Page Title",
|
"pageTitle": "Page Title",
|
||||||
"pageTitleDescription": "The main heading displayed on the maintenance page",
|
"pageTitleDescription": "The main heading displayed on the maintenance page",
|
||||||
@@ -2684,5 +2840,6 @@
|
|||||||
"approvalsEmptyStateStep2Description": "Edit a role and enable the 'Require Device Approvals' option. Users with this role will need admin approval for new devices.",
|
"approvalsEmptyStateStep2Description": "Edit a role and enable the 'Require Device Approvals' option. Users with this role will need admin approval for new devices.",
|
||||||
"approvalsEmptyStatePreviewDescription": "Preview: When enabled, pending device requests will appear here for review",
|
"approvalsEmptyStatePreviewDescription": "Preview: When enabled, pending device requests will appear here for review",
|
||||||
"approvalsEmptyStateButtonText": "Manage Roles",
|
"approvalsEmptyStateButtonText": "Manage Roles",
|
||||||
"domainErrorTitle": "We are having trouble verifying your domain"
|
"domainErrorTitle": "We are having trouble verifying your domain",
|
||||||
|
"idpAdminAutoProvisionPoliciesTabHint": "Configure role mapping and organization policies on the <policiesTabLink>Auto Provision Settings</policiesTabLink> tab."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Eliminar usuario",
|
"actionRemoveUser": "Eliminar usuario",
|
||||||
"actionListUsers": "Listar usuarios",
|
"actionListUsers": "Listar usuarios",
|
||||||
"actionAddUserRole": "Añadir rol de usuario",
|
"actionAddUserRole": "Añadir rol de usuario",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Generar token de acceso",
|
"actionGenerateAccessToken": "Generar token de acceso",
|
||||||
"actionDeleteAccessToken": "Eliminar token de acceso",
|
"actionDeleteAccessToken": "Eliminar token de acceso",
|
||||||
"actionListAccessTokens": "Lista de Tokens de Acceso",
|
"actionListAccessTokens": "Lista de Tokens de Acceso",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Supprimer un utilisateur",
|
"actionRemoveUser": "Supprimer un utilisateur",
|
||||||
"actionListUsers": "Lister les utilisateurs",
|
"actionListUsers": "Lister les utilisateurs",
|
||||||
"actionAddUserRole": "Ajouter un rôle utilisateur",
|
"actionAddUserRole": "Ajouter un rôle utilisateur",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Générer un jeton d'accès",
|
"actionGenerateAccessToken": "Générer un jeton d'accès",
|
||||||
"actionDeleteAccessToken": "Supprimer un jeton d'accès",
|
"actionDeleteAccessToken": "Supprimer un jeton d'accès",
|
||||||
"actionListAccessTokens": "Lister les jetons d'accès",
|
"actionListAccessTokens": "Lister les jetons d'accès",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Rimuovi Utente",
|
"actionRemoveUser": "Rimuovi Utente",
|
||||||
"actionListUsers": "Elenca Utenti",
|
"actionListUsers": "Elenca Utenti",
|
||||||
"actionAddUserRole": "Aggiungi Ruolo Utente",
|
"actionAddUserRole": "Aggiungi Ruolo Utente",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Genera Token di Accesso",
|
"actionGenerateAccessToken": "Genera Token di Accesso",
|
||||||
"actionDeleteAccessToken": "Elimina Token di Accesso",
|
"actionDeleteAccessToken": "Elimina Token di Accesso",
|
||||||
"actionListAccessTokens": "Elenca Token di Accesso",
|
"actionListAccessTokens": "Elenca Token di Accesso",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "사용자 제거",
|
"actionRemoveUser": "사용자 제거",
|
||||||
"actionListUsers": "사용자 목록",
|
"actionListUsers": "사용자 목록",
|
||||||
"actionAddUserRole": "사용자 역할 추가",
|
"actionAddUserRole": "사용자 역할 추가",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "액세스 토큰 생성",
|
"actionGenerateAccessToken": "액세스 토큰 생성",
|
||||||
"actionDeleteAccessToken": "액세스 토큰 삭제",
|
"actionDeleteAccessToken": "액세스 토큰 삭제",
|
||||||
"actionListAccessTokens": "액세스 토큰 목록",
|
"actionListAccessTokens": "액세스 토큰 목록",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Fjern bruker",
|
"actionRemoveUser": "Fjern bruker",
|
||||||
"actionListUsers": "List opp brukere",
|
"actionListUsers": "List opp brukere",
|
||||||
"actionAddUserRole": "Legg til brukerrolle",
|
"actionAddUserRole": "Legg til brukerrolle",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Generer tilgangstoken",
|
"actionGenerateAccessToken": "Generer tilgangstoken",
|
||||||
"actionDeleteAccessToken": "Slett tilgangstoken",
|
"actionDeleteAccessToken": "Slett tilgangstoken",
|
||||||
"actionListAccessTokens": "List opp tilgangstokener",
|
"actionListAccessTokens": "List opp tilgangstokener",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Gebruiker verwijderen",
|
"actionRemoveUser": "Gebruiker verwijderen",
|
||||||
"actionListUsers": "Gebruikers weergeven",
|
"actionListUsers": "Gebruikers weergeven",
|
||||||
"actionAddUserRole": "Gebruikersrol toevoegen",
|
"actionAddUserRole": "Gebruikersrol toevoegen",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Genereer Toegangstoken",
|
"actionGenerateAccessToken": "Genereer Toegangstoken",
|
||||||
"actionDeleteAccessToken": "Verwijder toegangstoken",
|
"actionDeleteAccessToken": "Verwijder toegangstoken",
|
||||||
"actionListAccessTokens": "Lijst toegangstokens",
|
"actionListAccessTokens": "Lijst toegangstokens",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Usuń użytkownika",
|
"actionRemoveUser": "Usuń użytkownika",
|
||||||
"actionListUsers": "Lista użytkowników",
|
"actionListUsers": "Lista użytkowników",
|
||||||
"actionAddUserRole": "Dodaj rolę użytkownika",
|
"actionAddUserRole": "Dodaj rolę użytkownika",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Wygeneruj token dostępu",
|
"actionGenerateAccessToken": "Wygeneruj token dostępu",
|
||||||
"actionDeleteAccessToken": "Usuń token dostępu",
|
"actionDeleteAccessToken": "Usuń token dostępu",
|
||||||
"actionListAccessTokens": "Lista tokenów dostępu",
|
"actionListAccessTokens": "Lista tokenów dostępu",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Remover Utilizador",
|
"actionRemoveUser": "Remover Utilizador",
|
||||||
"actionListUsers": "Listar Utilizadores",
|
"actionListUsers": "Listar Utilizadores",
|
||||||
"actionAddUserRole": "Adicionar Função ao Utilizador",
|
"actionAddUserRole": "Adicionar Função ao Utilizador",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Gerar Token de Acesso",
|
"actionGenerateAccessToken": "Gerar Token de Acesso",
|
||||||
"actionDeleteAccessToken": "Eliminar Token de Acesso",
|
"actionDeleteAccessToken": "Eliminar Token de Acesso",
|
||||||
"actionListAccessTokens": "Listar Tokens de Acesso",
|
"actionListAccessTokens": "Listar Tokens de Acesso",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Удалить пользователя",
|
"actionRemoveUser": "Удалить пользователя",
|
||||||
"actionListUsers": "Список пользователей",
|
"actionListUsers": "Список пользователей",
|
||||||
"actionAddUserRole": "Добавить роль пользователя",
|
"actionAddUserRole": "Добавить роль пользователя",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Сгенерировать токен доступа",
|
"actionGenerateAccessToken": "Сгенерировать токен доступа",
|
||||||
"actionDeleteAccessToken": "Удалить токен доступа",
|
"actionDeleteAccessToken": "Удалить токен доступа",
|
||||||
"actionListAccessTokens": "Список токенов доступа",
|
"actionListAccessTokens": "Список токенов доступа",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "Kullanıcıyı Kaldır",
|
"actionRemoveUser": "Kullanıcıyı Kaldır",
|
||||||
"actionListUsers": "Kullanıcıları Listele",
|
"actionListUsers": "Kullanıcıları Listele",
|
||||||
"actionAddUserRole": "Kullanıcı Rolü Ekle",
|
"actionAddUserRole": "Kullanıcı Rolü Ekle",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "Erişim Jetonu Oluştur",
|
"actionGenerateAccessToken": "Erişim Jetonu Oluştur",
|
||||||
"actionDeleteAccessToken": "Erişim Jetonunu Sil",
|
"actionDeleteAccessToken": "Erişim Jetonunu Sil",
|
||||||
"actionListAccessTokens": "Erişim Jetonlarını Listele",
|
"actionListAccessTokens": "Erişim Jetonlarını Listele",
|
||||||
|
|||||||
@@ -1148,6 +1148,7 @@
|
|||||||
"actionRemoveUser": "删除用户",
|
"actionRemoveUser": "删除用户",
|
||||||
"actionListUsers": "列出用户",
|
"actionListUsers": "列出用户",
|
||||||
"actionAddUserRole": "添加用户角色",
|
"actionAddUserRole": "添加用户角色",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "生成访问令牌",
|
"actionGenerateAccessToken": "生成访问令牌",
|
||||||
"actionDeleteAccessToken": "删除访问令牌",
|
"actionDeleteAccessToken": "删除访问令牌",
|
||||||
"actionListAccessTokens": "访问令牌",
|
"actionListAccessTokens": "访问令牌",
|
||||||
|
|||||||
@@ -1091,6 +1091,7 @@
|
|||||||
"actionRemoveUser": "刪除用戶",
|
"actionRemoveUser": "刪除用戶",
|
||||||
"actionListUsers": "列出用戶",
|
"actionListUsers": "列出用戶",
|
||||||
"actionAddUserRole": "添加用戶角色",
|
"actionAddUserRole": "添加用戶角色",
|
||||||
|
"actionSetUserOrgRoles": "Set User Roles",
|
||||||
"actionGenerateAccessToken": "生成訪問令牌",
|
"actionGenerateAccessToken": "生成訪問令牌",
|
||||||
"actionDeleteAccessToken": "刪除訪問令牌",
|
"actionDeleteAccessToken": "刪除訪問令牌",
|
||||||
"actionListAccessTokens": "訪問令牌",
|
"actionListAccessTokens": "訪問令牌",
|
||||||
|
|||||||
130
package-lock.json
generated
130
package-lock.json
generated
@@ -44,6 +44,7 @@
|
|||||||
"@tailwindcss/forms": "0.5.11",
|
"@tailwindcss/forms": "0.5.11",
|
||||||
"@tanstack/react-query": "5.90.21",
|
"@tanstack/react-query": "5.90.21",
|
||||||
"@tanstack/react-table": "8.21.3",
|
"@tanstack/react-table": "8.21.3",
|
||||||
|
"@xyflow/react": "^12.8.4",
|
||||||
"arctic": "3.7.0",
|
"arctic": "3.7.0",
|
||||||
"axios": "1.13.5",
|
"axios": "1.13.5",
|
||||||
"better-sqlite3": "11.9.1",
|
"better-sqlite3": "11.9.1",
|
||||||
@@ -1058,6 +1059,7 @@
|
|||||||
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
|
"integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.29.0",
|
"@babel/code-frame": "^7.29.0",
|
||||||
"@babel/generator": "^7.29.0",
|
"@babel/generator": "^7.29.0",
|
||||||
@@ -2353,6 +2355,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2375,6 +2378,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2397,6 +2401,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2413,6 +2418,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2429,6 +2435,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2445,6 +2452,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2461,6 +2469,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2477,6 +2486,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2493,6 +2503,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2509,6 +2520,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2525,6 +2537,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "LGPL-3.0-or-later",
|
"license": "LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2541,6 +2554,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2563,6 +2577,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2585,6 +2600,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2607,6 +2623,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2629,6 +2646,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2651,6 +2669,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2673,6 +2692,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2695,6 +2715,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"wasm32"
|
"wasm32"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
|
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -2714,6 +2735,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2733,6 +2755,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -2752,6 +2775,7 @@
|
|||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
|
"dev": true,
|
||||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"os": [
|
"os": [
|
||||||
@@ -3002,6 +3026,7 @@
|
|||||||
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
|
"integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^14.21.3 || >=16"
|
"node": "^14.21.3 || >=16"
|
||||||
},
|
},
|
||||||
@@ -6948,6 +6973,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@react-email/text/-/text-0.1.6.tgz",
|
"resolved": "https://registry.npmjs.org/@react-email/text/-/text-0.1.6.tgz",
|
||||||
"integrity": "sha512-TYqkioRS45wTR5il3dYk/SbUjjEdhSwh9BtRNB99qNH1pXAwA45H7rAuxehiu8iJQJH0IyIr+6n62gBz9ezmsw==",
|
"integrity": "sha512-TYqkioRS45wTR5il3dYk/SbUjjEdhSwh9BtRNB99qNH1pXAwA45H7rAuxehiu8iJQJH0IyIr+6n62gBz9ezmsw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20.0.0"
|
"node": ">=20.0.0"
|
||||||
},
|
},
|
||||||
@@ -8408,6 +8434,7 @@
|
|||||||
"version": "5.90.21",
|
"version": "5.90.21",
|
||||||
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.21.tgz",
|
"resolved": "https://registry.npmjs.org/@tanstack/react-query/-/react-query-5.90.21.tgz",
|
||||||
"integrity": "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg==",
|
"integrity": "sha512-0Lu6y5t+tvlTJMTO7oh5NSpJfpg/5D41LlThfepTixPYkJ0sE2Jj0m0f6yYqujBwIXlId87e234+MxG3D3g7kg==",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tanstack/query-core": "5.90.20"
|
"@tanstack/query-core": "5.90.20"
|
||||||
},
|
},
|
||||||
@@ -8523,6 +8550,7 @@
|
|||||||
"integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==",
|
"integrity": "sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
@@ -8682,7 +8710,6 @@
|
|||||||
"version": "3.0.7",
|
"version": "3.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/d3-drag/-/d3-drag-3.0.7.tgz",
|
||||||
"integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==",
|
"integrity": "sha512-HE3jVKlzU9AaMazNufooRJ5ZpWmLIoc90A37WU2JMmeq28w1FQqCZswHZ3xR+SuxYftzHq6WU6KJHvqxKzTxxQ==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/d3-selection": "*"
|
"@types/d3-selection": "*"
|
||||||
@@ -8798,7 +8825,6 @@
|
|||||||
"version": "3.0.11",
|
"version": "3.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/d3-selection/-/d3-selection-3.0.11.tgz",
|
||||||
"integrity": "sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==",
|
"integrity": "sha512-bhAXu23DJWsrI45xafYpkQ4NtcKMwWnAC/vKrd2l+nxMFuvOT3XMYTIj2opv8vq8AO5Yh7Qac/nSeP/3zjTK0w==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/d3-shape": {
|
"node_modules/@types/d3-shape": {
|
||||||
@@ -8833,7 +8859,6 @@
|
|||||||
"version": "3.0.9",
|
"version": "3.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/@types/d3-transition/-/d3-transition-3.0.9.tgz",
|
||||||
"integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==",
|
"integrity": "sha512-uZS5shfxzO3rGlu0cC3bjmMFKsXv+SmZZcgp0KD22ts4uGXp5EVYGzu/0YdwZeKmddhcAccYtREJKkPfXkZuCg==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/d3-selection": "*"
|
"@types/d3-selection": "*"
|
||||||
@@ -8843,7 +8868,6 @@
|
|||||||
"version": "3.0.8",
|
"version": "3.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/d3-zoom/-/d3-zoom-3.0.8.tgz",
|
||||||
"integrity": "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==",
|
"integrity": "sha512-iqMC4/YlFCSlO8+2Ii1GGGliCAY4XdeG748w5vQUbevlbDu0zSjH/+jojorQVBK/se0j6DUFNPBGSqD3YWYnDw==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/d3-interpolate": "*",
|
"@types/d3-interpolate": "*",
|
||||||
@@ -8870,6 +8894,7 @@
|
|||||||
"integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==",
|
"integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/body-parser": "*",
|
"@types/body-parser": "*",
|
||||||
"@types/express-serve-static-core": "^5.0.0",
|
"@types/express-serve-static-core": "^5.0.0",
|
||||||
@@ -8965,6 +8990,7 @@
|
|||||||
"integrity": "sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==",
|
"integrity": "sha512-oX8xrhvpiyRCQkG1MFchB09f+cXftgIXb3a7UUa4Y3wpmZPw5tyZGTLWhlESOLq1Rq6oDlc8npVU2/9xiCuXMA==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.18.0"
|
"undici-types": "~7.18.0"
|
||||||
}
|
}
|
||||||
@@ -8992,6 +9018,7 @@
|
|||||||
"integrity": "sha512-gT+oueVQkqnj6ajGJXblFR4iavIXWsGAFCk3dP4Kki5+a9R4NMt0JARdk6s8cUKcfUoqP5dAtDSLU8xYUTFV+Q==",
|
"integrity": "sha512-gT+oueVQkqnj6ajGJXblFR4iavIXWsGAFCk3dP4Kki5+a9R4NMt0JARdk6s8cUKcfUoqP5dAtDSLU8xYUTFV+Q==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "*",
|
"@types/node": "*",
|
||||||
"pg-protocol": "*",
|
"pg-protocol": "*",
|
||||||
@@ -9017,6 +9044,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
||||||
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
"integrity": "sha512-ilcTH/UniCkMdtexkoCN0bI7pMcJDvmQFPvuPvmEaYA/NSfFTAgdUSLAoVjaRJm7+6PvcM+q1zYOwS4wTYMF9w==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"csstype": "^3.2.2"
|
"csstype": "^3.2.2"
|
||||||
}
|
}
|
||||||
@@ -9027,6 +9055,7 @@
|
|||||||
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
|
"integrity": "sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@types/react": "^19.2.0"
|
"@types/react": "^19.2.0"
|
||||||
}
|
}
|
||||||
@@ -9113,8 +9142,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"optional": true,
|
"optional": true
|
||||||
"peer": true
|
|
||||||
},
|
},
|
||||||
"node_modules/@types/ws": {
|
"node_modules/@types/ws": {
|
||||||
"version": "8.18.1",
|
"version": "8.18.1",
|
||||||
@@ -9188,6 +9216,7 @@
|
|||||||
"integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==",
|
"integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.56.1",
|
"@typescript-eslint/scope-manager": "8.56.1",
|
||||||
"@typescript-eslint/types": "8.56.1",
|
"@typescript-eslint/types": "8.56.1",
|
||||||
@@ -9642,6 +9671,38 @@
|
|||||||
"win32"
|
"win32"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@xyflow/react": {
|
||||||
|
"version": "12.8.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@xyflow/react/-/react-12.8.4.tgz",
|
||||||
|
"integrity": "sha512-bqUu4T5QSHiCFPkoH+b+LROKwQJdLvcjhGbNW9c1dLafCBRjmH1IYz0zPE+lRDXCtQ9kRyFxz3tG19+8VORJ1w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@xyflow/system": "0.0.68",
|
||||||
|
"classcat": "^5.0.3",
|
||||||
|
"zustand": "^4.4.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=17",
|
||||||
|
"react-dom": ">=17"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@xyflow/system": {
|
||||||
|
"version": "0.0.68",
|
||||||
|
"resolved": "https://registry.npmjs.org/@xyflow/system/-/system-0.0.68.tgz",
|
||||||
|
"integrity": "sha512-QDG2wxIG4qX+uF8yzm1ULVZrcXX3MxPBoxv7O52FWsX87qIImOqifUhfa/TwsvLdzn7ic2DDBH1uI8TKbdNTYA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/d3-drag": "^3.0.7",
|
||||||
|
"@types/d3-interpolate": "^3.0.4",
|
||||||
|
"@types/d3-selection": "^3.0.10",
|
||||||
|
"@types/d3-transition": "^3.0.8",
|
||||||
|
"@types/d3-zoom": "^3.0.8",
|
||||||
|
"d3-drag": "^3.0.0",
|
||||||
|
"d3-interpolate": "^3.0.1",
|
||||||
|
"d3-selection": "^3.0.0",
|
||||||
|
"d3-zoom": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/accepts": {
|
"node_modules/accepts": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
|
||||||
@@ -9661,6 +9722,7 @@
|
|||||||
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -10109,6 +10171,7 @@
|
|||||||
"integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==",
|
"integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.26.0"
|
"@babel/types": "^7.26.0"
|
||||||
}
|
}
|
||||||
@@ -10180,6 +10243,7 @@
|
|||||||
"integrity": "sha512-Ba0KR+Fzxh2jDRhdg6TSH0SJGzb8C0aBY4hR8w8madIdIzzC6Y1+kx5qR6eS1Z+Gy20h6ZU28aeyg0z1VIrShQ==",
|
"integrity": "sha512-Ba0KR+Fzxh2jDRhdg6TSH0SJGzb8C0aBY4hR8w8madIdIzzC6Y1+kx5qR6eS1Z+Gy20h6ZU28aeyg0z1VIrShQ==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bindings": "^1.5.0",
|
"bindings": "^1.5.0",
|
||||||
"prebuild-install": "^7.1.1"
|
"prebuild-install": "^7.1.1"
|
||||||
@@ -10308,6 +10372,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"baseline-browser-mapping": "^2.9.0",
|
"baseline-browser-mapping": "^2.9.0",
|
||||||
"caniuse-lite": "^1.0.30001759",
|
"caniuse-lite": "^1.0.30001759",
|
||||||
@@ -10490,6 +10555,12 @@
|
|||||||
"url": "https://polar.sh/cva"
|
"url": "https://polar.sh/cva"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/classcat": {
|
||||||
|
"version": "5.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/classcat/-/classcat-5.0.5.tgz",
|
||||||
|
"integrity": "sha512-JhZUT7JFcQy/EzW605k/ktHtncoo9vnyW/2GspNYwFlN1C/WmjuV/xtS04e9SOkL2sTdw0VAZ2UGCcQ9lR6p6w==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/cli-spinners": {
|
"node_modules/cli-spinners": {
|
||||||
"version": "2.9.2",
|
"version": "2.9.2",
|
||||||
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
|
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
|
||||||
@@ -11214,6 +11285,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/d3-selection/-/d3-selection-3.0.0.tgz",
|
||||||
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
"integrity": "sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
}
|
}
|
||||||
@@ -11654,7 +11726,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.3.2.tgz",
|
||||||
"integrity": "sha512-6obghkliLdmKa56xdbLOpUZ43pAR6xFy1uOrxBaIDjT+yaRuuybLjGS9eVBoSR/UPU5fq3OXClEHLJNGvbxKpQ==",
|
"integrity": "sha512-6obghkliLdmKa56xdbLOpUZ43pAR6xFy1uOrxBaIDjT+yaRuuybLjGS9eVBoSR/UPU5fq3OXClEHLJNGvbxKpQ==",
|
||||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=20"
|
"node": ">=20"
|
||||||
},
|
},
|
||||||
@@ -12289,6 +12360,7 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"esbuild": "bin/esbuild"
|
"esbuild": "bin/esbuild"
|
||||||
},
|
},
|
||||||
@@ -12374,6 +12446,7 @@
|
|||||||
"integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==",
|
"integrity": "sha512-COV33RzXZkqhG9P2rZCFl9ZmJ7WL+gQSCRzE7RhkbclbQPtLAWReL7ysA0Sh4c8Im2U9ynybdR56PV0XcKvqaQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.8.0",
|
"@eslint-community/eslint-utils": "^4.8.0",
|
||||||
"@eslint-community/regexpp": "^4.12.2",
|
"@eslint-community/regexpp": "^4.12.2",
|
||||||
@@ -12510,6 +12583,7 @@
|
|||||||
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rtsao/scc": "^1.1.0",
|
"@rtsao/scc": "^1.1.0",
|
||||||
"array-includes": "^3.1.9",
|
"array-includes": "^3.1.9",
|
||||||
@@ -12903,6 +12977,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
|
||||||
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "^2.0.0",
|
"accepts": "^2.0.0",
|
||||||
"body-parser": "^2.2.1",
|
"body-parser": "^2.2.1",
|
||||||
@@ -15320,7 +15395,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz",
|
"resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz",
|
||||||
"integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==",
|
"integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dompurify": "3.2.7",
|
"dompurify": "3.2.7",
|
||||||
"marked": "14.0.0"
|
"marked": "14.0.0"
|
||||||
@@ -15331,7 +15405,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/marked/-/marked-14.0.0.tgz",
|
||||||
"integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",
|
"integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"marked": "bin/marked.js"
|
"marked": "bin/marked.js"
|
||||||
},
|
},
|
||||||
@@ -15419,6 +15492,7 @@
|
|||||||
"version": "15.5.12",
|
"version": "15.5.12",
|
||||||
"resolved": "https://registry.npmjs.org/next/-/next-15.5.12.tgz",
|
"resolved": "https://registry.npmjs.org/next/-/next-15.5.12.tgz",
|
||||||
"integrity": "sha512-Fi/wQ4Etlrn60rz78bebG1i1SR20QxvV8tVp6iJspjLUSHcZoeUXCt+vmWoEcza85ElZzExK/jJ/F6SvtGktjA==",
|
"integrity": "sha512-Fi/wQ4Etlrn60rz78bebG1i1SR20QxvV8tVp6iJspjLUSHcZoeUXCt+vmWoEcza85ElZzExK/jJ/F6SvtGktjA==",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@next/env": "15.5.12",
|
"@next/env": "15.5.12",
|
||||||
"@swc/helpers": "0.5.15",
|
"@swc/helpers": "0.5.15",
|
||||||
@@ -16377,6 +16451,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/pg/-/pg-8.20.0.tgz",
|
||||||
"integrity": "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA==",
|
"integrity": "sha512-ldhMxz2r8fl/6QkXnBD3CR9/xg694oT6DZQ2s6c/RI28OjtSOpxnPrUCGOBJ46RCUxcWdx3p6kw/xnDHjKvaRA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pg-connection-string": "^2.12.0",
|
"pg-connection-string": "^2.12.0",
|
||||||
"pg-pool": "^3.13.0",
|
"pg-pool": "^3.13.0",
|
||||||
@@ -16881,6 +16956,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz",
|
||||||
"integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==",
|
"integrity": "sha512-9nfp2hYpCwOjAN+8TZFGhtWEwgvWHXqESH8qT89AT/lWklpLON22Lc8pEtnpsZz7VmawabSU0gCjnj8aC0euHQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@@ -16912,6 +16988,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.4.tgz",
|
||||||
"integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==",
|
"integrity": "sha512-AXJdLo8kgMbimY95O2aKQqsz2iWi9jMgKJhRBAxECE4IFxfcazB2LmzloIoibJI3C12IlY20+KFaLv+71bUJeQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"scheduler": "^0.27.0"
|
"scheduler": "^0.27.0"
|
||||||
},
|
},
|
||||||
@@ -17204,6 +17281,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.2.tgz",
|
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.71.2.tgz",
|
||||||
"integrity": "sha512-1CHvcDYzuRUNOflt4MOq3ZM46AronNJtQ1S7tnX6YN4y72qhgiUItpacZUAQ0TyWYci3yz1X+rXaSxiuEm86PA==",
|
"integrity": "sha512-1CHvcDYzuRUNOflt4MOq3ZM46AronNJtQ1S7tnX6YN4y72qhgiUItpacZUAQ0TyWYci3yz1X+rXaSxiuEm86PA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
},
|
},
|
||||||
@@ -18665,7 +18743,8 @@
|
|||||||
"version": "4.2.1",
|
"version": "4.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.1.tgz",
|
||||||
"integrity": "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw==",
|
"integrity": "sha512-/tBrSQ36vCleJkAOsy9kbNTgaxvGbyOamC30PRePTQe/o1MFwEKHQk4Cn7BNGaPtjp+PuUrByJehM1hgxfq4sw==",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
"version": "2.3.0",
|
"version": "2.3.0",
|
||||||
@@ -19140,6 +19219,7 @@
|
|||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"devOptional": true,
|
"devOptional": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
@@ -19567,6 +19647,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz",
|
||||||
"integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==",
|
"integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@colors/colors": "^1.6.0",
|
"@colors/colors": "^1.6.0",
|
||||||
"@dabh/diagnostics": "^2.0.8",
|
"@dabh/diagnostics": "^2.0.8",
|
||||||
@@ -19773,6 +19854,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz",
|
||||||
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
|
"integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"funding": {
|
"funding": {
|
||||||
"url": "https://github.com/sponsors/colinhacks"
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
}
|
}
|
||||||
@@ -19788,6 +19870,34 @@
|
|||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"zod": "^3.25.0 || ^4.0.0"
|
"zod": "^3.25.0 || ^4.0.0"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zustand": {
|
||||||
|
"version": "4.5.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.7.tgz",
|
||||||
|
"integrity": "sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"use-sync-external-store": "^1.2.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.7.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": ">=16.8",
|
||||||
|
"immer": ">=9.0.6",
|
||||||
|
"react": ">=16.8"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"immer": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"react": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
"@tailwindcss/forms": "0.5.11",
|
"@tailwindcss/forms": "0.5.11",
|
||||||
"@tanstack/react-query": "5.90.21",
|
"@tanstack/react-query": "5.90.21",
|
||||||
"@tanstack/react-table": "8.21.3",
|
"@tanstack/react-table": "8.21.3",
|
||||||
|
"@xyflow/react": "^12.8.4",
|
||||||
"arctic": "3.7.0",
|
"arctic": "3.7.0",
|
||||||
"axios": "1.13.5",
|
"axios": "1.13.5",
|
||||||
"better-sqlite3": "11.9.1",
|
"better-sqlite3": "11.9.1",
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
import { Request } from "express";
|
import { Request } from "express";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { userActions, roleActions, userOrgs } from "@server/db";
|
import { userActions, roleActions } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export enum ActionsEnum {
|
export enum ActionsEnum {
|
||||||
createOrgUser = "createOrgUser",
|
createOrgUser = "createOrgUser",
|
||||||
@@ -53,6 +54,8 @@ export enum ActionsEnum {
|
|||||||
listRoleResources = "listRoleResources",
|
listRoleResources = "listRoleResources",
|
||||||
// listRoleActions = "listRoleActions",
|
// listRoleActions = "listRoleActions",
|
||||||
addUserRole = "addUserRole",
|
addUserRole = "addUserRole",
|
||||||
|
removeUserRole = "removeUserRole",
|
||||||
|
setUserOrgRoles = "setUserOrgRoles",
|
||||||
// addUserSite = "addUserSite",
|
// addUserSite = "addUserSite",
|
||||||
// addUserAction = "addUserAction",
|
// addUserAction = "addUserAction",
|
||||||
// removeUserAction = "removeUserAction",
|
// removeUserAction = "removeUserAction",
|
||||||
@@ -109,6 +112,10 @@ export enum ActionsEnum {
|
|||||||
listApiKeyActions = "listApiKeyActions",
|
listApiKeyActions = "listApiKeyActions",
|
||||||
listApiKeys = "listApiKeys",
|
listApiKeys = "listApiKeys",
|
||||||
getApiKey = "getApiKey",
|
getApiKey = "getApiKey",
|
||||||
|
createSiteProvisioningKey = "createSiteProvisioningKey",
|
||||||
|
listSiteProvisioningKeys = "listSiteProvisioningKeys",
|
||||||
|
updateSiteProvisioningKey = "updateSiteProvisioningKey",
|
||||||
|
deleteSiteProvisioningKey = "deleteSiteProvisioningKey",
|
||||||
getCertificate = "getCertificate",
|
getCertificate = "getCertificate",
|
||||||
restartCertificate = "restartCertificate",
|
restartCertificate = "restartCertificate",
|
||||||
billing = "billing",
|
billing = "billing",
|
||||||
@@ -154,29 +161,16 @@ export async function checkUserActionPermission(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let userOrgRoleId = req.userOrgRoleId;
|
let userOrgRoleIds = req.userOrgRoleIds;
|
||||||
|
|
||||||
// If userOrgRoleId is not available on the request, fetch it
|
if (userOrgRoleIds === undefined) {
|
||||||
if (userOrgRoleId === undefined) {
|
userOrgRoleIds = await getUserOrgRoleIds(userId, req.userOrgId!);
|
||||||
const userOrgRole = await db
|
if (userOrgRoleIds.length === 0) {
|
||||||
.select()
|
|
||||||
.from(userOrgs)
|
|
||||||
.where(
|
|
||||||
and(
|
|
||||||
eq(userOrgs.userId, userId),
|
|
||||||
eq(userOrgs.orgId, req.userOrgId!)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
if (userOrgRole.length === 0) {
|
|
||||||
throw createHttpError(
|
throw createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
"User does not have access to this organization"
|
"User does not have access to this organization"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
userOrgRoleId = userOrgRole[0].roleId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user has direct permission for the action in the current org
|
// Check if the user has direct permission for the action in the current org
|
||||||
@@ -187,7 +181,7 @@ export async function checkUserActionPermission(
|
|||||||
and(
|
and(
|
||||||
eq(userActions.userId, userId),
|
eq(userActions.userId, userId),
|
||||||
eq(userActions.actionId, actionId),
|
eq(userActions.actionId, actionId),
|
||||||
eq(userActions.orgId, req.userOrgId!) // TODO: we cant pass the org id if we are not checking the org
|
eq(userActions.orgId, req.userOrgId!)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
@@ -196,14 +190,14 @@ export async function checkUserActionPermission(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no direct permission, check role-based permission
|
// If no direct permission, check role-based permission (any of user's roles)
|
||||||
const roleActionPermission = await db
|
const roleActionPermission = await db
|
||||||
.select()
|
.select()
|
||||||
.from(roleActions)
|
.from(roleActions)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(roleActions.actionId, actionId),
|
eq(roleActions.actionId, actionId),
|
||||||
eq(roleActions.roleId, userOrgRoleId!),
|
inArray(roleActions.roleId, userOrgRoleIds),
|
||||||
eq(roleActions.orgId, req.userOrgId!)
|
eq(roleActions.orgId, req.userOrgId!)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,26 +1,29 @@
|
|||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import { roleResources, userResources } from "@server/db";
|
import { roleResources, userResources } from "@server/db";
|
||||||
|
|
||||||
export async function canUserAccessResource({
|
export async function canUserAccessResource({
|
||||||
userId,
|
userId,
|
||||||
resourceId,
|
resourceId,
|
||||||
roleId
|
roleIds
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
resourceId: number;
|
resourceId: number;
|
||||||
roleId: number;
|
roleIds: number[];
|
||||||
}): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
const roleResourceAccess = await db
|
const roleResourceAccess =
|
||||||
.select()
|
roleIds.length > 0
|
||||||
.from(roleResources)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleResources)
|
||||||
eq(roleResources.resourceId, resourceId),
|
.where(
|
||||||
eq(roleResources.roleId, roleId)
|
and(
|
||||||
)
|
eq(roleResources.resourceId, resourceId),
|
||||||
)
|
inArray(roleResources.roleId, roleIds)
|
||||||
.limit(1);
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (roleResourceAccess.length > 0) {
|
if (roleResourceAccess.length > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,26 +1,29 @@
|
|||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import { roleSiteResources, userSiteResources } from "@server/db";
|
import { roleSiteResources, userSiteResources } from "@server/db";
|
||||||
|
|
||||||
export async function canUserAccessSiteResource({
|
export async function canUserAccessSiteResource({
|
||||||
userId,
|
userId,
|
||||||
resourceId,
|
resourceId,
|
||||||
roleId
|
roleIds
|
||||||
}: {
|
}: {
|
||||||
userId: string;
|
userId: string;
|
||||||
resourceId: number;
|
resourceId: number;
|
||||||
roleId: number;
|
roleIds: number[];
|
||||||
}): Promise<boolean> {
|
}): Promise<boolean> {
|
||||||
const roleResourceAccess = await db
|
const roleResourceAccess =
|
||||||
.select()
|
roleIds.length > 0
|
||||||
.from(roleSiteResources)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleSiteResources)
|
||||||
eq(roleSiteResources.siteResourceId, resourceId),
|
.where(
|
||||||
eq(roleSiteResources.roleId, roleId)
|
and(
|
||||||
)
|
eq(roleSiteResources.siteResourceId, resourceId),
|
||||||
)
|
inArray(roleSiteResources.roleId, roleIds)
|
||||||
.limit(1);
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (roleResourceAccess.length > 0) {
|
if (roleResourceAccess.length > 0) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { flushBandwidthToDb } from "@server/routers/newt/handleReceiveBandwidthMessage";
|
import { flushBandwidthToDb } from "@server/routers/newt/handleReceiveBandwidthMessage";
|
||||||
|
import { flushConnectionLogToDb } from "#dynamic/routers/newt";
|
||||||
import { flushSiteBandwidthToDb } from "@server/routers/gerbil/receiveBandwidth";
|
import { flushSiteBandwidthToDb } from "@server/routers/gerbil/receiveBandwidth";
|
||||||
import { stopPingAccumulator } from "@server/routers/newt/pingAccumulator";
|
import { stopPingAccumulator } from "@server/routers/newt/pingAccumulator";
|
||||||
import { cleanup as wsCleanup } from "#dynamic/routers/ws";
|
import { cleanup as wsCleanup } from "#dynamic/routers/ws";
|
||||||
@@ -6,6 +7,7 @@ import { cleanup as wsCleanup } from "#dynamic/routers/ws";
|
|||||||
async function cleanup() {
|
async function cleanup() {
|
||||||
await stopPingAccumulator();
|
await stopPingAccumulator();
|
||||||
await flushBandwidthToDb();
|
await flushBandwidthToDb();
|
||||||
|
await flushConnectionLogToDb();
|
||||||
await flushSiteBandwidthToDb();
|
await flushSiteBandwidthToDb();
|
||||||
await wsCleanup();
|
await wsCleanup();
|
||||||
|
|
||||||
@@ -16,4 +18,4 @@ export async function initCleanup() {
|
|||||||
// Handle process termination
|
// Handle process termination
|
||||||
process.on("SIGTERM", () => cleanup());
|
process.on("SIGTERM", () => cleanup());
|
||||||
process.on("SIGINT", () => cleanup());
|
process.on("SIGINT", () => cleanup());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import {
|
|||||||
bigint,
|
bigint,
|
||||||
real,
|
real,
|
||||||
text,
|
text,
|
||||||
index
|
index,
|
||||||
|
primaryKey
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { InferSelectModel } from "drizzle-orm";
|
import { InferSelectModel } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
@@ -17,7 +18,9 @@ import {
|
|||||||
users,
|
users,
|
||||||
exitNodes,
|
exitNodes,
|
||||||
sessions,
|
sessions,
|
||||||
clients
|
clients,
|
||||||
|
siteResources,
|
||||||
|
sites
|
||||||
} from "./schema";
|
} from "./schema";
|
||||||
|
|
||||||
export const certificates = pgTable("certificates", {
|
export const certificates = pgTable("certificates", {
|
||||||
@@ -89,7 +92,9 @@ export const subscriptions = pgTable("subscriptions", {
|
|||||||
|
|
||||||
export const subscriptionItems = pgTable("subscriptionItems", {
|
export const subscriptionItems = pgTable("subscriptionItems", {
|
||||||
subscriptionItemId: serial("subscriptionItemId").primaryKey(),
|
subscriptionItemId: serial("subscriptionItemId").primaryKey(),
|
||||||
stripeSubscriptionItemId: varchar("stripeSubscriptionItemId", { length: 255 }),
|
stripeSubscriptionItemId: varchar("stripeSubscriptionItemId", {
|
||||||
|
length: 255
|
||||||
|
}),
|
||||||
subscriptionId: varchar("subscriptionId", { length: 255 })
|
subscriptionId: varchar("subscriptionId", { length: 255 })
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => subscriptions.subscriptionId, {
|
.references(() => subscriptions.subscriptionId, {
|
||||||
@@ -302,6 +307,45 @@ export const accessAuditLog = pgTable(
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const connectionAuditLog = pgTable(
|
||||||
|
"connectionAuditLog",
|
||||||
|
{
|
||||||
|
id: serial("id").primaryKey(),
|
||||||
|
sessionId: text("sessionId").notNull(),
|
||||||
|
siteResourceId: integer("siteResourceId").references(
|
||||||
|
() => siteResources.siteResourceId,
|
||||||
|
{ onDelete: "cascade" }
|
||||||
|
),
|
||||||
|
orgId: text("orgId").references(() => orgs.orgId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
siteId: integer("siteId").references(() => sites.siteId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
clientId: integer("clientId").references(() => clients.clientId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
userId: text("userId").references(() => users.userId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
sourceAddr: text("sourceAddr").notNull(),
|
||||||
|
destAddr: text("destAddr").notNull(),
|
||||||
|
protocol: text("protocol").notNull(),
|
||||||
|
startedAt: integer("startedAt").notNull(),
|
||||||
|
endedAt: integer("endedAt"),
|
||||||
|
bytesTx: integer("bytesTx"),
|
||||||
|
bytesRx: integer("bytesRx")
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
index("idx_accessAuditLog_startedAt").on(table.startedAt),
|
||||||
|
index("idx_accessAuditLog_org_startedAt").on(
|
||||||
|
table.orgId,
|
||||||
|
table.startedAt
|
||||||
|
),
|
||||||
|
index("idx_accessAuditLog_siteResourceId").on(table.siteResourceId)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
export const approvals = pgTable("approvals", {
|
export const approvals = pgTable("approvals", {
|
||||||
approvalId: serial("approvalId").primaryKey(),
|
approvalId: serial("approvalId").primaryKey(),
|
||||||
timestamp: integer("timestamp").notNull(), // this is EPOCH time in seconds
|
timestamp: integer("timestamp").notNull(), // this is EPOCH time in seconds
|
||||||
@@ -329,13 +373,48 @@ export const approvals = pgTable("approvals", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const bannedEmails = pgTable("bannedEmails", {
|
export const bannedEmails = pgTable("bannedEmails", {
|
||||||
email: varchar("email", { length: 255 }).primaryKey(),
|
email: varchar("email", { length: 255 }).primaryKey()
|
||||||
});
|
});
|
||||||
|
|
||||||
export const bannedIps = pgTable("bannedIps", {
|
export const bannedIps = pgTable("bannedIps", {
|
||||||
ip: varchar("ip", { length: 255 }).primaryKey(),
|
ip: varchar("ip", { length: 255 }).primaryKey()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const siteProvisioningKeys = pgTable("siteProvisioningKeys", {
|
||||||
|
siteProvisioningKeyId: varchar("siteProvisioningKeyId", {
|
||||||
|
length: 255
|
||||||
|
}).primaryKey(),
|
||||||
|
name: varchar("name", { length: 255 }).notNull(),
|
||||||
|
siteProvisioningKeyHash: text("siteProvisioningKeyHash").notNull(),
|
||||||
|
lastChars: varchar("lastChars", { length: 4 }).notNull(),
|
||||||
|
createdAt: varchar("dateCreated", { length: 255 }).notNull(),
|
||||||
|
lastUsed: varchar("lastUsed", { length: 255 }),
|
||||||
|
maxBatchSize: integer("maxBatchSize"), // null = no limit
|
||||||
|
numUsed: integer("numUsed").notNull().default(0),
|
||||||
|
validUntil: varchar("validUntil", { length: 255 })
|
||||||
|
});
|
||||||
|
|
||||||
|
export const siteProvisioningKeyOrg = pgTable(
|
||||||
|
"siteProvisioningKeyOrg",
|
||||||
|
{
|
||||||
|
siteProvisioningKeyId: varchar("siteProvisioningKeyId", {
|
||||||
|
length: 255
|
||||||
|
})
|
||||||
|
.notNull()
|
||||||
|
.references(() => siteProvisioningKeys.siteProvisioningKeyId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
orgId: varchar("orgId", { length: 255 })
|
||||||
|
.notNull()
|
||||||
|
.references(() => orgs.orgId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
primaryKey({
|
||||||
|
columns: [table.siteProvisioningKeyId, table.orgId]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
export type Approval = InferSelectModel<typeof approvals>;
|
export type Approval = InferSelectModel<typeof approvals>;
|
||||||
export type Limit = InferSelectModel<typeof limits>;
|
export type Limit = InferSelectModel<typeof limits>;
|
||||||
export type Account = InferSelectModel<typeof account>;
|
export type Account = InferSelectModel<typeof account>;
|
||||||
@@ -357,3 +436,4 @@ export type LoginPage = InferSelectModel<typeof loginPage>;
|
|||||||
export type LoginPageBranding = InferSelectModel<typeof loginPageBranding>;
|
export type LoginPageBranding = InferSelectModel<typeof loginPageBranding>;
|
||||||
export type ActionAuditLog = InferSelectModel<typeof actionAuditLog>;
|
export type ActionAuditLog = InferSelectModel<typeof actionAuditLog>;
|
||||||
export type AccessAuditLog = InferSelectModel<typeof accessAuditLog>;
|
export type AccessAuditLog = InferSelectModel<typeof accessAuditLog>;
|
||||||
|
export type ConnectionAuditLog = InferSelectModel<typeof connectionAuditLog>;
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import {
|
|||||||
index,
|
index,
|
||||||
integer,
|
integer,
|
||||||
pgTable,
|
pgTable,
|
||||||
|
primaryKey,
|
||||||
real,
|
real,
|
||||||
serial,
|
serial,
|
||||||
text,
|
text,
|
||||||
|
unique,
|
||||||
varchar
|
varchar
|
||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
|
|
||||||
@@ -55,6 +57,9 @@ export const orgs = pgTable("orgs", {
|
|||||||
settingsLogRetentionDaysAction: integer("settingsLogRetentionDaysAction") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
settingsLogRetentionDaysAction: integer("settingsLogRetentionDaysAction") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
||||||
.notNull()
|
.notNull()
|
||||||
.default(0),
|
.default(0),
|
||||||
|
settingsLogRetentionDaysConnection: integer("settingsLogRetentionDaysConnection") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
||||||
|
.notNull()
|
||||||
|
.default(0),
|
||||||
sshCaPrivateKey: text("sshCaPrivateKey"), // Encrypted SSH CA private key (PEM format)
|
sshCaPrivateKey: text("sshCaPrivateKey"), // Encrypted SSH CA private key (PEM format)
|
||||||
sshCaPublicKey: text("sshCaPublicKey"), // SSH CA public key (OpenSSH format)
|
sshCaPublicKey: text("sshCaPublicKey"), // SSH CA public key (OpenSSH format)
|
||||||
isBillingOrg: boolean("isBillingOrg"),
|
isBillingOrg: boolean("isBillingOrg"),
|
||||||
@@ -335,9 +340,6 @@ export const userOrgs = pgTable("userOrgs", {
|
|||||||
onDelete: "cascade"
|
onDelete: "cascade"
|
||||||
})
|
})
|
||||||
.notNull(),
|
.notNull(),
|
||||||
roleId: integer("roleId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => roles.roleId),
|
|
||||||
isOwner: boolean("isOwner").notNull().default(false),
|
isOwner: boolean("isOwner").notNull().default(false),
|
||||||
autoProvisioned: boolean("autoProvisioned").default(false),
|
autoProvisioned: boolean("autoProvisioned").default(false),
|
||||||
pamUsername: varchar("pamUsername") // cleaned username for ssh and such
|
pamUsername: varchar("pamUsername") // cleaned username for ssh and such
|
||||||
@@ -386,6 +388,22 @@ export const roles = pgTable("roles", {
|
|||||||
sshUnixGroups: text("sshUnixGroups").default("[]")
|
sshUnixGroups: text("sshUnixGroups").default("[]")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userOrgRoles = pgTable(
|
||||||
|
"userOrgRoles",
|
||||||
|
{
|
||||||
|
userId: varchar("userId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
|
orgId: varchar("orgId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
|
roleId: integer("roleId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => roles.roleId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(t) => [unique().on(t.userId, t.orgId, t.roleId)]
|
||||||
|
);
|
||||||
|
|
||||||
export const roleActions = pgTable("roleActions", {
|
export const roleActions = pgTable("roleActions", {
|
||||||
roleId: integer("roleId")
|
roleId: integer("roleId")
|
||||||
.notNull()
|
.notNull()
|
||||||
@@ -453,12 +471,22 @@ export const userInvites = pgTable("userInvites", {
|
|||||||
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
email: varchar("email").notNull(),
|
email: varchar("email").notNull(),
|
||||||
expiresAt: bigint("expiresAt", { mode: "number" }).notNull(),
|
expiresAt: bigint("expiresAt", { mode: "number" }).notNull(),
|
||||||
tokenHash: varchar("token").notNull(),
|
tokenHash: varchar("token").notNull()
|
||||||
roleId: integer("roleId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => roles.roleId, { onDelete: "cascade" })
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userInviteRoles = pgTable(
|
||||||
|
"userInviteRoles",
|
||||||
|
{
|
||||||
|
inviteId: varchar("inviteId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => userInvites.inviteId, { onDelete: "cascade" }),
|
||||||
|
roleId: integer("roleId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => roles.roleId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(t) => [primaryKey({ columns: [t.inviteId, t.roleId] })]
|
||||||
|
);
|
||||||
|
|
||||||
export const resourcePincode = pgTable("resourcePincode", {
|
export const resourcePincode = pgTable("resourcePincode", {
|
||||||
pincodeId: serial("pincodeId").primaryKey(),
|
pincodeId: serial("pincodeId").primaryKey(),
|
||||||
resourceId: integer("resourceId")
|
resourceId: integer("resourceId")
|
||||||
@@ -1034,7 +1062,9 @@ export type UserSite = InferSelectModel<typeof userSites>;
|
|||||||
export type RoleResource = InferSelectModel<typeof roleResources>;
|
export type RoleResource = InferSelectModel<typeof roleResources>;
|
||||||
export type UserResource = InferSelectModel<typeof userResources>;
|
export type UserResource = InferSelectModel<typeof userResources>;
|
||||||
export type UserInvite = InferSelectModel<typeof userInvites>;
|
export type UserInvite = InferSelectModel<typeof userInvites>;
|
||||||
|
export type UserInviteRole = InferSelectModel<typeof userInviteRoles>;
|
||||||
export type UserOrg = InferSelectModel<typeof userOrgs>;
|
export type UserOrg = InferSelectModel<typeof userOrgs>;
|
||||||
|
export type UserOrgRole = InferSelectModel<typeof userOrgRoles>;
|
||||||
export type ResourceSession = InferSelectModel<typeof resourceSessions>;
|
export type ResourceSession = InferSelectModel<typeof resourceSessions>;
|
||||||
export type ResourcePincode = InferSelectModel<typeof resourcePincode>;
|
export type ResourcePincode = InferSelectModel<typeof resourcePincode>;
|
||||||
export type ResourcePassword = InferSelectModel<typeof resourcePassword>;
|
export type ResourcePassword = InferSelectModel<typeof resourcePassword>;
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import { db, loginPage, LoginPage, loginPageOrg, Org, orgs, roles } from "@server/db";
|
import {
|
||||||
|
db,
|
||||||
|
loginPage,
|
||||||
|
LoginPage,
|
||||||
|
loginPageOrg,
|
||||||
|
Org,
|
||||||
|
orgs,
|
||||||
|
roles
|
||||||
|
} from "@server/db";
|
||||||
import {
|
import {
|
||||||
Resource,
|
Resource,
|
||||||
ResourcePassword,
|
ResourcePassword,
|
||||||
@@ -12,13 +20,12 @@ import {
|
|||||||
resources,
|
resources,
|
||||||
roleResources,
|
roleResources,
|
||||||
sessions,
|
sessions,
|
||||||
userOrgs,
|
|
||||||
userResources,
|
userResources,
|
||||||
users,
|
users,
|
||||||
ResourceHeaderAuthExtendedCompatibility,
|
ResourceHeaderAuthExtendedCompatibility,
|
||||||
resourceHeaderAuthExtendedCompatibility
|
resourceHeaderAuthExtendedCompatibility
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
|
|
||||||
export type ResourceWithAuth = {
|
export type ResourceWithAuth = {
|
||||||
resource: Resource | null;
|
resource: Resource | null;
|
||||||
@@ -104,24 +111,15 @@ export async function getUserSessionWithUser(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user organization role
|
* Get role name by role ID (for display).
|
||||||
*/
|
*/
|
||||||
export async function getUserOrgRole(userId: string, orgId: string) {
|
export async function getRoleName(roleId: number): Promise<string | null> {
|
||||||
const userOrgRole = await db
|
const [row] = await db
|
||||||
.select({
|
.select({ name: roles.name })
|
||||||
userId: userOrgs.userId,
|
.from(roles)
|
||||||
orgId: userOrgs.orgId,
|
.where(eq(roles.roleId, roleId))
|
||||||
roleId: userOrgs.roleId,
|
|
||||||
isOwner: userOrgs.isOwner,
|
|
||||||
autoProvisioned: userOrgs.autoProvisioned,
|
|
||||||
roleName: roles.name
|
|
||||||
})
|
|
||||||
.from(userOrgs)
|
|
||||||
.where(and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, orgId)))
|
|
||||||
.leftJoin(roles, eq(userOrgs.roleId, roles.roleId))
|
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
return row?.name ?? null;
|
||||||
return userOrgRole.length > 0 ? userOrgRole[0] : null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,7 +127,7 @@ export async function getUserOrgRole(userId: string, orgId: string) {
|
|||||||
*/
|
*/
|
||||||
export async function getRoleResourceAccess(
|
export async function getRoleResourceAccess(
|
||||||
resourceId: number,
|
resourceId: number,
|
||||||
roleId: number
|
roleIds: number[]
|
||||||
) {
|
) {
|
||||||
const roleResourceAccess = await db
|
const roleResourceAccess = await db
|
||||||
.select()
|
.select()
|
||||||
@@ -137,12 +135,11 @@ export async function getRoleResourceAccess(
|
|||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(roleResources.resourceId, resourceId),
|
eq(roleResources.resourceId, resourceId),
|
||||||
eq(roleResources.roleId, roleId)
|
inArray(roleResources.roleId, roleIds)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
return roleResourceAccess.length > 0 ? roleResourceAccess[0] : null;
|
return roleResourceAccess.length > 0 ? roleResourceAccess : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,11 +2,12 @@ import { InferSelectModel } from "drizzle-orm";
|
|||||||
import {
|
import {
|
||||||
index,
|
index,
|
||||||
integer,
|
integer,
|
||||||
|
primaryKey,
|
||||||
real,
|
real,
|
||||||
sqliteTable,
|
sqliteTable,
|
||||||
text
|
text
|
||||||
} from "drizzle-orm/sqlite-core";
|
} from "drizzle-orm/sqlite-core";
|
||||||
import { clients, domains, exitNodes, orgs, sessions, users } from "./schema";
|
import { clients, domains, exitNodes, orgs, sessions, siteResources, sites, users } from "./schema";
|
||||||
|
|
||||||
export const certificates = sqliteTable("certificates", {
|
export const certificates = sqliteTable("certificates", {
|
||||||
certId: integer("certId").primaryKey({ autoIncrement: true }),
|
certId: integer("certId").primaryKey({ autoIncrement: true }),
|
||||||
@@ -294,6 +295,45 @@ export const accessAuditLog = sqliteTable(
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const connectionAuditLog = sqliteTable(
|
||||||
|
"connectionAuditLog",
|
||||||
|
{
|
||||||
|
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||||
|
sessionId: text("sessionId").notNull(),
|
||||||
|
siteResourceId: integer("siteResourceId").references(
|
||||||
|
() => siteResources.siteResourceId,
|
||||||
|
{ onDelete: "cascade" }
|
||||||
|
),
|
||||||
|
orgId: text("orgId").references(() => orgs.orgId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
siteId: integer("siteId").references(() => sites.siteId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
clientId: integer("clientId").references(() => clients.clientId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
userId: text("userId").references(() => users.userId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
sourceAddr: text("sourceAddr").notNull(),
|
||||||
|
destAddr: text("destAddr").notNull(),
|
||||||
|
protocol: text("protocol").notNull(),
|
||||||
|
startedAt: integer("startedAt").notNull(),
|
||||||
|
endedAt: integer("endedAt"),
|
||||||
|
bytesTx: integer("bytesTx"),
|
||||||
|
bytesRx: integer("bytesRx")
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
index("idx_accessAuditLog_startedAt").on(table.startedAt),
|
||||||
|
index("idx_accessAuditLog_org_startedAt").on(
|
||||||
|
table.orgId,
|
||||||
|
table.startedAt
|
||||||
|
),
|
||||||
|
index("idx_accessAuditLog_siteResourceId").on(table.siteResourceId)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
export const approvals = sqliteTable("approvals", {
|
export const approvals = sqliteTable("approvals", {
|
||||||
approvalId: integer("approvalId").primaryKey({ autoIncrement: true }),
|
approvalId: integer("approvalId").primaryKey({ autoIncrement: true }),
|
||||||
timestamp: integer("timestamp").notNull(), // this is EPOCH time in seconds
|
timestamp: integer("timestamp").notNull(), // this is EPOCH time in seconds
|
||||||
@@ -318,7 +358,6 @@ export const approvals = sqliteTable("approvals", {
|
|||||||
.notNull()
|
.notNull()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export const bannedEmails = sqliteTable("bannedEmails", {
|
export const bannedEmails = sqliteTable("bannedEmails", {
|
||||||
email: text("email").primaryKey()
|
email: text("email").primaryKey()
|
||||||
});
|
});
|
||||||
@@ -327,6 +366,37 @@ export const bannedIps = sqliteTable("bannedIps", {
|
|||||||
ip: text("ip").primaryKey()
|
ip: text("ip").primaryKey()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const siteProvisioningKeys = sqliteTable("siteProvisioningKeys", {
|
||||||
|
siteProvisioningKeyId: text("siteProvisioningKeyId").primaryKey(),
|
||||||
|
name: text("name").notNull(),
|
||||||
|
siteProvisioningKeyHash: text("siteProvisioningKeyHash").notNull(),
|
||||||
|
lastChars: text("lastChars").notNull(),
|
||||||
|
createdAt: text("dateCreated").notNull(),
|
||||||
|
lastUsed: text("lastUsed"),
|
||||||
|
maxBatchSize: integer("maxBatchSize"), // null = no limit
|
||||||
|
numUsed: integer("numUsed").notNull().default(0),
|
||||||
|
validUntil: text("validUntil")
|
||||||
|
});
|
||||||
|
|
||||||
|
export const siteProvisioningKeyOrg = sqliteTable(
|
||||||
|
"siteProvisioningKeyOrg",
|
||||||
|
{
|
||||||
|
siteProvisioningKeyId: text("siteProvisioningKeyId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => siteProvisioningKeys.siteProvisioningKeyId, {
|
||||||
|
onDelete: "cascade"
|
||||||
|
}),
|
||||||
|
orgId: text("orgId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => orgs.orgId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(table) => [
|
||||||
|
primaryKey({
|
||||||
|
columns: [table.siteProvisioningKeyId, table.orgId]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
export type Approval = InferSelectModel<typeof approvals>;
|
export type Approval = InferSelectModel<typeof approvals>;
|
||||||
export type Limit = InferSelectModel<typeof limits>;
|
export type Limit = InferSelectModel<typeof limits>;
|
||||||
export type Account = InferSelectModel<typeof account>;
|
export type Account = InferSelectModel<typeof account>;
|
||||||
@@ -348,3 +418,4 @@ export type LoginPage = InferSelectModel<typeof loginPage>;
|
|||||||
export type LoginPageBranding = InferSelectModel<typeof loginPageBranding>;
|
export type LoginPageBranding = InferSelectModel<typeof loginPageBranding>;
|
||||||
export type ActionAuditLog = InferSelectModel<typeof actionAuditLog>;
|
export type ActionAuditLog = InferSelectModel<typeof actionAuditLog>;
|
||||||
export type AccessAuditLog = InferSelectModel<typeof accessAuditLog>;
|
export type AccessAuditLog = InferSelectModel<typeof accessAuditLog>;
|
||||||
|
export type ConnectionAuditLog = InferSelectModel<typeof connectionAuditLog>;
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
import { randomUUID } from "crypto";
|
import { randomUUID } from "crypto";
|
||||||
import { InferSelectModel } from "drizzle-orm";
|
import { InferSelectModel } from "drizzle-orm";
|
||||||
import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
import {
|
||||||
|
index,
|
||||||
|
integer,
|
||||||
|
primaryKey,
|
||||||
|
sqliteTable,
|
||||||
|
text,
|
||||||
|
unique
|
||||||
|
} from "drizzle-orm/sqlite-core";
|
||||||
|
|
||||||
export const domains = sqliteTable("domains", {
|
export const domains = sqliteTable("domains", {
|
||||||
domainId: text("domainId").primaryKey(),
|
domainId: text("domainId").primaryKey(),
|
||||||
@@ -47,6 +54,9 @@ export const orgs = sqliteTable("orgs", {
|
|||||||
settingsLogRetentionDaysAction: integer("settingsLogRetentionDaysAction") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
settingsLogRetentionDaysAction: integer("settingsLogRetentionDaysAction") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
||||||
.notNull()
|
.notNull()
|
||||||
.default(0),
|
.default(0),
|
||||||
|
settingsLogRetentionDaysConnection: integer("settingsLogRetentionDaysConnection") // where 0 = dont keep logs and -1 = keep forever and 9001 = end of the following year
|
||||||
|
.notNull()
|
||||||
|
.default(0),
|
||||||
sshCaPrivateKey: text("sshCaPrivateKey"), // Encrypted SSH CA private key (PEM format)
|
sshCaPrivateKey: text("sshCaPrivateKey"), // Encrypted SSH CA private key (PEM format)
|
||||||
sshCaPublicKey: text("sshCaPublicKey"), // SSH CA public key (OpenSSH format)
|
sshCaPublicKey: text("sshCaPublicKey"), // SSH CA public key (OpenSSH format)
|
||||||
isBillingOrg: integer("isBillingOrg", { mode: "boolean" }),
|
isBillingOrg: integer("isBillingOrg", { mode: "boolean" }),
|
||||||
@@ -643,9 +653,6 @@ export const userOrgs = sqliteTable("userOrgs", {
|
|||||||
onDelete: "cascade"
|
onDelete: "cascade"
|
||||||
})
|
})
|
||||||
.notNull(),
|
.notNull(),
|
||||||
roleId: integer("roleId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => roles.roleId),
|
|
||||||
isOwner: integer("isOwner", { mode: "boolean" }).notNull().default(false),
|
isOwner: integer("isOwner", { mode: "boolean" }).notNull().default(false),
|
||||||
autoProvisioned: integer("autoProvisioned", {
|
autoProvisioned: integer("autoProvisioned", {
|
||||||
mode: "boolean"
|
mode: "boolean"
|
||||||
@@ -700,6 +707,22 @@ export const roles = sqliteTable("roles", {
|
|||||||
sshUnixGroups: text("sshUnixGroups").default("[]")
|
sshUnixGroups: text("sshUnixGroups").default("[]")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userOrgRoles = sqliteTable(
|
||||||
|
"userOrgRoles",
|
||||||
|
{
|
||||||
|
userId: text("userId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => users.userId, { onDelete: "cascade" }),
|
||||||
|
orgId: text("orgId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
|
roleId: integer("roleId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => roles.roleId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(t) => [unique().on(t.userId, t.orgId, t.roleId)]
|
||||||
|
);
|
||||||
|
|
||||||
export const roleActions = sqliteTable("roleActions", {
|
export const roleActions = sqliteTable("roleActions", {
|
||||||
roleId: integer("roleId")
|
roleId: integer("roleId")
|
||||||
.notNull()
|
.notNull()
|
||||||
@@ -785,12 +808,22 @@ export const userInvites = sqliteTable("userInvites", {
|
|||||||
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
.references(() => orgs.orgId, { onDelete: "cascade" }),
|
||||||
email: text("email").notNull(),
|
email: text("email").notNull(),
|
||||||
expiresAt: integer("expiresAt").notNull(),
|
expiresAt: integer("expiresAt").notNull(),
|
||||||
tokenHash: text("token").notNull(),
|
tokenHash: text("token").notNull()
|
||||||
roleId: integer("roleId")
|
|
||||||
.notNull()
|
|
||||||
.references(() => roles.roleId, { onDelete: "cascade" })
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userInviteRoles = sqliteTable(
|
||||||
|
"userInviteRoles",
|
||||||
|
{
|
||||||
|
inviteId: text("inviteId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => userInvites.inviteId, { onDelete: "cascade" }),
|
||||||
|
roleId: integer("roleId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => roles.roleId, { onDelete: "cascade" })
|
||||||
|
},
|
||||||
|
(t) => [primaryKey({ columns: [t.inviteId, t.roleId] })]
|
||||||
|
);
|
||||||
|
|
||||||
export const resourcePincode = sqliteTable("resourcePincode", {
|
export const resourcePincode = sqliteTable("resourcePincode", {
|
||||||
pincodeId: integer("pincodeId").primaryKey({
|
pincodeId: integer("pincodeId").primaryKey({
|
||||||
autoIncrement: true
|
autoIncrement: true
|
||||||
@@ -1133,7 +1166,9 @@ export type UserSite = InferSelectModel<typeof userSites>;
|
|||||||
export type RoleResource = InferSelectModel<typeof roleResources>;
|
export type RoleResource = InferSelectModel<typeof roleResources>;
|
||||||
export type UserResource = InferSelectModel<typeof userResources>;
|
export type UserResource = InferSelectModel<typeof userResources>;
|
||||||
export type UserInvite = InferSelectModel<typeof userInvites>;
|
export type UserInvite = InferSelectModel<typeof userInvites>;
|
||||||
|
export type UserInviteRole = InferSelectModel<typeof userInviteRoles>;
|
||||||
export type UserOrg = InferSelectModel<typeof userOrgs>;
|
export type UserOrg = InferSelectModel<typeof userOrgs>;
|
||||||
|
export type UserOrgRole = InferSelectModel<typeof userOrgRoles>;
|
||||||
export type ResourceSession = InferSelectModel<typeof resourceSessions>;
|
export type ResourceSession = InferSelectModel<typeof resourceSessions>;
|
||||||
export type ResourcePincode = InferSelectModel<typeof resourcePincode>;
|
export type ResourcePincode = InferSelectModel<typeof resourcePincode>;
|
||||||
export type ResourcePassword = InferSelectModel<typeof resourcePassword>;
|
export type ResourcePassword = InferSelectModel<typeof resourcePassword>;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ declare global {
|
|||||||
session: Session;
|
session: Session;
|
||||||
userOrg?: UserOrg;
|
userOrg?: UserOrg;
|
||||||
apiKeyOrg?: ApiKeyOrg;
|
apiKeyOrg?: ApiKeyOrg;
|
||||||
userOrgRoleId?: number;
|
userOrgRoleIds?: number[];
|
||||||
userOrgId?: string;
|
userOrgId?: string;
|
||||||
userOrgIds?: string[];
|
userOrgIds?: string[];
|
||||||
remoteExitNode?: RemoteExitNode;
|
remoteExitNode?: RemoteExitNode;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export enum TierFeature {
|
|||||||
LogExport = "logExport",
|
LogExport = "logExport",
|
||||||
AccessLogs = "accessLogs", // set the retention period to none on downgrade
|
AccessLogs = "accessLogs", // set the retention period to none on downgrade
|
||||||
ActionLogs = "actionLogs", // set the retention period to none on downgrade
|
ActionLogs = "actionLogs", // set the retention period to none on downgrade
|
||||||
|
ConnectionLogs = "connectionLogs",
|
||||||
RotateCredentials = "rotateCredentials",
|
RotateCredentials = "rotateCredentials",
|
||||||
MaintencePage = "maintencePage", // handle downgrade
|
MaintencePage = "maintencePage", // handle downgrade
|
||||||
DevicePosture = "devicePosture",
|
DevicePosture = "devicePosture",
|
||||||
@@ -15,7 +16,9 @@ export enum TierFeature {
|
|||||||
SessionDurationPolicies = "sessionDurationPolicies", // handle downgrade by setting to default duration
|
SessionDurationPolicies = "sessionDurationPolicies", // handle downgrade by setting to default duration
|
||||||
PasswordExpirationPolicies = "passwordExpirationPolicies", // handle downgrade by setting to default duration
|
PasswordExpirationPolicies = "passwordExpirationPolicies", // handle downgrade by setting to default duration
|
||||||
AutoProvisioning = "autoProvisioning", // handle downgrade by disabling auto provisioning
|
AutoProvisioning = "autoProvisioning", // handle downgrade by disabling auto provisioning
|
||||||
SshPam = "sshPam"
|
SshPam = "sshPam",
|
||||||
|
FullRbac = "fullRbac",
|
||||||
|
SiteProvisioningKeys = "siteProvisioningKeys" // handle downgrade by revoking keys if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tierMatrix: Record<TierFeature, Tier[]> = {
|
export const tierMatrix: Record<TierFeature, Tier[]> = {
|
||||||
@@ -26,6 +29,7 @@ export const tierMatrix: Record<TierFeature, Tier[]> = {
|
|||||||
[TierFeature.LogExport]: ["tier3", "enterprise"],
|
[TierFeature.LogExport]: ["tier3", "enterprise"],
|
||||||
[TierFeature.AccessLogs]: ["tier2", "tier3", "enterprise"],
|
[TierFeature.AccessLogs]: ["tier2", "tier3", "enterprise"],
|
||||||
[TierFeature.ActionLogs]: ["tier2", "tier3", "enterprise"],
|
[TierFeature.ActionLogs]: ["tier2", "tier3", "enterprise"],
|
||||||
|
[TierFeature.ConnectionLogs]: ["tier2", "tier3", "enterprise"],
|
||||||
[TierFeature.RotateCredentials]: ["tier1", "tier2", "tier3", "enterprise"],
|
[TierFeature.RotateCredentials]: ["tier1", "tier2", "tier3", "enterprise"],
|
||||||
[TierFeature.MaintencePage]: ["tier1", "tier2", "tier3", "enterprise"],
|
[TierFeature.MaintencePage]: ["tier1", "tier2", "tier3", "enterprise"],
|
||||||
[TierFeature.DevicePosture]: ["tier2", "tier3", "enterprise"],
|
[TierFeature.DevicePosture]: ["tier2", "tier3", "enterprise"],
|
||||||
@@ -48,5 +52,7 @@ export const tierMatrix: Record<TierFeature, Tier[]> = {
|
|||||||
"enterprise"
|
"enterprise"
|
||||||
],
|
],
|
||||||
[TierFeature.AutoProvisioning]: ["tier1", "tier3", "enterprise"],
|
[TierFeature.AutoProvisioning]: ["tier1", "tier3", "enterprise"],
|
||||||
[TierFeature.SshPam]: ["tier1", "tier3", "enterprise"]
|
[TierFeature.SshPam]: ["tier1", "tier3", "enterprise"],
|
||||||
|
[TierFeature.FullRbac]: ["tier1", "tier2", "tier3", "enterprise"],
|
||||||
|
[TierFeature.SiteProvisioningKeys]: ["enterprise"]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
roles,
|
roles,
|
||||||
Transaction,
|
Transaction,
|
||||||
userClients,
|
userClients,
|
||||||
|
userOrgRoles,
|
||||||
userOrgs
|
userOrgs
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { getUniqueClientName } from "@server/db/names";
|
import { getUniqueClientName } from "@server/db/names";
|
||||||
@@ -39,20 +40,36 @@ export async function calculateUserClientsForOrgs(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all user orgs
|
// Get all user orgs with all roles (for org list and role-based logic)
|
||||||
const allUserOrgs = await transaction
|
const userOrgRoleRows = await transaction
|
||||||
.select()
|
.select()
|
||||||
.from(userOrgs)
|
.from(userOrgs)
|
||||||
.innerJoin(roles, eq(roles.roleId, userOrgs.roleId))
|
.innerJoin(
|
||||||
|
userOrgRoles,
|
||||||
|
and(
|
||||||
|
eq(userOrgs.userId, userOrgRoles.userId),
|
||||||
|
eq(userOrgs.orgId, userOrgRoles.orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.innerJoin(roles, eq(userOrgRoles.roleId, roles.roleId))
|
||||||
.where(eq(userOrgs.userId, userId));
|
.where(eq(userOrgs.userId, userId));
|
||||||
|
|
||||||
const userOrgIds = allUserOrgs.map(({ userOrgs: uo }) => uo.orgId);
|
const userOrgIds = [...new Set(userOrgRoleRows.map((r) => r.userOrgs.orgId))];
|
||||||
|
const orgIdToRoleRows = new Map<
|
||||||
|
string,
|
||||||
|
(typeof userOrgRoleRows)[0][]
|
||||||
|
>();
|
||||||
|
for (const r of userOrgRoleRows) {
|
||||||
|
const list = orgIdToRoleRows.get(r.userOrgs.orgId) ?? [];
|
||||||
|
list.push(r);
|
||||||
|
orgIdToRoleRows.set(r.userOrgs.orgId, list);
|
||||||
|
}
|
||||||
|
|
||||||
// For each OLM, ensure there's a client in each org the user is in
|
// For each OLM, ensure there's a client in each org the user is in
|
||||||
for (const olm of userOlms) {
|
for (const olm of userOlms) {
|
||||||
for (const userRoleOrg of allUserOrgs) {
|
for (const orgId of orgIdToRoleRows.keys()) {
|
||||||
const { userOrgs: userOrg, roles: role } = userRoleOrg;
|
const roleRowsForOrg = orgIdToRoleRows.get(orgId)!;
|
||||||
const orgId = userOrg.orgId;
|
const userOrg = roleRowsForOrg[0].userOrgs;
|
||||||
|
|
||||||
const [org] = await transaction
|
const [org] = await transaction
|
||||||
.select()
|
.select()
|
||||||
@@ -196,7 +213,7 @@ export async function calculateUserClientsForOrgs(
|
|||||||
const requireApproval =
|
const requireApproval =
|
||||||
build !== "oss" &&
|
build !== "oss" &&
|
||||||
isOrgLicensed &&
|
isOrgLicensed &&
|
||||||
role.requireDeviceApproval;
|
roleRowsForOrg.some((r) => r.roles.requireDeviceApproval);
|
||||||
|
|
||||||
const newClientData: InferInsertModel<typeof clients> = {
|
const newClientData: InferInsertModel<typeof clients> = {
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { db, orgs } from "@server/db";
|
|||||||
import { cleanUpOldLogs as cleanUpOldAccessLogs } from "#dynamic/lib/logAccessAudit";
|
import { cleanUpOldLogs as cleanUpOldAccessLogs } from "#dynamic/lib/logAccessAudit";
|
||||||
import { cleanUpOldLogs as cleanUpOldActionLogs } from "#dynamic/middlewares/logActionAudit";
|
import { cleanUpOldLogs as cleanUpOldActionLogs } from "#dynamic/middlewares/logActionAudit";
|
||||||
import { cleanUpOldLogs as cleanUpOldRequestLogs } from "@server/routers/badger/logRequestAudit";
|
import { cleanUpOldLogs as cleanUpOldRequestLogs } from "@server/routers/badger/logRequestAudit";
|
||||||
|
import { cleanUpOldLogs as cleanUpOldConnectionLogs } from "#dynamic/routers/newt";
|
||||||
import { gt, or } from "drizzle-orm";
|
import { gt, or } from "drizzle-orm";
|
||||||
import { cleanUpOldFingerprintSnapshots } from "@server/routers/olm/fingerprintingUtils";
|
import { cleanUpOldFingerprintSnapshots } from "@server/routers/olm/fingerprintingUtils";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
@@ -20,14 +21,17 @@ export function initLogCleanupInterval() {
|
|||||||
settingsLogRetentionDaysAccess:
|
settingsLogRetentionDaysAccess:
|
||||||
orgs.settingsLogRetentionDaysAccess,
|
orgs.settingsLogRetentionDaysAccess,
|
||||||
settingsLogRetentionDaysRequest:
|
settingsLogRetentionDaysRequest:
|
||||||
orgs.settingsLogRetentionDaysRequest
|
orgs.settingsLogRetentionDaysRequest,
|
||||||
|
settingsLogRetentionDaysConnection:
|
||||||
|
orgs.settingsLogRetentionDaysConnection
|
||||||
})
|
})
|
||||||
.from(orgs)
|
.from(orgs)
|
||||||
.where(
|
.where(
|
||||||
or(
|
or(
|
||||||
gt(orgs.settingsLogRetentionDaysAction, 0),
|
gt(orgs.settingsLogRetentionDaysAction, 0),
|
||||||
gt(orgs.settingsLogRetentionDaysAccess, 0),
|
gt(orgs.settingsLogRetentionDaysAccess, 0),
|
||||||
gt(orgs.settingsLogRetentionDaysRequest, 0)
|
gt(orgs.settingsLogRetentionDaysRequest, 0),
|
||||||
|
gt(orgs.settingsLogRetentionDaysConnection, 0)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -37,7 +41,8 @@ export function initLogCleanupInterval() {
|
|||||||
orgId,
|
orgId,
|
||||||
settingsLogRetentionDaysAction,
|
settingsLogRetentionDaysAction,
|
||||||
settingsLogRetentionDaysAccess,
|
settingsLogRetentionDaysAccess,
|
||||||
settingsLogRetentionDaysRequest
|
settingsLogRetentionDaysRequest,
|
||||||
|
settingsLogRetentionDaysConnection
|
||||||
} = org;
|
} = org;
|
||||||
|
|
||||||
if (settingsLogRetentionDaysAction > 0) {
|
if (settingsLogRetentionDaysAction > 0) {
|
||||||
@@ -60,6 +65,13 @@ export function initLogCleanupInterval() {
|
|||||||
settingsLogRetentionDaysRequest
|
settingsLogRetentionDaysRequest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settingsLogRetentionDaysConnection > 0) {
|
||||||
|
await cleanUpOldConnectionLogs(
|
||||||
|
orgId,
|
||||||
|
settingsLogRetentionDaysConnection
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await cleanUpOldFingerprintSnapshots(365);
|
await cleanUpOldFingerprintSnapshots(365);
|
||||||
|
|||||||
127
server/lib/ip.ts
127
server/lib/ip.ts
@@ -571,6 +571,133 @@ export function generateSubnetProxyTargets(
|
|||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SubnetProxyTargetV2 = {
|
||||||
|
sourcePrefixes: string[]; // must be cidrs
|
||||||
|
destPrefix: string; // must be a cidr
|
||||||
|
disableIcmp?: boolean;
|
||||||
|
rewriteTo?: string; // must be a cidr
|
||||||
|
portRange?: {
|
||||||
|
min: number;
|
||||||
|
max: number;
|
||||||
|
protocol: "tcp" | "udp";
|
||||||
|
}[];
|
||||||
|
resourceId?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function generateSubnetProxyTargetV2(
|
||||||
|
siteResource: SiteResource,
|
||||||
|
clients: {
|
||||||
|
clientId: number;
|
||||||
|
pubKey: string | null;
|
||||||
|
subnet: string | null;
|
||||||
|
}[]
|
||||||
|
): SubnetProxyTargetV2 | undefined {
|
||||||
|
if (clients.length === 0) {
|
||||||
|
logger.debug(
|
||||||
|
`No clients have access to site resource ${siteResource.siteResourceId}, skipping target generation.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let target: SubnetProxyTargetV2 | null = null;
|
||||||
|
|
||||||
|
const portRange = [
|
||||||
|
...parsePortRangeString(siteResource.tcpPortRangeString, "tcp"),
|
||||||
|
...parsePortRangeString(siteResource.udpPortRangeString, "udp")
|
||||||
|
];
|
||||||
|
const disableIcmp = siteResource.disableIcmp ?? false;
|
||||||
|
|
||||||
|
if (siteResource.mode == "host") {
|
||||||
|
let destination = siteResource.destination;
|
||||||
|
// check if this is a valid ip
|
||||||
|
const ipSchema = z.union([z.ipv4(), z.ipv6()]);
|
||||||
|
if (ipSchema.safeParse(destination).success) {
|
||||||
|
destination = `${destination}/32`;
|
||||||
|
|
||||||
|
target = {
|
||||||
|
sourcePrefixes: [],
|
||||||
|
destPrefix: destination,
|
||||||
|
portRange,
|
||||||
|
disableIcmp,
|
||||||
|
resourceId: siteResource.siteResourceId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siteResource.alias && siteResource.aliasAddress) {
|
||||||
|
// also push a match for the alias address
|
||||||
|
target = {
|
||||||
|
sourcePrefixes: [],
|
||||||
|
destPrefix: `${siteResource.aliasAddress}/32`,
|
||||||
|
rewriteTo: destination,
|
||||||
|
portRange,
|
||||||
|
disableIcmp,
|
||||||
|
resourceId: siteResource.siteResourceId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else if (siteResource.mode == "cidr") {
|
||||||
|
target = {
|
||||||
|
sourcePrefixes: [],
|
||||||
|
destPrefix: siteResource.destination,
|
||||||
|
portRange,
|
||||||
|
disableIcmp,
|
||||||
|
resourceId: siteResource.siteResourceId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const clientSite of clients) {
|
||||||
|
if (!clientSite.subnet) {
|
||||||
|
logger.debug(
|
||||||
|
`Client ${clientSite.clientId} has no subnet, skipping for site resource ${siteResource.siteResourceId}.`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientPrefix = `${clientSite.subnet.split("/")[0]}/32`;
|
||||||
|
|
||||||
|
// add client prefix to source prefixes
|
||||||
|
target.sourcePrefixes.push(clientPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
// print a nice representation of the targets
|
||||||
|
// logger.debug(
|
||||||
|
// `Generated subnet proxy targets for: ${JSON.stringify(targets, null, 2)}`
|
||||||
|
// );
|
||||||
|
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a SubnetProxyTargetV2 to an array of SubnetProxyTarget (v1)
|
||||||
|
* by expanding each source prefix into its own target entry.
|
||||||
|
* @param targetV2 - The v2 target to convert
|
||||||
|
* @returns Array of v1 SubnetProxyTarget objects
|
||||||
|
*/
|
||||||
|
export function convertSubnetProxyTargetsV2ToV1(
|
||||||
|
targetsV2: SubnetProxyTargetV2[]
|
||||||
|
): SubnetProxyTarget[] {
|
||||||
|
return targetsV2.flatMap((targetV2) =>
|
||||||
|
targetV2.sourcePrefixes.map((sourcePrefix) => ({
|
||||||
|
sourcePrefix,
|
||||||
|
destPrefix: targetV2.destPrefix,
|
||||||
|
...(targetV2.disableIcmp !== undefined && {
|
||||||
|
disableIcmp: targetV2.disableIcmp
|
||||||
|
}),
|
||||||
|
...(targetV2.rewriteTo !== undefined && {
|
||||||
|
rewriteTo: targetV2.rewriteTo
|
||||||
|
}),
|
||||||
|
...(targetV2.portRange !== undefined && {
|
||||||
|
portRange: targetV2.portRange
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Custom schema for validating port range strings
|
// Custom schema for validating port range strings
|
||||||
// Format: "80,443,8000-9000" or "*" for all ports, or empty string
|
// Format: "80,443,8000-9000" or "*" for all ports, or empty string
|
||||||
export const portRangeStringSchema = z
|
export const portRangeStringSchema = z
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ export const configSchema = z
|
|||||||
.default(3001)
|
.default(3001)
|
||||||
.transform(stoi)
|
.transform(stoi)
|
||||||
.pipe(portSchema),
|
.pipe(portSchema),
|
||||||
|
badger_override: z.string().optional(),
|
||||||
next_port: portSchema
|
next_port: portSchema
|
||||||
.optional()
|
.optional()
|
||||||
.default(3002)
|
.default(3002)
|
||||||
@@ -302,8 +303,8 @@ export const configSchema = z
|
|||||||
.optional()
|
.optional()
|
||||||
.default({
|
.default({
|
||||||
block_size: 24,
|
block_size: 24,
|
||||||
subnet_group: "100.90.128.0/24",
|
subnet_group: "100.90.128.0/20",
|
||||||
utility_subnet_group: "100.96.128.0/24"
|
utility_subnet_group: "100.96.128.0/20"
|
||||||
}),
|
}),
|
||||||
rate_limits: z
|
rate_limits: z
|
||||||
.object({
|
.object({
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
siteResources,
|
siteResources,
|
||||||
sites,
|
sites,
|
||||||
Transaction,
|
Transaction,
|
||||||
|
userOrgRoles,
|
||||||
userOrgs,
|
userOrgs,
|
||||||
userSiteResources
|
userSiteResources
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
@@ -32,7 +33,7 @@ import logger from "@server/logger";
|
|||||||
import {
|
import {
|
||||||
generateAliasConfig,
|
generateAliasConfig,
|
||||||
generateRemoteSubnets,
|
generateRemoteSubnets,
|
||||||
generateSubnetProxyTargets,
|
generateSubnetProxyTargetV2,
|
||||||
parseEndpoint,
|
parseEndpoint,
|
||||||
formatEndpoint
|
formatEndpoint
|
||||||
} from "@server/lib/ip";
|
} from "@server/lib/ip";
|
||||||
@@ -77,10 +78,10 @@ export async function getClientSiteResourceAccess(
|
|||||||
// get all of the users in these roles
|
// get all of the users in these roles
|
||||||
const userIdsFromRoles = await trx
|
const userIdsFromRoles = await trx
|
||||||
.select({
|
.select({
|
||||||
userId: userOrgs.userId
|
userId: userOrgRoles.userId
|
||||||
})
|
})
|
||||||
.from(userOrgs)
|
.from(userOrgRoles)
|
||||||
.where(inArray(userOrgs.roleId, roleIds))
|
.where(inArray(userOrgRoles.roleId, roleIds))
|
||||||
.then((rows) => rows.map((row) => row.userId));
|
.then((rows) => rows.map((row) => row.userId));
|
||||||
|
|
||||||
const newAllUserIds = Array.from(
|
const newAllUserIds = Array.from(
|
||||||
@@ -660,19 +661,16 @@ async function handleSubnetProxyTargetUpdates(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (addedClients.length > 0) {
|
if (addedClients.length > 0) {
|
||||||
const targetsToAdd = generateSubnetProxyTargets(
|
const targetToAdd = generateSubnetProxyTargetV2(
|
||||||
siteResource,
|
siteResource,
|
||||||
addedClients
|
addedClients
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetsToAdd.length > 0) {
|
if (targetToAdd) {
|
||||||
logger.info(
|
|
||||||
`Adding ${targetsToAdd.length} subnet proxy targets for siteResource ${siteResource.siteResourceId}`
|
|
||||||
);
|
|
||||||
proxyJobs.push(
|
proxyJobs.push(
|
||||||
addSubnetProxyTargets(
|
addSubnetProxyTargets(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
targetsToAdd,
|
[targetToAdd],
|
||||||
newt.version
|
newt.version
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -700,19 +698,16 @@ async function handleSubnetProxyTargetUpdates(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (removedClients.length > 0) {
|
if (removedClients.length > 0) {
|
||||||
const targetsToRemove = generateSubnetProxyTargets(
|
const targetToRemove = generateSubnetProxyTargetV2(
|
||||||
siteResource,
|
siteResource,
|
||||||
removedClients
|
removedClients
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetsToRemove.length > 0) {
|
if (targetToRemove) {
|
||||||
logger.info(
|
|
||||||
`Removing ${targetsToRemove.length} subnet proxy targets for siteResource ${siteResource.siteResourceId}`
|
|
||||||
);
|
|
||||||
proxyJobs.push(
|
proxyJobs.push(
|
||||||
removeSubnetProxyTargets(
|
removeSubnetProxyTargets(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
targetsToRemove,
|
[targetToRemove],
|
||||||
newt.version
|
newt.version
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -820,12 +815,12 @@ export async function rebuildClientAssociationsFromClient(
|
|||||||
|
|
||||||
// Role-based access
|
// Role-based access
|
||||||
const roleIds = await trx
|
const roleIds = await trx
|
||||||
.select({ roleId: userOrgs.roleId })
|
.select({ roleId: userOrgRoles.roleId })
|
||||||
.from(userOrgs)
|
.from(userOrgRoles)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(userOrgs.userId, client.userId),
|
eq(userOrgRoles.userId, client.userId),
|
||||||
eq(userOrgs.orgId, client.orgId)
|
eq(userOrgRoles.orgId, client.orgId)
|
||||||
)
|
)
|
||||||
) // this needs to be locked onto this org or else cross-org access could happen
|
) // this needs to be locked onto this org or else cross-org access could happen
|
||||||
.then((rows) => rows.map((row) => row.roleId));
|
.then((rows) => rows.map((row) => row.roleId));
|
||||||
@@ -1169,7 +1164,7 @@ async function handleMessagesForClientResources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
const targets = generateSubnetProxyTargets(resource, [
|
const target = generateSubnetProxyTargetV2(resource, [
|
||||||
{
|
{
|
||||||
clientId: client.clientId,
|
clientId: client.clientId,
|
||||||
pubKey: client.pubKey,
|
pubKey: client.pubKey,
|
||||||
@@ -1177,11 +1172,11 @@ async function handleMessagesForClientResources(
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (targets.length > 0) {
|
if (target) {
|
||||||
proxyJobs.push(
|
proxyJobs.push(
|
||||||
addSubnetProxyTargets(
|
addSubnetProxyTargets(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
targets,
|
[target],
|
||||||
newt.version
|
newt.version
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -1246,7 +1241,7 @@ async function handleMessagesForClientResources(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const resource of resources) {
|
for (const resource of resources) {
|
||||||
const targets = generateSubnetProxyTargets(resource, [
|
const target = generateSubnetProxyTargetV2(resource, [
|
||||||
{
|
{
|
||||||
clientId: client.clientId,
|
clientId: client.clientId,
|
||||||
pubKey: client.pubKey,
|
pubKey: client.pubKey,
|
||||||
@@ -1254,11 +1249,11 @@ async function handleMessagesForClientResources(
|
|||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (targets.length > 0) {
|
if (target) {
|
||||||
proxyJobs.push(
|
proxyJobs.push(
|
||||||
removeSubnetProxyTargets(
|
removeSubnetProxyTargets(
|
||||||
newt.newtId,
|
newt.newtId,
|
||||||
targets,
|
[target],
|
||||||
newt.version
|
newt.version
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
siteResources,
|
siteResources,
|
||||||
sites,
|
sites,
|
||||||
Transaction,
|
Transaction,
|
||||||
UserOrg,
|
userOrgRoles,
|
||||||
userOrgs,
|
userOrgs,
|
||||||
userResources,
|
userResources,
|
||||||
userSiteResources,
|
userSiteResources,
|
||||||
@@ -19,9 +19,22 @@ import { FeatureId } from "@server/lib/billing";
|
|||||||
export async function assignUserToOrg(
|
export async function assignUserToOrg(
|
||||||
org: Org,
|
org: Org,
|
||||||
values: typeof userOrgs.$inferInsert,
|
values: typeof userOrgs.$inferInsert,
|
||||||
|
roleIds: number[],
|
||||||
trx: Transaction | typeof db = db
|
trx: Transaction | typeof db = db
|
||||||
) {
|
) {
|
||||||
|
const uniqueRoleIds = [...new Set(roleIds)];
|
||||||
|
if (uniqueRoleIds.length === 0) {
|
||||||
|
throw new Error("assignUserToOrg requires at least one roleId");
|
||||||
|
}
|
||||||
|
|
||||||
const [userOrg] = await trx.insert(userOrgs).values(values).returning();
|
const [userOrg] = await trx.insert(userOrgs).values(values).returning();
|
||||||
|
await trx.insert(userOrgRoles).values(
|
||||||
|
uniqueRoleIds.map((roleId) => ({
|
||||||
|
userId: userOrg.userId,
|
||||||
|
orgId: userOrg.orgId,
|
||||||
|
roleId
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
// calculate if the user is in any other of the orgs before we count it as an add to the billing org
|
// calculate if the user is in any other of the orgs before we count it as an add to the billing org
|
||||||
if (org.billingOrgId) {
|
if (org.billingOrgId) {
|
||||||
@@ -58,6 +71,14 @@ export async function removeUserFromOrg(
|
|||||||
userId: string,
|
userId: string,
|
||||||
trx: Transaction | typeof db = db
|
trx: Transaction | typeof db = db
|
||||||
) {
|
) {
|
||||||
|
await trx
|
||||||
|
.delete(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, org.orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
await trx
|
await trx
|
||||||
.delete(userOrgs)
|
.delete(userOrgs)
|
||||||
.where(and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, org.orgId)));
|
.where(and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, org.orgId)));
|
||||||
|
|||||||
36
server/lib/userOrgRoles.ts
Normal file
36
server/lib/userOrgRoles.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { db, roles, userOrgRoles } from "@server/db";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all role IDs a user has in an organization.
|
||||||
|
* Returns empty array if the user has no roles in the org (callers must treat as no access).
|
||||||
|
*/
|
||||||
|
export async function getUserOrgRoleIds(
|
||||||
|
userId: string,
|
||||||
|
orgId: string
|
||||||
|
): Promise<number[]> {
|
||||||
|
const rows = await db
|
||||||
|
.select({ roleId: userOrgRoles.roleId })
|
||||||
|
.from(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return rows.map((r) => r.roleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getUserOrgRoles(
|
||||||
|
userId: string,
|
||||||
|
orgId: string
|
||||||
|
): Promise<{ roleId: number; roleName: string }[]> {
|
||||||
|
const rows = await db
|
||||||
|
.select({ roleId: userOrgRoles.roleId, roleName: roles.name })
|
||||||
|
.from(userOrgRoles)
|
||||||
|
.innerJoin(roles, eq(userOrgRoles.roleId, roles.roleId))
|
||||||
|
.where(
|
||||||
|
and(eq(userOrgRoles.userId, userId), eq(userOrgRoles.orgId, orgId))
|
||||||
|
);
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
@@ -21,8 +21,7 @@ export async function getUserOrgs(
|
|||||||
try {
|
try {
|
||||||
const userOrganizations = await db
|
const userOrganizations = await db
|
||||||
.select({
|
.select({
|
||||||
orgId: userOrgs.orgId,
|
orgId: userOrgs.orgId
|
||||||
roleId: userOrgs.roleId
|
|
||||||
})
|
})
|
||||||
.from(userOrgs)
|
.from(userOrgs)
|
||||||
.where(eq(userOrgs.userId, userId));
|
.where(eq(userOrgs.userId, userId));
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export * from "./verifyAccessTokenAccess";
|
|||||||
export * from "./requestTimeout";
|
export * from "./requestTimeout";
|
||||||
export * from "./verifyClientAccess";
|
export * from "./verifyClientAccess";
|
||||||
export * from "./verifyUserHasAction";
|
export * from "./verifyUserHasAction";
|
||||||
|
export * from "./verifyUserCanSetUserOrgRoles";
|
||||||
export * from "./verifyUserIsServerAdmin";
|
export * from "./verifyUserIsServerAdmin";
|
||||||
export * from "./verifyIsLoggedInUser";
|
export * from "./verifyIsLoggedInUser";
|
||||||
export * from "./verifyIsLoggedInUser";
|
export * from "./verifyIsLoggedInUser";
|
||||||
@@ -24,6 +25,7 @@ export * from "./verifyClientAccess";
|
|||||||
export * from "./integration";
|
export * from "./integration";
|
||||||
export * from "./verifyUserHasAction";
|
export * from "./verifyUserHasAction";
|
||||||
export * from "./verifyApiKeyAccess";
|
export * from "./verifyApiKeyAccess";
|
||||||
|
export * from "./verifySiteProvisioningKeyAccess";
|
||||||
export * from "./verifyDomainAccess";
|
export * from "./verifyDomainAccess";
|
||||||
export * from "./verifyUserIsOrgOwner";
|
export * from "./verifyUserIsOrgOwner";
|
||||||
export * from "./verifySiteResourceAccess";
|
export * from "./verifySiteResourceAccess";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export * from "./verifyApiKey";
|
export * from "./verifyApiKey";
|
||||||
export * from "./verifyApiKeyOrgAccess";
|
export * from "./verifyApiKeyOrgAccess";
|
||||||
export * from "./verifyApiKeyHasAction";
|
export * from "./verifyApiKeyHasAction";
|
||||||
|
export * from "./verifyApiKeyCanSetUserOrgRoles";
|
||||||
export * from "./verifyApiKeySiteAccess";
|
export * from "./verifyApiKeySiteAccess";
|
||||||
export * from "./verifyApiKeyResourceAccess";
|
export * from "./verifyApiKeyResourceAccess";
|
||||||
export * from "./verifyApiKeyTargetAccess";
|
export * from "./verifyApiKeyTargetAccess";
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { ActionsEnum } from "@server/auth/actions";
|
||||||
|
import { db } from "@server/db";
|
||||||
|
import { apiKeyActions } from "@server/db";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
|
||||||
|
async function apiKeyHasAction(apiKeyId: string, actionId: ActionsEnum) {
|
||||||
|
const [row] = await db
|
||||||
|
.select()
|
||||||
|
.from(apiKeyActions)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(apiKeyActions.apiKeyId, apiKeyId),
|
||||||
|
eq(apiKeyActions.actionId, actionId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return !!row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows setUserOrgRoles on the key, or both addUserRole and removeUserRole.
|
||||||
|
*/
|
||||||
|
export function verifyApiKeyCanSetUserOrgRoles() {
|
||||||
|
return async function (
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
if (!req.apiKey) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.UNAUTHORIZED,
|
||||||
|
"API Key not authenticated"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyId = req.apiKey.apiKeyId;
|
||||||
|
|
||||||
|
if (await apiKeyHasAction(keyId, ActionsEnum.setUserOrgRoles)) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasAdd = await apiKeyHasAction(keyId, ActionsEnum.addUserRole);
|
||||||
|
const hasRemove = await apiKeyHasAction(
|
||||||
|
keyId,
|
||||||
|
ActionsEnum.removeUserRole
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasAdd && hasRemove) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"Key does not have permission perform this action"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error verifying API key set user org roles:", error);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Error verifying key action access"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import createHttpError from "http-errors";
|
|||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { canUserAccessResource } from "@server/auth/canUserAccessResource";
|
import { canUserAccessResource } from "@server/auth/canUserAccessResource";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyAccessTokenAccess(
|
export async function verifyAccessTokenAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -93,7 +94,10 @@ export async function verifyAccessTokenAccess(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
req.userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
|
req.userOrg.userId,
|
||||||
|
resource[0].orgId!
|
||||||
|
);
|
||||||
req.userOrgId = resource[0].orgId!;
|
req.userOrgId = resource[0].orgId!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +122,7 @@ export async function verifyAccessTokenAccess(
|
|||||||
const resourceAllowed = await canUserAccessResource({
|
const resourceAllowed = await canUserAccessResource({
|
||||||
userId,
|
userId,
|
||||||
resourceId,
|
resourceId,
|
||||||
roleId: req.userOrgRoleId!
|
roleIds: req.userOrgRoleIds ?? []
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resourceAllowed) {
|
if (!resourceAllowed) {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { roles, userOrgs } from "@server/db";
|
import { roles, userOrgs } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyAdmin(
|
export async function verifyAdmin(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -62,13 +63,29 @@ export async function verifyAdmin(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userRole = await db
|
req.userOrgRoleIds = await getUserOrgRoleIds(req.userOrg.userId, orgId!);
|
||||||
|
|
||||||
|
if (req.userOrgRoleIds.length === 0) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"User does not have Admin access"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const userAdminRoles = await db
|
||||||
.select()
|
.select()
|
||||||
.from(roles)
|
.from(roles)
|
||||||
.where(eq(roles.roleId, req.userOrg.roleId))
|
.where(
|
||||||
|
and(
|
||||||
|
inArray(roles.roleId, req.userOrgRoleIds),
|
||||||
|
eq(roles.isAdmin, true)
|
||||||
|
)
|
||||||
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (userRole.length === 0 || !userRole[0].isAdmin) {
|
if (userAdminRoles.length === 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { userOrgs, apiKeys, apiKeyOrg } from "@server/db";
|
import { userOrgs, apiKeys, apiKeyOrg } from "@server/db";
|
||||||
import { and, eq, or } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyApiKeyAccess(
|
export async function verifyApiKeyAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -103,8 +104,10 @@ export async function verifyApiKeyAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
orgId
|
||||||
|
);
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { Client, db } from "@server/db";
|
import { Client, db } from "@server/db";
|
||||||
import { userOrgs, clients, roleClients, userClients } from "@server/db";
|
import { userOrgs, clients, roleClients, userClients } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyClientAccess(
|
export async function verifyClientAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -113,21 +114,30 @@ export async function verifyClientAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
client.orgId
|
||||||
|
);
|
||||||
req.userOrgId = client.orgId;
|
req.userOrgId = client.orgId;
|
||||||
|
|
||||||
// Check role-based site access first
|
// Check role-based client access (any of user's roles)
|
||||||
const [roleClientAccess] = await db
|
const roleClientAccessList =
|
||||||
.select()
|
(req.userOrgRoleIds?.length ?? 0) > 0
|
||||||
.from(roleClients)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleClients)
|
||||||
eq(roleClients.clientId, client.clientId),
|
.where(
|
||||||
eq(roleClients.roleId, userOrgRoleId)
|
and(
|
||||||
)
|
eq(roleClients.clientId, client.clientId),
|
||||||
)
|
inArray(
|
||||||
.limit(1);
|
roleClients.roleId,
|
||||||
|
req.userOrgRoleIds!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
const [roleClientAccess] = roleClientAccessList;
|
||||||
|
|
||||||
if (roleClientAccess) {
|
if (roleClientAccess) {
|
||||||
// User has access to the site through their role
|
// User has access to the site through their role
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db, domains, orgDomains } from "@server/db";
|
import { db, domains, orgDomains } from "@server/db";
|
||||||
import { userOrgs, apiKeyOrg } from "@server/db";
|
import { userOrgs } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyDomainAccess(
|
export async function verifyDomainAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -63,7 +64,7 @@ export async function verifyDomainAccess(
|
|||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(userOrgs.userId, userId),
|
eq(userOrgs.userId, userId),
|
||||||
eq(userOrgs.orgId, apiKeyOrg.orgId)
|
eq(userOrgs.orgId, orgId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.limit(1);
|
.limit(1);
|
||||||
@@ -97,8 +98,7 @@ export async function verifyDomainAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(req.userOrg.userId, orgId);
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db, orgs } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { userOrgs } from "@server/db";
|
import { userOrgs } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyOrgAccess(
|
export async function verifyOrgAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -64,8 +65,8 @@ export async function verifyOrgAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// User has access, attach the user's role to the request for potential future use
|
// User has access, attach the user's role(s) to the request for potential future use
|
||||||
req.userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(req.userOrg.userId, orgId);
|
||||||
req.userOrgId = orgId;
|
req.userOrgId = orgId;
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db, Resource } from "@server/db";
|
import { db, Resource } from "@server/db";
|
||||||
import { resources, userOrgs, userResources, roleResources } from "@server/db";
|
import { resources, userOrgs, userResources, roleResources } from "@server/db";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyResourceAccess(
|
export async function verifyResourceAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -107,20 +108,28 @@ export async function verifyResourceAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
resource.orgId
|
||||||
|
);
|
||||||
req.userOrgId = resource.orgId;
|
req.userOrgId = resource.orgId;
|
||||||
|
|
||||||
const roleResourceAccess = await db
|
const roleResourceAccess =
|
||||||
.select()
|
(req.userOrgRoleIds?.length ?? 0) > 0
|
||||||
.from(roleResources)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleResources)
|
||||||
eq(roleResources.resourceId, resource.resourceId),
|
.where(
|
||||||
eq(roleResources.roleId, userOrgRoleId)
|
and(
|
||||||
)
|
eq(roleResources.resourceId, resource.resourceId),
|
||||||
)
|
inArray(
|
||||||
.limit(1);
|
roleResources.roleId,
|
||||||
|
req.userOrgRoleIds!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (roleResourceAccess.length > 0) {
|
if (roleResourceAccess.length > 0) {
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import createHttpError from "http-errors";
|
|||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyRoleAccess(
|
export async function verifyRoleAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -99,7 +100,6 @@ export async function verifyRoleAccess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!req.userOrg) {
|
if (!req.userOrg) {
|
||||||
// get the userORg
|
|
||||||
const userOrg = await db
|
const userOrg = await db
|
||||||
.select()
|
.select()
|
||||||
.from(userOrgs)
|
.from(userOrgs)
|
||||||
@@ -109,7 +109,7 @@ export async function verifyRoleAccess(
|
|||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
req.userOrg = userOrg[0];
|
req.userOrg = userOrg[0];
|
||||||
req.userOrgRoleId = userOrg[0].roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(userId, orgId!);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.userOrg) {
|
if (!req.userOrg) {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { sites, Site, userOrgs, userSites, roleSites, roles } from "@server/db";
|
import { sites, Site, userOrgs, userSites, roleSites, roles } from "@server/db";
|
||||||
import { and, eq, or } from "drizzle-orm";
|
import { and, eq, inArray, or } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifySiteAccess(
|
export async function verifySiteAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -112,21 +113,29 @@ export async function verifySiteAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
site.orgId
|
||||||
|
);
|
||||||
req.userOrgId = site.orgId;
|
req.userOrgId = site.orgId;
|
||||||
|
|
||||||
// Check role-based site access first
|
// Check role-based site access first (any of user's roles)
|
||||||
const roleSiteAccess = await db
|
const roleSiteAccess =
|
||||||
.select()
|
(req.userOrgRoleIds?.length ?? 0) > 0
|
||||||
.from(roleSites)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleSites)
|
||||||
eq(roleSites.siteId, site.siteId),
|
.where(
|
||||||
eq(roleSites.roleId, userOrgRoleId)
|
and(
|
||||||
)
|
eq(roleSites.siteId, site.siteId),
|
||||||
)
|
inArray(
|
||||||
.limit(1);
|
roleSites.roleId,
|
||||||
|
req.userOrgRoleIds!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (roleSiteAccess.length > 0) {
|
if (roleSiteAccess.length > 0) {
|
||||||
// User's role has access to the site
|
// User's role has access to the site
|
||||||
|
|||||||
131
server/middlewares/verifySiteProvisioningKeyAccess.ts
Normal file
131
server/middlewares/verifySiteProvisioningKeyAccess.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { db, userOrgs, siteProvisioningKeys, siteProvisioningKeyOrg } from "@server/db";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
|
||||||
|
export async function verifySiteProvisioningKeyAccess(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const userId = req.user!.userId;
|
||||||
|
const siteProvisioningKeyId = req.params.siteProvisioningKeyId;
|
||||||
|
const orgId = req.params.orgId;
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.UNAUTHORIZED, "User not authenticated")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!orgId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.BAD_REQUEST, "Invalid organization ID")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!siteProvisioningKeyId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.BAD_REQUEST, "Invalid key ID")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [row] = await db
|
||||||
|
.select()
|
||||||
|
.from(siteProvisioningKeys)
|
||||||
|
.innerJoin(
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
and(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId
|
||||||
|
),
|
||||||
|
eq(siteProvisioningKeyOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!row?.siteProvisioningKeys) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
`Site provisioning key with ID ${siteProvisioningKeyId} not found`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!row.siteProvisioningKeyOrg.orgId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
`Site provisioning key with ID ${siteProvisioningKeyId} does not have an organization ID`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!req.userOrg) {
|
||||||
|
const userOrgRole = await db
|
||||||
|
.select()
|
||||||
|
.from(userOrgs)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgs.userId, userId),
|
||||||
|
eq(
|
||||||
|
userOrgs.orgId,
|
||||||
|
row.siteProvisioningKeyOrg.orgId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
req.userOrg = userOrgRole[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!req.userOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"User does not have access to this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.orgPolicyAllowed === undefined && req.userOrg.orgId) {
|
||||||
|
const policyCheck = await checkOrgAccessPolicy({
|
||||||
|
orgId: req.userOrg.orgId,
|
||||||
|
userId,
|
||||||
|
session: req.session
|
||||||
|
});
|
||||||
|
req.orgPolicyAllowed = policyCheck.allowed;
|
||||||
|
if (!policyCheck.allowed || policyCheck.error) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"Failed organization access policy check: " +
|
||||||
|
(policyCheck.error || "Unknown error")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const userOrgRoleId = req.userOrg.roleId;
|
||||||
|
req.userOrgRoleId = userOrgRoleId;
|
||||||
|
|
||||||
|
return next();
|
||||||
|
} catch (error) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Error verifying site provisioning key access"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db, roleSiteResources, userOrgs, userSiteResources } from "@server/db";
|
import { db, roleSiteResources, userOrgs, userSiteResources } from "@server/db";
|
||||||
import { siteResources } from "@server/db";
|
import { siteResources } from "@server/db";
|
||||||
import { eq, and } from "drizzle-orm";
|
import { eq, and, inArray } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifySiteResourceAccess(
|
export async function verifySiteResourceAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -109,23 +110,34 @@ export async function verifySiteResourceAccess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
siteResource.orgId
|
||||||
|
);
|
||||||
req.userOrgId = siteResource.orgId;
|
req.userOrgId = siteResource.orgId;
|
||||||
|
|
||||||
// Attach the siteResource to the request for use in the next middleware/route
|
// Attach the siteResource to the request for use in the next middleware/route
|
||||||
req.siteResource = siteResource;
|
req.siteResource = siteResource;
|
||||||
|
|
||||||
const roleResourceAccess = await db
|
const roleResourceAccess =
|
||||||
.select()
|
(req.userOrgRoleIds?.length ?? 0) > 0
|
||||||
.from(roleSiteResources)
|
? await db
|
||||||
.where(
|
.select()
|
||||||
and(
|
.from(roleSiteResources)
|
||||||
eq(roleSiteResources.siteResourceId, siteResourceIdNum),
|
.where(
|
||||||
eq(roleSiteResources.roleId, userOrgRoleId)
|
and(
|
||||||
)
|
eq(
|
||||||
)
|
roleSiteResources.siteResourceId,
|
||||||
.limit(1);
|
siteResourceIdNum
|
||||||
|
),
|
||||||
|
inArray(
|
||||||
|
roleSiteResources.roleId,
|
||||||
|
req.userOrgRoleIds!
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1)
|
||||||
|
: [];
|
||||||
|
|
||||||
if (roleResourceAccess.length > 0) {
|
if (roleResourceAccess.length > 0) {
|
||||||
return next();
|
return next();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import createHttpError from "http-errors";
|
|||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import { canUserAccessResource } from "../auth/canUserAccessResource";
|
import { canUserAccessResource } from "../auth/canUserAccessResource";
|
||||||
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
import { checkOrgAccessPolicy } from "#dynamic/lib/checkOrgAccessPolicy";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyTargetAccess(
|
export async function verifyTargetAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -99,7 +100,10 @@ export async function verifyTargetAccess(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
req.userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
|
req.userOrg.userId,
|
||||||
|
resource[0].orgId!
|
||||||
|
);
|
||||||
req.userOrgId = resource[0].orgId!;
|
req.userOrgId = resource[0].orgId!;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +130,7 @@ export async function verifyTargetAccess(
|
|||||||
const resourceAllowed = await canUserAccessResource({
|
const resourceAllowed = await canUserAccessResource({
|
||||||
userId,
|
userId,
|
||||||
resourceId,
|
resourceId,
|
||||||
roleId: req.userOrgRoleId!
|
roleIds: req.userOrgRoleIds ?? []
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!resourceAllowed) {
|
if (!resourceAllowed) {
|
||||||
|
|||||||
54
server/middlewares/verifyUserCanSetUserOrgRoles.ts
Normal file
54
server/middlewares/verifyUserCanSetUserOrgRoles.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { ActionsEnum, checkUserActionPermission } from "@server/auth/actions";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows the new setUserOrgRoles action, or legacy permission pair addUserRole + removeUserRole.
|
||||||
|
*/
|
||||||
|
export function verifyUserCanSetUserOrgRoles() {
|
||||||
|
return async function (
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const canSet = await checkUserActionPermission(
|
||||||
|
ActionsEnum.setUserOrgRoles,
|
||||||
|
req
|
||||||
|
);
|
||||||
|
if (canSet) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
const canAdd = await checkUserActionPermission(
|
||||||
|
ActionsEnum.addUserRole,
|
||||||
|
req
|
||||||
|
);
|
||||||
|
const canRemove = await checkUserActionPermission(
|
||||||
|
ActionsEnum.removeUserRole,
|
||||||
|
req
|
||||||
|
);
|
||||||
|
|
||||||
|
if (canAdd && canRemove) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"User does not have permission perform this action"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error verifying set user org roles access:", error);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Error verifying role access"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ export async function verifyUserInRole(
|
|||||||
const roleId = parseInt(
|
const roleId = parseInt(
|
||||||
req.params.roleId || req.body.roleId || req.query.roleId
|
req.params.roleId || req.body.roleId || req.query.roleId
|
||||||
);
|
);
|
||||||
const userRoleId = req.userOrgRoleId;
|
const userOrgRoleIds = req.userOrgRoleIds ?? [];
|
||||||
|
|
||||||
if (isNaN(roleId)) {
|
if (isNaN(roleId)) {
|
||||||
return next(
|
return next(
|
||||||
@@ -20,7 +20,7 @@ export async function verifyUserInRole(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userRoleId) {
|
if (userOrgRoleIds.length === 0) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
@@ -29,7 +29,7 @@ export async function verifyUserInRole(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userRoleId !== roleId) {
|
if (!userOrgRoleIds.includes(roleId)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
HttpCode.FORBIDDEN,
|
HttpCode.FORBIDDEN,
|
||||||
|
|||||||
@@ -14,12 +14,14 @@
|
|||||||
import { rateLimitService } from "#private/lib/rateLimit";
|
import { rateLimitService } from "#private/lib/rateLimit";
|
||||||
import { cleanup as wsCleanup } from "#private/routers/ws";
|
import { cleanup as wsCleanup } from "#private/routers/ws";
|
||||||
import { flushBandwidthToDb } from "@server/routers/newt/handleReceiveBandwidthMessage";
|
import { flushBandwidthToDb } from "@server/routers/newt/handleReceiveBandwidthMessage";
|
||||||
|
import { flushConnectionLogToDb } from "#dynamic/routers/newt";
|
||||||
import { flushSiteBandwidthToDb } from "@server/routers/gerbil/receiveBandwidth";
|
import { flushSiteBandwidthToDb } from "@server/routers/gerbil/receiveBandwidth";
|
||||||
import { stopPingAccumulator } from "@server/routers/newt/pingAccumulator";
|
import { stopPingAccumulator } from "@server/routers/newt/pingAccumulator";
|
||||||
|
|
||||||
async function cleanup() {
|
async function cleanup() {
|
||||||
await stopPingAccumulator();
|
await stopPingAccumulator();
|
||||||
await flushBandwidthToDb();
|
await flushBandwidthToDb();
|
||||||
|
await flushConnectionLogToDb();
|
||||||
await flushSiteBandwidthToDb();
|
await flushSiteBandwidthToDb();
|
||||||
await rateLimitService.cleanup();
|
await rateLimitService.cleanup();
|
||||||
await wsCleanup();
|
await wsCleanup();
|
||||||
@@ -31,4 +33,4 @@ export async function initCleanup() {
|
|||||||
// Handle process termination
|
// Handle process termination
|
||||||
process.on("SIGTERM", () => cleanup());
|
process.on("SIGTERM", () => cleanup());
|
||||||
process.on("SIGINT", () => cleanup());
|
process.on("SIGINT", () => cleanup());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ export const privateConfigSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
host: z.string(),
|
host: z.string(),
|
||||||
port: portSchema,
|
port: portSchema,
|
||||||
password: z.string().optional(),
|
password: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform(getEnvOrYaml("REDIS_PASSWORD")),
|
||||||
db: z.int().nonnegative().optional().default(0),
|
db: z.int().nonnegative().optional().default(0),
|
||||||
replicas: z
|
replicas: z
|
||||||
.array(
|
.array(
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { userOrgs, db, idp, idpOrg } from "@server/db";
|
import { userOrgs, db, idp, idpOrg } from "@server/db";
|
||||||
import { and, eq, or } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyIdpAccess(
|
export async function verifyIdpAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -84,8 +85,10 @@ export async function verifyIdpAccess(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
idpRes.idpOrg.orgId
|
||||||
|
);
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { db, exitNodeOrgs, exitNodes, remoteExitNodes } from "@server/db";
|
import { db, exitNodeOrgs, remoteExitNodes } from "@server/db";
|
||||||
import { sites, userOrgs, userSites, roleSites, roles } from "@server/db";
|
import { userOrgs } from "@server/db";
|
||||||
import { and, eq, or } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { getUserOrgRoleIds } from "@server/lib/userOrgRoles";
|
||||||
|
|
||||||
export async function verifyRemoteExitNodeAccess(
|
export async function verifyRemoteExitNodeAccess(
|
||||||
req: Request,
|
req: Request,
|
||||||
@@ -103,8 +104,10 @@ export async function verifyRemoteExitNodeAccess(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRoleId = req.userOrg.roleId;
|
req.userOrgRoleIds = await getUserOrgRoleIds(
|
||||||
req.userOrgRoleId = userOrgRoleId;
|
req.userOrg.userId,
|
||||||
|
exitNodeOrg.orgId
|
||||||
|
);
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
99
server/private/routers/auditLogs/exportConnectionAuditLog.ts
Normal file
99
server/private/routers/auditLogs/exportConnectionAuditLog.ts
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { registry } from "@server/openApi";
|
||||||
|
import { NextFunction } from "express";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
import { OpenAPITags } from "@server/openApi";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import {
|
||||||
|
queryConnectionAuditLogsParams,
|
||||||
|
queryConnectionAuditLogsQuery,
|
||||||
|
queryConnection,
|
||||||
|
countConnectionQuery
|
||||||
|
} from "./queryConnectionAuditLog";
|
||||||
|
import { generateCSV } from "@server/routers/auditLogs/generateCSV";
|
||||||
|
import { MAX_EXPORT_LIMIT } from "@server/routers/auditLogs";
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: "get",
|
||||||
|
path: "/org/{orgId}/logs/connection/export",
|
||||||
|
description: "Export the connection audit log for an organization as CSV",
|
||||||
|
tags: [OpenAPITags.Logs],
|
||||||
|
request: {
|
||||||
|
query: queryConnectionAuditLogsQuery,
|
||||||
|
params: queryConnectionAuditLogsParams
|
||||||
|
},
|
||||||
|
responses: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function exportConnectionAuditLogs(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedQuery = queryConnectionAuditLogsQuery.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedParams = queryConnectionAuditLogsParams.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = { ...parsedQuery.data, ...parsedParams.data };
|
||||||
|
const [{ count }] = await countConnectionQuery(data);
|
||||||
|
if (count > MAX_EXPORT_LIMIT) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
`Export limit exceeded. Your selection contains ${count} rows, but the maximum is ${MAX_EXPORT_LIMIT} rows. Please select a shorter time range to reduce the data.`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseQuery = queryConnection(data);
|
||||||
|
|
||||||
|
const log = await baseQuery.limit(data.limit).offset(data.offset);
|
||||||
|
|
||||||
|
const csvData = generateCSV(log);
|
||||||
|
|
||||||
|
res.setHeader("Content-Type", "text/csv");
|
||||||
|
res.setHeader(
|
||||||
|
"Content-Disposition",
|
||||||
|
`attachment; filename="connection-audit-logs-${data.orgId}-${Date.now()}.csv"`
|
||||||
|
);
|
||||||
|
|
||||||
|
return res.send(csvData);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,3 +15,5 @@ export * from "./queryActionAuditLog";
|
|||||||
export * from "./exportActionAuditLog";
|
export * from "./exportActionAuditLog";
|
||||||
export * from "./queryAccessAuditLog";
|
export * from "./queryAccessAuditLog";
|
||||||
export * from "./exportAccessAuditLog";
|
export * from "./exportAccessAuditLog";
|
||||||
|
export * from "./queryConnectionAuditLog";
|
||||||
|
export * from "./exportConnectionAuditLog";
|
||||||
|
|||||||
524
server/private/routers/auditLogs/queryConnectionAuditLog.ts
Normal file
524
server/private/routers/auditLogs/queryConnectionAuditLog.ts
Normal file
@@ -0,0 +1,524 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
connectionAuditLog,
|
||||||
|
logsDb,
|
||||||
|
siteResources,
|
||||||
|
sites,
|
||||||
|
clients,
|
||||||
|
users,
|
||||||
|
primaryDb
|
||||||
|
} from "@server/db";
|
||||||
|
import { registry } from "@server/openApi";
|
||||||
|
import { NextFunction } from "express";
|
||||||
|
import { Request, Response } from "express";
|
||||||
|
import { eq, gt, lt, and, count, desc, inArray } from "drizzle-orm";
|
||||||
|
import { OpenAPITags } from "@server/openApi";
|
||||||
|
import { z } from "zod";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { QueryConnectionAuditLogResponse } from "@server/routers/auditLogs/types";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { getSevenDaysAgo } from "@app/lib/getSevenDaysAgo";
|
||||||
|
|
||||||
|
export const queryConnectionAuditLogsQuery = z.object({
|
||||||
|
// iso string just validate its a parseable date
|
||||||
|
timeStart: z
|
||||||
|
.string()
|
||||||
|
.refine((val) => !isNaN(Date.parse(val)), {
|
||||||
|
error: "timeStart must be a valid ISO date string"
|
||||||
|
})
|
||||||
|
.transform((val) => Math.floor(new Date(val).getTime() / 1000))
|
||||||
|
.prefault(() => getSevenDaysAgo().toISOString())
|
||||||
|
.openapi({
|
||||||
|
type: "string",
|
||||||
|
format: "date-time",
|
||||||
|
description:
|
||||||
|
"Start time as ISO date string (defaults to 7 days ago)"
|
||||||
|
}),
|
||||||
|
timeEnd: z
|
||||||
|
.string()
|
||||||
|
.refine((val) => !isNaN(Date.parse(val)), {
|
||||||
|
error: "timeEnd must be a valid ISO date string"
|
||||||
|
})
|
||||||
|
.transform((val) => Math.floor(new Date(val).getTime() / 1000))
|
||||||
|
.optional()
|
||||||
|
.prefault(() => new Date().toISOString())
|
||||||
|
.openapi({
|
||||||
|
type: "string",
|
||||||
|
format: "date-time",
|
||||||
|
description:
|
||||||
|
"End time as ISO date string (defaults to current time)"
|
||||||
|
}),
|
||||||
|
protocol: z.string().optional(),
|
||||||
|
sourceAddr: z.string().optional(),
|
||||||
|
destAddr: z.string().optional(),
|
||||||
|
clientId: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive())
|
||||||
|
.optional(),
|
||||||
|
siteId: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive())
|
||||||
|
.optional(),
|
||||||
|
siteResourceId: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive())
|
||||||
|
.optional(),
|
||||||
|
userId: z.string().optional(),
|
||||||
|
limit: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("1000")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive()),
|
||||||
|
offset: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("0")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().nonnegative())
|
||||||
|
});
|
||||||
|
|
||||||
|
export const queryConnectionAuditLogsParams = z.object({
|
||||||
|
orgId: z.string()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const queryConnectionAuditLogsCombined =
|
||||||
|
queryConnectionAuditLogsQuery.merge(queryConnectionAuditLogsParams);
|
||||||
|
type Q = z.infer<typeof queryConnectionAuditLogsCombined>;
|
||||||
|
|
||||||
|
function getWhere(data: Q) {
|
||||||
|
return and(
|
||||||
|
gt(connectionAuditLog.startedAt, data.timeStart),
|
||||||
|
lt(connectionAuditLog.startedAt, data.timeEnd),
|
||||||
|
eq(connectionAuditLog.orgId, data.orgId),
|
||||||
|
data.protocol
|
||||||
|
? eq(connectionAuditLog.protocol, data.protocol)
|
||||||
|
: undefined,
|
||||||
|
data.sourceAddr
|
||||||
|
? eq(connectionAuditLog.sourceAddr, data.sourceAddr)
|
||||||
|
: undefined,
|
||||||
|
data.destAddr
|
||||||
|
? eq(connectionAuditLog.destAddr, data.destAddr)
|
||||||
|
: undefined,
|
||||||
|
data.clientId
|
||||||
|
? eq(connectionAuditLog.clientId, data.clientId)
|
||||||
|
: undefined,
|
||||||
|
data.siteId
|
||||||
|
? eq(connectionAuditLog.siteId, data.siteId)
|
||||||
|
: undefined,
|
||||||
|
data.siteResourceId
|
||||||
|
? eq(connectionAuditLog.siteResourceId, data.siteResourceId)
|
||||||
|
: undefined,
|
||||||
|
data.userId
|
||||||
|
? eq(connectionAuditLog.userId, data.userId)
|
||||||
|
: undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function queryConnection(data: Q) {
|
||||||
|
return logsDb
|
||||||
|
.select({
|
||||||
|
sessionId: connectionAuditLog.sessionId,
|
||||||
|
siteResourceId: connectionAuditLog.siteResourceId,
|
||||||
|
orgId: connectionAuditLog.orgId,
|
||||||
|
siteId: connectionAuditLog.siteId,
|
||||||
|
clientId: connectionAuditLog.clientId,
|
||||||
|
userId: connectionAuditLog.userId,
|
||||||
|
sourceAddr: connectionAuditLog.sourceAddr,
|
||||||
|
destAddr: connectionAuditLog.destAddr,
|
||||||
|
protocol: connectionAuditLog.protocol,
|
||||||
|
startedAt: connectionAuditLog.startedAt,
|
||||||
|
endedAt: connectionAuditLog.endedAt,
|
||||||
|
bytesTx: connectionAuditLog.bytesTx,
|
||||||
|
bytesRx: connectionAuditLog.bytesRx
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(getWhere(data))
|
||||||
|
.orderBy(
|
||||||
|
desc(connectionAuditLog.startedAt),
|
||||||
|
desc(connectionAuditLog.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function countConnectionQuery(data: Q) {
|
||||||
|
const countQuery = logsDb
|
||||||
|
.select({ count: count() })
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(getWhere(data));
|
||||||
|
return countQuery;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function enrichWithDetails(
|
||||||
|
logs: Awaited<ReturnType<typeof queryConnection>>
|
||||||
|
) {
|
||||||
|
// Collect unique IDs from logs
|
||||||
|
const siteResourceIds = [
|
||||||
|
...new Set(
|
||||||
|
logs
|
||||||
|
.map((log) => log.siteResourceId)
|
||||||
|
.filter((id): id is number => id !== null && id !== undefined)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const siteIds = [
|
||||||
|
...new Set(
|
||||||
|
logs
|
||||||
|
.map((log) => log.siteId)
|
||||||
|
.filter((id): id is number => id !== null && id !== undefined)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const clientIds = [
|
||||||
|
...new Set(
|
||||||
|
logs
|
||||||
|
.map((log) => log.clientId)
|
||||||
|
.filter((id): id is number => id !== null && id !== undefined)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
const userIds = [
|
||||||
|
...new Set(
|
||||||
|
logs
|
||||||
|
.map((log) => log.userId)
|
||||||
|
.filter((id): id is string => id !== null && id !== undefined)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fetch resource details from main database
|
||||||
|
const resourceMap = new Map<
|
||||||
|
number,
|
||||||
|
{ name: string; niceId: string }
|
||||||
|
>();
|
||||||
|
if (siteResourceIds.length > 0) {
|
||||||
|
const resourceDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
siteResourceId: siteResources.siteResourceId,
|
||||||
|
name: siteResources.name,
|
||||||
|
niceId: siteResources.niceId
|
||||||
|
})
|
||||||
|
.from(siteResources)
|
||||||
|
.where(inArray(siteResources.siteResourceId, siteResourceIds));
|
||||||
|
|
||||||
|
for (const r of resourceDetails) {
|
||||||
|
resourceMap.set(r.siteResourceId, {
|
||||||
|
name: r.name,
|
||||||
|
niceId: r.niceId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch site details from main database
|
||||||
|
const siteMap = new Map<number, { name: string; niceId: string }>();
|
||||||
|
if (siteIds.length > 0) {
|
||||||
|
const siteDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
siteId: sites.siteId,
|
||||||
|
name: sites.name,
|
||||||
|
niceId: sites.niceId
|
||||||
|
})
|
||||||
|
.from(sites)
|
||||||
|
.where(inArray(sites.siteId, siteIds));
|
||||||
|
|
||||||
|
for (const s of siteDetails) {
|
||||||
|
siteMap.set(s.siteId, { name: s.name, niceId: s.niceId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch client details from main database
|
||||||
|
const clientMap = new Map<
|
||||||
|
number,
|
||||||
|
{ name: string; niceId: string; type: string }
|
||||||
|
>();
|
||||||
|
if (clientIds.length > 0) {
|
||||||
|
const clientDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
clientId: clients.clientId,
|
||||||
|
name: clients.name,
|
||||||
|
niceId: clients.niceId,
|
||||||
|
type: clients.type
|
||||||
|
})
|
||||||
|
.from(clients)
|
||||||
|
.where(inArray(clients.clientId, clientIds));
|
||||||
|
|
||||||
|
for (const c of clientDetails) {
|
||||||
|
clientMap.set(c.clientId, {
|
||||||
|
name: c.name,
|
||||||
|
niceId: c.niceId,
|
||||||
|
type: c.type
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch user details from main database
|
||||||
|
const userMap = new Map<
|
||||||
|
string,
|
||||||
|
{ email: string | null }
|
||||||
|
>();
|
||||||
|
if (userIds.length > 0) {
|
||||||
|
const userDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
userId: users.userId,
|
||||||
|
email: users.email
|
||||||
|
})
|
||||||
|
.from(users)
|
||||||
|
.where(inArray(users.userId, userIds));
|
||||||
|
|
||||||
|
for (const u of userDetails) {
|
||||||
|
userMap.set(u.userId, { email: u.email });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enrich logs with details
|
||||||
|
return logs.map((log) => ({
|
||||||
|
...log,
|
||||||
|
resourceName: log.siteResourceId
|
||||||
|
? resourceMap.get(log.siteResourceId)?.name ?? null
|
||||||
|
: null,
|
||||||
|
resourceNiceId: log.siteResourceId
|
||||||
|
? resourceMap.get(log.siteResourceId)?.niceId ?? null
|
||||||
|
: null,
|
||||||
|
siteName: log.siteId
|
||||||
|
? siteMap.get(log.siteId)?.name ?? null
|
||||||
|
: null,
|
||||||
|
siteNiceId: log.siteId
|
||||||
|
? siteMap.get(log.siteId)?.niceId ?? null
|
||||||
|
: null,
|
||||||
|
clientName: log.clientId
|
||||||
|
? clientMap.get(log.clientId)?.name ?? null
|
||||||
|
: null,
|
||||||
|
clientNiceId: log.clientId
|
||||||
|
? clientMap.get(log.clientId)?.niceId ?? null
|
||||||
|
: null,
|
||||||
|
clientType: log.clientId
|
||||||
|
? clientMap.get(log.clientId)?.type ?? null
|
||||||
|
: null,
|
||||||
|
userEmail: log.userId
|
||||||
|
? userMap.get(log.userId)?.email ?? null
|
||||||
|
: null
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function queryUniqueFilterAttributes(
|
||||||
|
timeStart: number,
|
||||||
|
timeEnd: number,
|
||||||
|
orgId: string
|
||||||
|
) {
|
||||||
|
const baseConditions = and(
|
||||||
|
gt(connectionAuditLog.startedAt, timeStart),
|
||||||
|
lt(connectionAuditLog.startedAt, timeEnd),
|
||||||
|
eq(connectionAuditLog.orgId, orgId)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Get unique protocols
|
||||||
|
const uniqueProtocols = await logsDb
|
||||||
|
.selectDistinct({
|
||||||
|
protocol: connectionAuditLog.protocol
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(baseConditions);
|
||||||
|
|
||||||
|
// Get unique destination addresses
|
||||||
|
const uniqueDestAddrs = await logsDb
|
||||||
|
.selectDistinct({
|
||||||
|
destAddr: connectionAuditLog.destAddr
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(baseConditions);
|
||||||
|
|
||||||
|
// Get unique client IDs
|
||||||
|
const uniqueClients = await logsDb
|
||||||
|
.selectDistinct({
|
||||||
|
clientId: connectionAuditLog.clientId
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(baseConditions);
|
||||||
|
|
||||||
|
// Get unique resource IDs
|
||||||
|
const uniqueResources = await logsDb
|
||||||
|
.selectDistinct({
|
||||||
|
siteResourceId: connectionAuditLog.siteResourceId
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(baseConditions);
|
||||||
|
|
||||||
|
// Get unique user IDs
|
||||||
|
const uniqueUsers = await logsDb
|
||||||
|
.selectDistinct({
|
||||||
|
userId: connectionAuditLog.userId
|
||||||
|
})
|
||||||
|
.from(connectionAuditLog)
|
||||||
|
.where(baseConditions);
|
||||||
|
|
||||||
|
// Enrich client IDs with names from main database
|
||||||
|
const clientIds = uniqueClients
|
||||||
|
.map((row) => row.clientId)
|
||||||
|
.filter((id): id is number => id !== null);
|
||||||
|
|
||||||
|
let clientsWithNames: Array<{ id: number; name: string }> = [];
|
||||||
|
if (clientIds.length > 0) {
|
||||||
|
const clientDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
clientId: clients.clientId,
|
||||||
|
name: clients.name
|
||||||
|
})
|
||||||
|
.from(clients)
|
||||||
|
.where(inArray(clients.clientId, clientIds));
|
||||||
|
|
||||||
|
clientsWithNames = clientDetails.map((c) => ({
|
||||||
|
id: c.clientId,
|
||||||
|
name: c.name
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enrich resource IDs with names from main database
|
||||||
|
const resourceIds = uniqueResources
|
||||||
|
.map((row) => row.siteResourceId)
|
||||||
|
.filter((id): id is number => id !== null);
|
||||||
|
|
||||||
|
let resourcesWithNames: Array<{ id: number; name: string | null }> = [];
|
||||||
|
if (resourceIds.length > 0) {
|
||||||
|
const resourceDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
siteResourceId: siteResources.siteResourceId,
|
||||||
|
name: siteResources.name
|
||||||
|
})
|
||||||
|
.from(siteResources)
|
||||||
|
.where(inArray(siteResources.siteResourceId, resourceIds));
|
||||||
|
|
||||||
|
resourcesWithNames = resourceDetails.map((r) => ({
|
||||||
|
id: r.siteResourceId,
|
||||||
|
name: r.name
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enrich user IDs with emails from main database
|
||||||
|
const userIdsList = uniqueUsers
|
||||||
|
.map((row) => row.userId)
|
||||||
|
.filter((id): id is string => id !== null);
|
||||||
|
|
||||||
|
let usersWithEmails: Array<{ id: string; email: string | null }> = [];
|
||||||
|
if (userIdsList.length > 0) {
|
||||||
|
const userDetails = await primaryDb
|
||||||
|
.select({
|
||||||
|
userId: users.userId,
|
||||||
|
email: users.email
|
||||||
|
})
|
||||||
|
.from(users)
|
||||||
|
.where(inArray(users.userId, userIdsList));
|
||||||
|
|
||||||
|
usersWithEmails = userDetails.map((u) => ({
|
||||||
|
id: u.userId,
|
||||||
|
email: u.email
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
protocols: uniqueProtocols
|
||||||
|
.map((row) => row.protocol)
|
||||||
|
.filter((protocol): protocol is string => protocol !== null),
|
||||||
|
destAddrs: uniqueDestAddrs
|
||||||
|
.map((row) => row.destAddr)
|
||||||
|
.filter((addr): addr is string => addr !== null),
|
||||||
|
clients: clientsWithNames,
|
||||||
|
resources: resourcesWithNames,
|
||||||
|
users: usersWithEmails
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: "get",
|
||||||
|
path: "/org/{orgId}/logs/connection",
|
||||||
|
description: "Query the connection audit log for an organization",
|
||||||
|
tags: [OpenAPITags.Logs],
|
||||||
|
request: {
|
||||||
|
query: queryConnectionAuditLogsQuery,
|
||||||
|
params: queryConnectionAuditLogsParams
|
||||||
|
},
|
||||||
|
responses: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function queryConnectionAuditLogs(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedQuery = queryConnectionAuditLogsQuery.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const parsedParams = queryConnectionAuditLogsParams.safeParse(
|
||||||
|
req.params
|
||||||
|
);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = { ...parsedQuery.data, ...parsedParams.data };
|
||||||
|
|
||||||
|
const baseQuery = queryConnection(data);
|
||||||
|
|
||||||
|
const logsRaw = await baseQuery.limit(data.limit).offset(data.offset);
|
||||||
|
|
||||||
|
// Enrich with resource, site, client, and user details
|
||||||
|
const log = await enrichWithDetails(logsRaw);
|
||||||
|
|
||||||
|
const totalCountResult = await countConnectionQuery(data);
|
||||||
|
const totalCount = totalCountResult[0].count;
|
||||||
|
|
||||||
|
const filterAttributes = await queryUniqueFilterAttributes(
|
||||||
|
data.timeStart,
|
||||||
|
data.timeEnd,
|
||||||
|
data.orgId
|
||||||
|
);
|
||||||
|
|
||||||
|
return response<QueryConnectionAuditLogResponse>(res, {
|
||||||
|
data: {
|
||||||
|
log: log,
|
||||||
|
pagination: {
|
||||||
|
total: totalCount,
|
||||||
|
limit: data.limit,
|
||||||
|
offset: data.offset
|
||||||
|
},
|
||||||
|
filterAttributes
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Connection audit logs retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,9 +26,12 @@ import {
|
|||||||
orgs,
|
orgs,
|
||||||
resources,
|
resources,
|
||||||
roles,
|
roles,
|
||||||
siteResources
|
siteResources,
|
||||||
|
userOrgRoles,
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
siteProvisioningKeys,
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum allowed retention days for a given tier
|
* Get the maximum allowed retention days for a given tier
|
||||||
@@ -291,6 +294,14 @@ async function disableFeature(
|
|||||||
await disableSshPam(orgId);
|
await disableSshPam(orgId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TierFeature.FullRbac:
|
||||||
|
await disableFullRbac(orgId);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TierFeature.SiteProvisioningKeys:
|
||||||
|
await disableSiteProvisioningKeys(orgId);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`Unknown feature ${feature} for org ${orgId}, skipping`
|
`Unknown feature ${feature} for org ${orgId}, skipping`
|
||||||
@@ -326,6 +337,61 @@ async function disableSshPam(orgId: string): Promise<void> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function disableFullRbac(orgId: string): Promise<void> {
|
||||||
|
logger.info(`Disabled full RBAC for org ${orgId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function disableSiteProvisioningKeys(orgId: string): Promise<void> {
|
||||||
|
const rows = await db
|
||||||
|
.select({
|
||||||
|
siteProvisioningKeyId:
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId
|
||||||
|
})
|
||||||
|
.from(siteProvisioningKeyOrg)
|
||||||
|
.where(eq(siteProvisioningKeyOrg.orgId, orgId));
|
||||||
|
|
||||||
|
for (const { siteProvisioningKeyId } of rows) {
|
||||||
|
await db.transaction(async (trx) => {
|
||||||
|
await trx
|
||||||
|
.delete(siteProvisioningKeyOrg)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
),
|
||||||
|
eq(siteProvisioningKeyOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const remaining = await trx
|
||||||
|
.select()
|
||||||
|
.from(siteProvisioningKeyOrg)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (remaining.length === 0) {
|
||||||
|
await trx
|
||||||
|
.delete(siteProvisioningKeys)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
`Removed site provisioning keys for org ${orgId} after tier downgrade`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async function disableLoginPageBranding(orgId: string): Promise<void> {
|
async function disableLoginPageBranding(orgId: string): Promise<void> {
|
||||||
const [existingBranding] = await db
|
const [existingBranding] = await db
|
||||||
.select()
|
.select()
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import * as misc from "#private/routers/misc";
|
|||||||
import * as reKey from "#private/routers/re-key";
|
import * as reKey from "#private/routers/re-key";
|
||||||
import * as approval from "#private/routers/approvals";
|
import * as approval from "#private/routers/approvals";
|
||||||
import * as ssh from "#private/routers/ssh";
|
import * as ssh from "#private/routers/ssh";
|
||||||
|
import * as user from "#private/routers/user";
|
||||||
|
import * as siteProvisioning from "#private/routers/siteProvisioning";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
@@ -33,7 +35,11 @@ import {
|
|||||||
verifyUserIsServerAdmin,
|
verifyUserIsServerAdmin,
|
||||||
verifySiteAccess,
|
verifySiteAccess,
|
||||||
verifyClientAccess,
|
verifyClientAccess,
|
||||||
verifyLimits
|
verifyLimits,
|
||||||
|
verifyRoleAccess,
|
||||||
|
verifyUserAccess,
|
||||||
|
verifyUserCanSetUserOrgRoles,
|
||||||
|
verifySiteProvisioningKeyAccess
|
||||||
} from "@server/middlewares";
|
} from "@server/middlewares";
|
||||||
import { ActionsEnum } from "@server/auth/actions";
|
import { ActionsEnum } from "@server/auth/actions";
|
||||||
import {
|
import {
|
||||||
@@ -478,6 +484,25 @@ authenticated.get(
|
|||||||
logs.exportAccessAuditLogs
|
logs.exportAccessAuditLogs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/logs/connection",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.connectionLogs),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.exportLogs),
|
||||||
|
logs.queryConnectionAuditLogs
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/logs/connection/export",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.logExport),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.exportLogs),
|
||||||
|
logActionAudit(ActionsEnum.exportLogs),
|
||||||
|
logs.exportConnectionAuditLogs
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
"/re-key/:clientId/regenerate-client-secret",
|
"/re-key/:clientId/regenerate-client-secret",
|
||||||
verifyClientAccess, // this is first to set the org id
|
verifyClientAccess, // this is first to set the org id
|
||||||
@@ -518,3 +543,75 @@ authenticated.post(
|
|||||||
// logActionAudit(ActionsEnum.signSshKey), // it is handled inside of the function below so we can include more metadata
|
// logActionAudit(ActionsEnum.signSshKey), // it is handled inside of the function below so we can include more metadata
|
||||||
ssh.signSshKey
|
ssh.signSshKey
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.post(
|
||||||
|
"/user/:userId/add-role/:roleId",
|
||||||
|
verifyRoleAccess,
|
||||||
|
verifyUserAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyUserHasAction(ActionsEnum.addUserRole),
|
||||||
|
logActionAudit(ActionsEnum.addUserRole),
|
||||||
|
user.addUserRole
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.delete(
|
||||||
|
"/user/:userId/remove-role/:roleId",
|
||||||
|
verifyRoleAccess,
|
||||||
|
verifyUserAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyUserHasAction(ActionsEnum.removeUserRole),
|
||||||
|
logActionAudit(ActionsEnum.removeUserRole),
|
||||||
|
user.removeUserRole
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.post(
|
||||||
|
"/user/:userId/org/:orgId/roles",
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyUserCanSetUserOrgRoles(),
|
||||||
|
logActionAudit(ActionsEnum.setUserOrgRoles),
|
||||||
|
user.setUserOrgRoles
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.put(
|
||||||
|
"/org/:orgId/site-provisioning-key",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.siteProvisioningKeys),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyUserHasAction(ActionsEnum.createSiteProvisioningKey),
|
||||||
|
logActionAudit(ActionsEnum.createSiteProvisioningKey),
|
||||||
|
siteProvisioning.createSiteProvisioningKey
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/site-provisioning-keys",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.siteProvisioningKeys),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.listSiteProvisioningKeys),
|
||||||
|
siteProvisioning.listSiteProvisioningKeys
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.delete(
|
||||||
|
"/org/:orgId/site-provisioning-key/:siteProvisioningKeyId",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.siteProvisioningKeys),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifySiteProvisioningKeyAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.deleteSiteProvisioningKey),
|
||||||
|
logActionAudit(ActionsEnum.deleteSiteProvisioningKey),
|
||||||
|
siteProvisioning.deleteSiteProvisioningKey
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.patch(
|
||||||
|
"/org/:orgId/site-provisioning-key/:siteProvisioningKeyId",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.siteProvisioningKeys),
|
||||||
|
verifyOrgAccess,
|
||||||
|
verifySiteProvisioningKeyAccess,
|
||||||
|
verifyUserHasAction(ActionsEnum.updateSiteProvisioningKey),
|
||||||
|
logActionAudit(ActionsEnum.updateSiteProvisioningKey),
|
||||||
|
siteProvisioning.updateSiteProvisioningKey
|
||||||
|
);
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ import {
|
|||||||
userOrgs,
|
userOrgs,
|
||||||
roleResources,
|
roleResources,
|
||||||
userResources,
|
userResources,
|
||||||
resourceRules
|
resourceRules,
|
||||||
|
userOrgRoles,
|
||||||
|
roles
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
import { eq, and, inArray, isNotNull, ne } from "drizzle-orm";
|
import { eq, and, inArray, isNotNull, ne } from "drizzle-orm";
|
||||||
import { response } from "@server/lib/response";
|
import { response } from "@server/lib/response";
|
||||||
@@ -104,6 +106,13 @@ const getUserOrgSessionVerifySchema = z.strictObject({
|
|||||||
sessionId: z.string().min(1, "Session ID is required")
|
sessionId: z.string().min(1, "Session ID is required")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getRoleNameParamsSchema = z.strictObject({
|
||||||
|
roleId: z
|
||||||
|
.string()
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive("Role ID must be a positive integer"))
|
||||||
|
});
|
||||||
|
|
||||||
const getRoleResourceAccessParamsSchema = z.strictObject({
|
const getRoleResourceAccessParamsSchema = z.strictObject({
|
||||||
roleId: z
|
roleId: z
|
||||||
.string()
|
.string()
|
||||||
@@ -115,6 +124,23 @@ const getRoleResourceAccessParamsSchema = z.strictObject({
|
|||||||
.pipe(z.int().positive("Resource ID must be a positive integer"))
|
.pipe(z.int().positive("Resource ID must be a positive integer"))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getResourceAccessParamsSchema = z.strictObject({
|
||||||
|
resourceId: z
|
||||||
|
.string()
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive("Resource ID must be a positive integer"))
|
||||||
|
});
|
||||||
|
|
||||||
|
const getResourceAccessQuerySchema = z.strictObject({
|
||||||
|
roleIds: z
|
||||||
|
.union([z.array(z.string()), z.string()])
|
||||||
|
.transform((val) =>
|
||||||
|
(Array.isArray(val) ? val : [val])
|
||||||
|
.map(Number)
|
||||||
|
.filter((n) => !isNaN(n))
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
const getUserResourceAccessParamsSchema = z.strictObject({
|
const getUserResourceAccessParamsSchema = z.strictObject({
|
||||||
userId: z.string().min(1, "User ID is required"),
|
userId: z.string().min(1, "User ID is required"),
|
||||||
resourceId: z
|
resourceId: z
|
||||||
@@ -760,7 +786,7 @@ hybridRouter.get(
|
|||||||
|
|
||||||
// Get user organization role
|
// Get user organization role
|
||||||
hybridRouter.get(
|
hybridRouter.get(
|
||||||
"/user/:userId/org/:orgId/role",
|
"/user/:userId/org/:orgId/roles",
|
||||||
async (req: Request, res: Response, next: NextFunction) => {
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
try {
|
try {
|
||||||
const parsedParams = getUserOrgRoleParamsSchema.safeParse(
|
const parsedParams = getUserOrgRoleParamsSchema.safeParse(
|
||||||
@@ -796,23 +822,129 @@ hybridRouter.get(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRole = await db
|
const userOrgRoleRows = await db
|
||||||
.select()
|
.select({ roleId: userOrgRoles.roleId, roleName: roles.name })
|
||||||
.from(userOrgs)
|
.from(userOrgRoles)
|
||||||
|
.innerJoin(roles, eq(roles.roleId, userOrgRoles.roleId))
|
||||||
.where(
|
.where(
|
||||||
and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, orgId))
|
and(
|
||||||
)
|
eq(userOrgRoles.userId, userId),
|
||||||
.limit(1);
|
eq(userOrgRoles.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
const result = userOrgRole.length > 0 ? userOrgRole[0] : null;
|
logger.debug(`User ${userId} has roles in org ${orgId}:`, userOrgRoleRows);
|
||||||
|
|
||||||
return response<typeof userOrgs.$inferSelect | null>(res, {
|
return response<{ roleId: number, roleName: string }[]>(res, {
|
||||||
data: result,
|
data: userOrgRoleRows,
|
||||||
success: true,
|
success: true,
|
||||||
error: false,
|
error: false,
|
||||||
message: result
|
message:
|
||||||
? "User org role retrieved successfully"
|
userOrgRoleRows.length > 0
|
||||||
: "User org role not found",
|
? "User org roles retrieved successfully"
|
||||||
|
: "User has no roles in this organization",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to get user org role"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// DEPRICATED Get user organization role
|
||||||
|
// used for backward compatibility with old remote nodes
|
||||||
|
hybridRouter.get(
|
||||||
|
"/user/:userId/org/:orgId/role", // <- note the missing s
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const parsedParams = getUserOrgRoleParamsSchema.safeParse(
|
||||||
|
req.params
|
||||||
|
);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { userId, orgId } = parsedParams.data;
|
||||||
|
const remoteExitNode = req.remoteExitNode;
|
||||||
|
|
||||||
|
if (!remoteExitNode || !remoteExitNode.exitNodeId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Remote exit node not found"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await checkExitNodeOrg(remoteExitNode.exitNodeId, orgId)) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.UNAUTHORIZED,
|
||||||
|
"User is not authorized to access this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the roles on the user
|
||||||
|
|
||||||
|
const userOrgRoleRows = await db
|
||||||
|
.select({ roleId: userOrgRoles.roleId })
|
||||||
|
.from(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const roleIds = userOrgRoleRows.map((r) => r.roleId);
|
||||||
|
|
||||||
|
let roleId: number | null = null;
|
||||||
|
|
||||||
|
if (userOrgRoleRows.length === 0) {
|
||||||
|
// User has no roles in this organization
|
||||||
|
roleId = null;
|
||||||
|
} else if (userOrgRoleRows.length === 1) {
|
||||||
|
// User has exactly one role, return it
|
||||||
|
roleId = userOrgRoleRows[0].roleId;
|
||||||
|
} else {
|
||||||
|
// User has multiple roles
|
||||||
|
// Check if any of these roles are also assigned to a resource
|
||||||
|
// If we find a match, prefer that role; otherwise return the first role
|
||||||
|
// Get all resources that have any of these roles assigned
|
||||||
|
const roleResourceMatches = await db
|
||||||
|
.select({ roleId: roleResources.roleId })
|
||||||
|
.from(roleResources)
|
||||||
|
.where(inArray(roleResources.roleId, roleIds))
|
||||||
|
.limit(1);
|
||||||
|
if (roleResourceMatches.length > 0) {
|
||||||
|
// Return the first role that's also on a resource
|
||||||
|
roleId = roleResourceMatches[0].roleId;
|
||||||
|
} else {
|
||||||
|
// No resource match found, return the first role
|
||||||
|
roleId = userOrgRoleRows[0].roleId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response<{ roleId: number | null }>(res, {
|
||||||
|
data: { roleId },
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message:
|
||||||
|
roleIds.length > 0
|
||||||
|
? "User org roles retrieved successfully"
|
||||||
|
: "User has no roles in this organization",
|
||||||
status: HttpCode.OK
|
status: HttpCode.OK
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -890,6 +1022,60 @@ hybridRouter.get(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Get role name by ID
|
||||||
|
hybridRouter.get(
|
||||||
|
"/role/:roleId/name",
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const parsedParams = getRoleNameParamsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { roleId } = parsedParams.data;
|
||||||
|
const remoteExitNode = req.remoteExitNode;
|
||||||
|
|
||||||
|
if (!remoteExitNode?.exitNodeId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Remote exit node not found"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [role] = await db
|
||||||
|
.select({ name: roles.name })
|
||||||
|
.from(roles)
|
||||||
|
.where(eq(roles.roleId, roleId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
return response<string | null>(res, {
|
||||||
|
data: role?.name ?? null,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: role
|
||||||
|
? "Role name retrieved successfully"
|
||||||
|
: "Role not found",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to get role name"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Check if role has access to resource
|
// Check if role has access to resource
|
||||||
hybridRouter.get(
|
hybridRouter.get(
|
||||||
"/role/:roleId/resource/:resourceId/access",
|
"/role/:roleId/resource/:resourceId/access",
|
||||||
@@ -975,6 +1161,101 @@ hybridRouter.get(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check if role has access to resource
|
||||||
|
hybridRouter.get(
|
||||||
|
"/resource/:resourceId/access",
|
||||||
|
async (req: Request, res: Response, next: NextFunction) => {
|
||||||
|
try {
|
||||||
|
const parsedParams = getResourceAccessParamsSchema.safeParse(
|
||||||
|
req.params
|
||||||
|
);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { resourceId } = parsedParams.data;
|
||||||
|
const parsedQuery = getResourceAccessQuerySchema.safeParse(
|
||||||
|
req.query
|
||||||
|
);
|
||||||
|
const roleIds = parsedQuery.success ? parsedQuery.data.roleIds : [];
|
||||||
|
|
||||||
|
const remoteExitNode = req.remoteExitNode;
|
||||||
|
|
||||||
|
if (!remoteExitNode?.exitNodeId) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"Remote exit node not found"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [resource] = await db
|
||||||
|
.select()
|
||||||
|
.from(resources)
|
||||||
|
.where(eq(resources.resourceId, resourceId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (
|
||||||
|
await checkExitNodeOrg(
|
||||||
|
remoteExitNode.exitNodeId,
|
||||||
|
resource.orgId
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
// If the exit node is not allowed for the org, return an error
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"Exit node not allowed for this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const roleResourceAccess = await db
|
||||||
|
.select({
|
||||||
|
resourceId: roleResources.resourceId,
|
||||||
|
roleId: roleResources.roleId
|
||||||
|
})
|
||||||
|
.from(roleResources)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(roleResources.resourceId, resourceId),
|
||||||
|
inArray(roleResources.roleId, roleIds)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const result =
|
||||||
|
roleResourceAccess.length > 0 ? roleResourceAccess : null;
|
||||||
|
|
||||||
|
return response<{ resourceId: number; roleId: number }[] | null>(
|
||||||
|
res,
|
||||||
|
{
|
||||||
|
data: result,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: result
|
||||||
|
? "Role resource access retrieved successfully"
|
||||||
|
: "Role resource access not found",
|
||||||
|
status: HttpCode.OK
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to get role resource access"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Check if user has direct access to resource
|
// Check if user has direct access to resource
|
||||||
hybridRouter.get(
|
hybridRouter.get(
|
||||||
"/user/:userId/resource/:resourceId/access",
|
"/user/:userId/resource/:resourceId/access",
|
||||||
@@ -1873,7 +2154,8 @@ hybridRouter.post(
|
|||||||
// userAgent: data.userAgent, // TODO: add this
|
// userAgent: data.userAgent, // TODO: add this
|
||||||
// headers: data.body.headers,
|
// headers: data.body.headers,
|
||||||
// query: data.body.query,
|
// query: data.body.query,
|
||||||
originalRequestURL: sanitizeString(logEntry.originalRequestURL) ?? "",
|
originalRequestURL:
|
||||||
|
sanitizeString(logEntry.originalRequestURL) ?? "",
|
||||||
scheme: sanitizeString(logEntry.scheme) ?? "",
|
scheme: sanitizeString(logEntry.scheme) ?? "",
|
||||||
host: sanitizeString(logEntry.host) ?? "",
|
host: sanitizeString(logEntry.host) ?? "",
|
||||||
path: sanitizeString(logEntry.path) ?? "",
|
path: sanitizeString(logEntry.path) ?? "",
|
||||||
|
|||||||
@@ -20,8 +20,11 @@ import {
|
|||||||
verifyApiKeyIsRoot,
|
verifyApiKeyIsRoot,
|
||||||
verifyApiKeyOrgAccess,
|
verifyApiKeyOrgAccess,
|
||||||
verifyApiKeyIdpAccess,
|
verifyApiKeyIdpAccess,
|
||||||
|
verifyApiKeyRoleAccess,
|
||||||
|
verifyApiKeyUserAccess,
|
||||||
verifyLimits
|
verifyLimits
|
||||||
} from "@server/middlewares";
|
} from "@server/middlewares";
|
||||||
|
import * as user from "#private/routers/user";
|
||||||
import {
|
import {
|
||||||
verifyValidSubscription,
|
verifyValidSubscription,
|
||||||
verifyValidLicense
|
verifyValidLicense
|
||||||
@@ -91,6 +94,25 @@ authenticated.get(
|
|||||||
logs.exportAccessAuditLogs
|
logs.exportAccessAuditLogs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/logs/connection",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.connectionLogs),
|
||||||
|
verifyApiKeyOrgAccess,
|
||||||
|
verifyApiKeyHasAction(ActionsEnum.exportLogs),
|
||||||
|
logs.queryConnectionAuditLogs
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.get(
|
||||||
|
"/org/:orgId/logs/connection/export",
|
||||||
|
verifyValidLicense,
|
||||||
|
verifyValidSubscription(tierMatrix.logExport),
|
||||||
|
verifyApiKeyOrgAccess,
|
||||||
|
verifyApiKeyHasAction(ActionsEnum.exportLogs),
|
||||||
|
logActionAudit(ActionsEnum.exportLogs),
|
||||||
|
logs.exportConnectionAuditLogs
|
||||||
|
);
|
||||||
|
|
||||||
authenticated.put(
|
authenticated.put(
|
||||||
"/org/:orgId/idp/oidc",
|
"/org/:orgId/idp/oidc",
|
||||||
verifyValidLicense,
|
verifyValidLicense,
|
||||||
@@ -140,3 +162,23 @@ authenticated.get(
|
|||||||
verifyApiKeyHasAction(ActionsEnum.listIdps),
|
verifyApiKeyHasAction(ActionsEnum.listIdps),
|
||||||
orgIdp.listOrgIdps
|
orgIdp.listOrgIdps
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authenticated.post(
|
||||||
|
"/user/:userId/add-role/:roleId",
|
||||||
|
verifyApiKeyRoleAccess,
|
||||||
|
verifyApiKeyUserAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyApiKeyHasAction(ActionsEnum.addUserRole),
|
||||||
|
logActionAudit(ActionsEnum.addUserRole),
|
||||||
|
user.addUserRole
|
||||||
|
);
|
||||||
|
|
||||||
|
authenticated.delete(
|
||||||
|
"/user/:userId/remove-role/:roleId",
|
||||||
|
verifyApiKeyRoleAccess,
|
||||||
|
verifyApiKeyUserAccess,
|
||||||
|
verifyLimits,
|
||||||
|
verifyApiKeyHasAction(ActionsEnum.removeUserRole),
|
||||||
|
logActionAudit(ActionsEnum.removeUserRole),
|
||||||
|
user.removeUserRole
|
||||||
|
);
|
||||||
|
|||||||
394
server/private/routers/newt/handleConnectionLogMessage.ts
Normal file
394
server/private/routers/newt/handleConnectionLogMessage.ts
Normal file
@@ -0,0 +1,394 @@
|
|||||||
|
import { db, logsDb } from "@server/db";
|
||||||
|
import { MessageHandler } from "@server/routers/ws";
|
||||||
|
import { connectionAuditLog, sites, Newt, clients, orgs } from "@server/db";
|
||||||
|
import { and, eq, lt, inArray } from "drizzle-orm";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { inflate } from "zlib";
|
||||||
|
import { promisify } from "util";
|
||||||
|
import { calculateCutoffTimestamp } from "@server/lib/cleanupLogs";
|
||||||
|
|
||||||
|
const zlibInflate = promisify(inflate);
|
||||||
|
|
||||||
|
// Retry configuration for deadlock handling
|
||||||
|
const MAX_RETRIES = 3;
|
||||||
|
const BASE_DELAY_MS = 50;
|
||||||
|
|
||||||
|
// How often to flush accumulated connection log data to the database
|
||||||
|
const FLUSH_INTERVAL_MS = 30_000; // 30 seconds
|
||||||
|
|
||||||
|
// Maximum number of records to buffer before forcing a flush
|
||||||
|
const MAX_BUFFERED_RECORDS = 500;
|
||||||
|
|
||||||
|
// Maximum number of records to insert in a single batch
|
||||||
|
const INSERT_BATCH_SIZE = 100;
|
||||||
|
|
||||||
|
interface ConnectionSessionData {
|
||||||
|
sessionId: string;
|
||||||
|
resourceId: number;
|
||||||
|
sourceAddr: string;
|
||||||
|
destAddr: string;
|
||||||
|
protocol: string;
|
||||||
|
startedAt: string; // ISO 8601 timestamp
|
||||||
|
endedAt?: string; // ISO 8601 timestamp
|
||||||
|
bytesTx?: number;
|
||||||
|
bytesRx?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ConnectionLogRecord {
|
||||||
|
sessionId: string;
|
||||||
|
siteResourceId: number;
|
||||||
|
orgId: string;
|
||||||
|
siteId: number;
|
||||||
|
clientId: number | null;
|
||||||
|
userId: string | null;
|
||||||
|
sourceAddr: string;
|
||||||
|
destAddr: string;
|
||||||
|
protocol: string;
|
||||||
|
startedAt: number; // epoch seconds
|
||||||
|
endedAt: number | null;
|
||||||
|
bytesTx: number | null;
|
||||||
|
bytesRx: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In-memory buffer of records waiting to be flushed
|
||||||
|
let buffer: ConnectionLogRecord[] = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if an error is a deadlock error
|
||||||
|
*/
|
||||||
|
function isDeadlockError(error: any): boolean {
|
||||||
|
return (
|
||||||
|
error?.code === "40P01" ||
|
||||||
|
error?.cause?.code === "40P01" ||
|
||||||
|
(error?.message && error.message.includes("deadlock"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a function with retry logic for deadlock handling
|
||||||
|
*/
|
||||||
|
async function withDeadlockRetry<T>(
|
||||||
|
operation: () => Promise<T>,
|
||||||
|
context: string
|
||||||
|
): Promise<T> {
|
||||||
|
let attempt = 0;
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
return await operation();
|
||||||
|
} catch (error: any) {
|
||||||
|
if (isDeadlockError(error) && attempt < MAX_RETRIES) {
|
||||||
|
attempt++;
|
||||||
|
const baseDelay = Math.pow(2, attempt - 1) * BASE_DELAY_MS;
|
||||||
|
const jitter = Math.random() * baseDelay;
|
||||||
|
const delay = baseDelay + jitter;
|
||||||
|
logger.warn(
|
||||||
|
`Deadlock detected in ${context}, retrying attempt ${attempt}/${MAX_RETRIES} after ${delay.toFixed(0)}ms`
|
||||||
|
);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decompress a base64-encoded zlib-compressed string into parsed JSON.
|
||||||
|
*/
|
||||||
|
async function decompressConnectionLog(
|
||||||
|
compressed: string
|
||||||
|
): Promise<ConnectionSessionData[]> {
|
||||||
|
const compressedBuffer = Buffer.from(compressed, "base64");
|
||||||
|
const decompressed = await zlibInflate(compressedBuffer);
|
||||||
|
const jsonString = decompressed.toString("utf-8");
|
||||||
|
const parsed = JSON.parse(jsonString);
|
||||||
|
|
||||||
|
if (!Array.isArray(parsed)) {
|
||||||
|
throw new Error("Decompressed connection log data is not an array");
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an ISO 8601 timestamp string to epoch seconds.
|
||||||
|
* Returns null if the input is falsy.
|
||||||
|
*/
|
||||||
|
function toEpochSeconds(isoString: string | undefined | null): number | null {
|
||||||
|
if (!isoString) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const ms = new Date(isoString).getTime();
|
||||||
|
if (isNaN(ms)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Math.floor(ms / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush all buffered connection log records to the database.
|
||||||
|
*
|
||||||
|
* Swaps out the buffer before writing so that any records added during the
|
||||||
|
* flush are captured in the new buffer rather than being lost. Entries that
|
||||||
|
* fail to write are re-queued back into the buffer so they will be retried
|
||||||
|
* on the next flush.
|
||||||
|
*
|
||||||
|
* This function is exported so that the application's graceful-shutdown
|
||||||
|
* cleanup handler can call it before the process exits.
|
||||||
|
*/
|
||||||
|
export async function flushConnectionLogToDb(): Promise<void> {
|
||||||
|
if (buffer.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Atomically swap out the buffer so new data keeps flowing in
|
||||||
|
const snapshot = buffer;
|
||||||
|
buffer = [];
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Flushing ${snapshot.length} connection log record(s) to the database`
|
||||||
|
);
|
||||||
|
|
||||||
|
// Insert in batches to avoid overly large SQL statements
|
||||||
|
for (let i = 0; i < snapshot.length; i += INSERT_BATCH_SIZE) {
|
||||||
|
const batch = snapshot.slice(i, i + INSERT_BATCH_SIZE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await withDeadlockRetry(async () => {
|
||||||
|
await logsDb.insert(connectionAuditLog).values(batch);
|
||||||
|
}, `flush connection log batch (${batch.length} records)`);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
`Failed to flush connection log batch of ${batch.length} records:`,
|
||||||
|
error
|
||||||
|
);
|
||||||
|
|
||||||
|
// Re-queue the failed batch so it is retried on the next flush
|
||||||
|
buffer = [...batch, ...buffer];
|
||||||
|
|
||||||
|
// Cap buffer to prevent unbounded growth if DB is unreachable
|
||||||
|
if (buffer.length > MAX_BUFFERED_RECORDS * 5) {
|
||||||
|
const dropped = buffer.length - MAX_BUFFERED_RECORDS * 5;
|
||||||
|
buffer = buffer.slice(0, MAX_BUFFERED_RECORDS * 5);
|
||||||
|
logger.warn(
|
||||||
|
`Connection log buffer overflow, dropped ${dropped} oldest records`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop trying further batches from this snapshot — they'll be
|
||||||
|
// picked up by the next flush via the re-queued records above
|
||||||
|
const remaining = snapshot.slice(i + INSERT_BATCH_SIZE);
|
||||||
|
if (remaining.length > 0) {
|
||||||
|
buffer = [...remaining, ...buffer];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const flushTimer = setInterval(async () => {
|
||||||
|
try {
|
||||||
|
await flushConnectionLogToDb();
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
"Unexpected error during periodic connection log flush:",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, FLUSH_INTERVAL_MS);
|
||||||
|
|
||||||
|
// Calling unref() means this timer will not keep the Node.js event loop alive
|
||||||
|
// on its own — the process can still exit normally when there is no other work
|
||||||
|
// left. The graceful-shutdown path will call flushConnectionLogToDb() explicitly
|
||||||
|
// before process.exit(), so no data is lost.
|
||||||
|
flushTimer.unref();
|
||||||
|
|
||||||
|
export async function cleanUpOldLogs(orgId: string, retentionDays: number) {
|
||||||
|
const cutoffTimestamp = calculateCutoffTimestamp(retentionDays);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await logsDb
|
||||||
|
.delete(connectionAuditLog)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
lt(connectionAuditLog.startedAt, cutoffTimestamp),
|
||||||
|
eq(connectionAuditLog.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// logger.debug(
|
||||||
|
// `Cleaned up connection audit logs older than ${retentionDays} days`
|
||||||
|
// );
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Error cleaning up old connection audit logs:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handleConnectionLogMessage: MessageHandler = async (context) => {
|
||||||
|
const { message, client } = context;
|
||||||
|
const newt = client as Newt;
|
||||||
|
|
||||||
|
if (!newt) {
|
||||||
|
logger.warn("Connection log received but no newt client in context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!newt.siteId) {
|
||||||
|
logger.warn("Connection log received but newt has no siteId");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.data?.compressed) {
|
||||||
|
logger.warn("Connection log message missing compressed data");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up the org for this site
|
||||||
|
const [site] = await db
|
||||||
|
.select({ orgId: sites.orgId, orgSubnet: orgs.subnet })
|
||||||
|
.from(sites)
|
||||||
|
.innerJoin(orgs, eq(sites.orgId, orgs.orgId))
|
||||||
|
.where(eq(sites.siteId, newt.siteId));
|
||||||
|
|
||||||
|
if (!site) {
|
||||||
|
logger.warn(
|
||||||
|
`Connection log received but site ${newt.siteId} not found in database`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const orgId = site.orgId;
|
||||||
|
|
||||||
|
// Extract the CIDR suffix (e.g. "/16") from the org subnet so we can
|
||||||
|
// reconstruct the exact subnet string stored on each client record.
|
||||||
|
const cidrSuffix = site.orgSubnet?.includes("/")
|
||||||
|
? site.orgSubnet.substring(site.orgSubnet.indexOf("/"))
|
||||||
|
: null;
|
||||||
|
|
||||||
|
let sessions: ConnectionSessionData[];
|
||||||
|
try {
|
||||||
|
sessions = await decompressConnectionLog(message.data.compressed);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error("Failed to decompress connection log data:", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sessions.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(`Sessions: ${JSON.stringify(sessions)}`)
|
||||||
|
|
||||||
|
// Build a map from sourceAddr → { clientId, userId } by querying clients
|
||||||
|
// whose subnet field matches exactly. Client subnets are stored with the
|
||||||
|
// org's CIDR suffix (e.g. "100.90.128.5/16"), so we reconstruct that from
|
||||||
|
// each unique sourceAddr + the org's CIDR suffix and do a targeted IN query.
|
||||||
|
const ipToClient = new Map<string, { clientId: number; userId: string | null }>();
|
||||||
|
|
||||||
|
if (cidrSuffix) {
|
||||||
|
// Collect unique source addresses so we only query for what we need
|
||||||
|
const uniqueSourceAddrs = new Set<string>();
|
||||||
|
for (const session of sessions) {
|
||||||
|
if (session.sourceAddr) {
|
||||||
|
uniqueSourceAddrs.add(session.sourceAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uniqueSourceAddrs.size > 0) {
|
||||||
|
// Construct the exact subnet strings as stored in the DB
|
||||||
|
const subnetQueries = Array.from(uniqueSourceAddrs).map(
|
||||||
|
(addr) => {
|
||||||
|
// Strip port if present (e.g. "100.90.128.1:38004" → "100.90.128.1")
|
||||||
|
const ip = addr.includes(":") ? addr.split(":")[0] : addr;
|
||||||
|
return `${ip}${cidrSuffix}`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
logger.debug(`Subnet queries: ${JSON.stringify(subnetQueries)}`);
|
||||||
|
|
||||||
|
const matchedClients = await db
|
||||||
|
.select({
|
||||||
|
clientId: clients.clientId,
|
||||||
|
userId: clients.userId,
|
||||||
|
subnet: clients.subnet
|
||||||
|
})
|
||||||
|
.from(clients)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(clients.orgId, orgId),
|
||||||
|
inArray(clients.subnet, subnetQueries)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const c of matchedClients) {
|
||||||
|
const ip = c.subnet.split("/")[0];
|
||||||
|
logger.debug(`Client ${c.clientId} subnet ${c.subnet} matches ${ip}`);
|
||||||
|
ipToClient.set(ip, { clientId: c.clientId, userId: c.userId });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to DB records and add to the buffer
|
||||||
|
for (const session of sessions) {
|
||||||
|
// Validate required fields
|
||||||
|
if (
|
||||||
|
!session.sessionId ||
|
||||||
|
!session.resourceId ||
|
||||||
|
!session.sourceAddr ||
|
||||||
|
!session.destAddr ||
|
||||||
|
!session.protocol
|
||||||
|
) {
|
||||||
|
logger.debug(
|
||||||
|
`Skipping connection log session with missing required fields: ${JSON.stringify(session)}`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startedAt = toEpochSeconds(session.startedAt);
|
||||||
|
if (startedAt === null) {
|
||||||
|
logger.debug(
|
||||||
|
`Skipping connection log session with invalid startedAt: ${session.startedAt}`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match the source address to a client. The sourceAddr is the
|
||||||
|
// client's IP on the WireGuard network, which corresponds to the IP
|
||||||
|
// portion of the client's subnet CIDR (e.g. "100.90.128.5/24").
|
||||||
|
// Strip port if present (e.g. "100.90.128.1:38004" → "100.90.128.1")
|
||||||
|
const sourceIp = session.sourceAddr.includes(":") ? session.sourceAddr.split(":")[0] : session.sourceAddr;
|
||||||
|
const clientInfo = ipToClient.get(sourceIp) ?? null;
|
||||||
|
|
||||||
|
|
||||||
|
buffer.push({
|
||||||
|
sessionId: session.sessionId,
|
||||||
|
siteResourceId: session.resourceId,
|
||||||
|
orgId,
|
||||||
|
siteId: newt.siteId,
|
||||||
|
clientId: clientInfo?.clientId ?? null,
|
||||||
|
userId: clientInfo?.userId ?? null,
|
||||||
|
sourceAddr: session.sourceAddr,
|
||||||
|
destAddr: session.destAddr,
|
||||||
|
protocol: session.protocol,
|
||||||
|
startedAt,
|
||||||
|
endedAt: toEpochSeconds(session.endedAt),
|
||||||
|
bytesTx: session.bytesTx ?? null,
|
||||||
|
bytesRx: session.bytesRx ?? null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
`Buffered ${sessions.length} connection log session(s) from newt ${newt.newtId} (site ${newt.siteId})`
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the buffer has grown large enough, trigger an immediate flush
|
||||||
|
if (buffer.length >= MAX_BUFFERED_RECORDS) {
|
||||||
|
// Fire and forget — errors are handled inside flushConnectionLogToDb
|
||||||
|
flushConnectionLogToDb().catch((error) => {
|
||||||
|
logger.error(
|
||||||
|
"Unexpected error during size-triggered connection log flush:",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
1
server/private/routers/newt/index.ts
Normal file
1
server/private/routers/newt/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from "./handleConnectionLogMessage";
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import { userOrgs, users, roles, orgs } from "@server/db";
|
import { userOrgs, userOrgRoles, users, roles, orgs } from "@server/db";
|
||||||
import { eq, and, or } from "drizzle-orm";
|
import { eq, and, or } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
@@ -95,7 +95,14 @@ async function getOrgAdmins(orgId: string) {
|
|||||||
})
|
})
|
||||||
.from(userOrgs)
|
.from(userOrgs)
|
||||||
.innerJoin(users, eq(userOrgs.userId, users.userId))
|
.innerJoin(users, eq(userOrgs.userId, users.userId))
|
||||||
.leftJoin(roles, eq(userOrgs.roleId, roles.roleId))
|
.leftJoin(
|
||||||
|
userOrgRoles,
|
||||||
|
and(
|
||||||
|
eq(userOrgs.userId, userOrgRoles.userId),
|
||||||
|
eq(userOrgs.orgId, userOrgRoles.orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.leftJoin(roles, eq(userOrgRoles.roleId, roles.roleId))
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(userOrgs.orgId, orgId),
|
eq(userOrgs.orgId, orgId),
|
||||||
@@ -103,8 +110,11 @@ async function getOrgAdmins(orgId: string) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Filter to only include users with verified emails
|
// Dedupe by userId (user may have multiple roles)
|
||||||
const orgAdmins = admins.filter(
|
const byUserId = new Map(
|
||||||
|
admins.map((a) => [a.userId, a])
|
||||||
|
);
|
||||||
|
const orgAdmins = Array.from(byUserId.values()).filter(
|
||||||
(admin) => admin.email && admin.email.length > 0
|
(admin) => admin.email && admin.email.length > 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export async function createRemoteExitNode(
|
|||||||
|
|
||||||
const { remoteExitNodeId, secret } = parsedBody.data;
|
const { remoteExitNodeId, secret } = parsedBody.data;
|
||||||
|
|
||||||
if (req.user && !req.userOrgRoleId) {
|
if (req.user && (!req.userOrgRoleIds || req.userOrgRoleIds.length === 0)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import { db, siteProvisioningKeyOrg, siteProvisioningKeys } from "@server/db";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import moment from "moment";
|
||||||
|
import {
|
||||||
|
generateId,
|
||||||
|
generateIdFromEntropySize
|
||||||
|
} from "@server/auth/sessions/app";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { hashPassword } from "@server/auth/password";
|
||||||
|
import type { CreateSiteProvisioningKeyResponse } from "@server/routers/siteProvisioning/types";
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
orgId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
const bodySchema = z
|
||||||
|
.strictObject({
|
||||||
|
name: z.string().min(1).max(255),
|
||||||
|
maxBatchSize: z.union([
|
||||||
|
z.null(),
|
||||||
|
z.coerce.number().int().positive().max(1_000_000)
|
||||||
|
]),
|
||||||
|
validUntil: z.string().max(255).optional()
|
||||||
|
})
|
||||||
|
.superRefine((data, ctx) => {
|
||||||
|
const v = data.validUntil;
|
||||||
|
if (v == null || v.trim() === "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number.isNaN(Date.parse(v))) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: "custom",
|
||||||
|
message: "Invalid validUntil",
|
||||||
|
path: ["validUntil"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CreateSiteProvisioningKeyBody = z.infer<typeof bodySchema>;
|
||||||
|
|
||||||
|
export async function createSiteProvisioningKey(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedBody = bodySchema.safeParse(req.body);
|
||||||
|
if (!parsedBody.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedBody.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId } = parsedParams.data;
|
||||||
|
const { name, maxBatchSize } = parsedBody.data;
|
||||||
|
const vuRaw = parsedBody.data.validUntil;
|
||||||
|
const validUntil =
|
||||||
|
vuRaw == null || vuRaw.trim() === ""
|
||||||
|
? null
|
||||||
|
: new Date(Date.parse(vuRaw)).toISOString();
|
||||||
|
|
||||||
|
const siteProvisioningKeyId = `spk-${generateId(15)}`;
|
||||||
|
const siteProvisioningKey = generateIdFromEntropySize(25);
|
||||||
|
const siteProvisioningKeyHash = await hashPassword(siteProvisioningKey);
|
||||||
|
const lastChars = siteProvisioningKey.slice(-4);
|
||||||
|
const createdAt = moment().toISOString();
|
||||||
|
const provisioningKey = `${siteProvisioningKeyId}.${siteProvisioningKey}`;
|
||||||
|
|
||||||
|
await db.transaction(async (trx) => {
|
||||||
|
await trx.insert(siteProvisioningKeys).values({
|
||||||
|
siteProvisioningKeyId,
|
||||||
|
name,
|
||||||
|
siteProvisioningKeyHash,
|
||||||
|
createdAt,
|
||||||
|
lastChars,
|
||||||
|
lastUsed: null,
|
||||||
|
maxBatchSize,
|
||||||
|
numUsed: 0,
|
||||||
|
validUntil
|
||||||
|
});
|
||||||
|
|
||||||
|
await trx.insert(siteProvisioningKeyOrg).values({
|
||||||
|
siteProvisioningKeyId,
|
||||||
|
orgId
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
return response<CreateSiteProvisioningKeyResponse>(res, {
|
||||||
|
data: {
|
||||||
|
siteProvisioningKeyId,
|
||||||
|
orgId,
|
||||||
|
name,
|
||||||
|
siteProvisioningKey: provisioningKey,
|
||||||
|
lastChars,
|
||||||
|
createdAt,
|
||||||
|
lastUsed: null,
|
||||||
|
maxBatchSize,
|
||||||
|
numUsed: 0,
|
||||||
|
validUntil
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Site provisioning key created",
|
||||||
|
status: HttpCode.CREATED
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
logger.error(e);
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to create site provisioning key"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import {
|
||||||
|
db,
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
siteProvisioningKeys
|
||||||
|
} from "@server/db";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
siteProvisioningKeyId: z.string().nonempty(),
|
||||||
|
orgId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function deleteSiteProvisioningKey(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { siteProvisioningKeyId, orgId } = parsedParams.data;
|
||||||
|
|
||||||
|
const [row] = await db
|
||||||
|
.select()
|
||||||
|
.from(siteProvisioningKeys)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.innerJoin(
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
and(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId
|
||||||
|
),
|
||||||
|
eq(siteProvisioningKeyOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
`Site provisioning key with ID ${siteProvisioningKeyId} not found`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.transaction(async (trx) => {
|
||||||
|
await trx
|
||||||
|
.delete(siteProvisioningKeyOrg)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
),
|
||||||
|
eq(siteProvisioningKeyOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const siteProvisioningKeyOrgs = await trx
|
||||||
|
.select()
|
||||||
|
.from(siteProvisioningKeyOrg)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (siteProvisioningKeyOrgs.length === 0) {
|
||||||
|
await trx
|
||||||
|
.delete(siteProvisioningKeys)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response(res, {
|
||||||
|
data: null,
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Site provisioning key deleted successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
17
server/private/routers/siteProvisioning/index.ts
Normal file
17
server/private/routers/siteProvisioning/index.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from "./createSiteProvisioningKey";
|
||||||
|
export * from "./listSiteProvisioningKeys";
|
||||||
|
export * from "./deleteSiteProvisioningKey";
|
||||||
|
export * from "./updateSiteProvisioningKey";
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
db,
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
siteProvisioningKeys
|
||||||
|
} from "@server/db";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import { NextFunction, Request, Response } from "express";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import type { ListSiteProvisioningKeysResponse } from "@server/routers/siteProvisioning/types";
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
orgId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
const querySchema = z.object({
|
||||||
|
limit: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("1000")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().positive()),
|
||||||
|
offset: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.default("0")
|
||||||
|
.transform(Number)
|
||||||
|
.pipe(z.int().nonnegative())
|
||||||
|
});
|
||||||
|
|
||||||
|
function querySiteProvisioningKeys(orgId: string) {
|
||||||
|
return db
|
||||||
|
.select({
|
||||||
|
siteProvisioningKeyId:
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
orgId: siteProvisioningKeyOrg.orgId,
|
||||||
|
lastChars: siteProvisioningKeys.lastChars,
|
||||||
|
createdAt: siteProvisioningKeys.createdAt,
|
||||||
|
name: siteProvisioningKeys.name,
|
||||||
|
lastUsed: siteProvisioningKeys.lastUsed,
|
||||||
|
maxBatchSize: siteProvisioningKeys.maxBatchSize,
|
||||||
|
numUsed: siteProvisioningKeys.numUsed,
|
||||||
|
validUntil: siteProvisioningKeys.validUntil
|
||||||
|
})
|
||||||
|
.from(siteProvisioningKeyOrg)
|
||||||
|
.innerJoin(
|
||||||
|
siteProvisioningKeys,
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.where(eq(siteProvisioningKeyOrg.orgId, orgId));
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function listSiteProvisioningKeys(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedQuery = querySchema.safeParse(req.query);
|
||||||
|
if (!parsedQuery.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedQuery.error)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId } = parsedParams.data;
|
||||||
|
const { limit, offset } = parsedQuery.data;
|
||||||
|
|
||||||
|
const siteProvisioningKeysList = await querySiteProvisioningKeys(orgId)
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset);
|
||||||
|
|
||||||
|
return response<ListSiteProvisioningKeysResponse>(res, {
|
||||||
|
data: {
|
||||||
|
siteProvisioningKeys: siteProvisioningKeysList,
|
||||||
|
pagination: {
|
||||||
|
total: siteProvisioningKeysList.length,
|
||||||
|
limit,
|
||||||
|
offset
|
||||||
|
}
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Site provisioning keys retrieved successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import {
|
||||||
|
db,
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
siteProvisioningKeys
|
||||||
|
} from "@server/db";
|
||||||
|
import { and, eq } from "drizzle-orm";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import type { UpdateSiteProvisioningKeyResponse } from "@server/routers/siteProvisioning/types";
|
||||||
|
|
||||||
|
const paramsSchema = z.object({
|
||||||
|
siteProvisioningKeyId: z.string().nonempty(),
|
||||||
|
orgId: z.string().nonempty()
|
||||||
|
});
|
||||||
|
|
||||||
|
const bodySchema = z
|
||||||
|
.strictObject({
|
||||||
|
maxBatchSize: z
|
||||||
|
.union([
|
||||||
|
z.null(),
|
||||||
|
z.coerce.number().int().positive().max(1_000_000)
|
||||||
|
])
|
||||||
|
.optional(),
|
||||||
|
validUntil: z.string().max(255).optional()
|
||||||
|
})
|
||||||
|
.superRefine((data, ctx) => {
|
||||||
|
if (
|
||||||
|
data.maxBatchSize === undefined &&
|
||||||
|
data.validUntil === undefined
|
||||||
|
) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: "custom",
|
||||||
|
message: "Provide maxBatchSize and/or validUntil",
|
||||||
|
path: ["maxBatchSize"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const v = data.validUntil;
|
||||||
|
if (v == null || v.trim() === "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Number.isNaN(Date.parse(v))) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: "custom",
|
||||||
|
message: "Invalid validUntil",
|
||||||
|
path: ["validUntil"]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export type UpdateSiteProvisioningKeyBody = z.infer<typeof bodySchema>;
|
||||||
|
|
||||||
|
export async function updateSiteProvisioningKey(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = paramsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedBody = bodySchema.safeParse(req.body);
|
||||||
|
if (!parsedBody.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedBody.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { siteProvisioningKeyId, orgId } = parsedParams.data;
|
||||||
|
const body = parsedBody.data;
|
||||||
|
|
||||||
|
const [row] = await db
|
||||||
|
.select()
|
||||||
|
.from(siteProvisioningKeys)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.innerJoin(
|
||||||
|
siteProvisioningKeyOrg,
|
||||||
|
and(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyOrg.siteProvisioningKeyId
|
||||||
|
),
|
||||||
|
eq(siteProvisioningKeyOrg.orgId, orgId)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
`Site provisioning key with ID ${siteProvisioningKeyId} not found`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const setValues: {
|
||||||
|
maxBatchSize?: number | null;
|
||||||
|
validUntil?: string | null;
|
||||||
|
} = {};
|
||||||
|
if (body.maxBatchSize !== undefined) {
|
||||||
|
setValues.maxBatchSize = body.maxBatchSize;
|
||||||
|
}
|
||||||
|
if (body.validUntil !== undefined) {
|
||||||
|
setValues.validUntil =
|
||||||
|
body.validUntil.trim() === ""
|
||||||
|
? null
|
||||||
|
: new Date(Date.parse(body.validUntil)).toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
await db
|
||||||
|
.update(siteProvisioningKeys)
|
||||||
|
.set(setValues)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const [updated] = await db
|
||||||
|
.select({
|
||||||
|
siteProvisioningKeyId:
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
name: siteProvisioningKeys.name,
|
||||||
|
lastChars: siteProvisioningKeys.lastChars,
|
||||||
|
createdAt: siteProvisioningKeys.createdAt,
|
||||||
|
lastUsed: siteProvisioningKeys.lastUsed,
|
||||||
|
maxBatchSize: siteProvisioningKeys.maxBatchSize,
|
||||||
|
numUsed: siteProvisioningKeys.numUsed,
|
||||||
|
validUntil: siteProvisioningKeys.validUntil
|
||||||
|
})
|
||||||
|
.from(siteProvisioningKeys)
|
||||||
|
.where(
|
||||||
|
eq(
|
||||||
|
siteProvisioningKeys.siteProvisioningKeyId,
|
||||||
|
siteProvisioningKeyId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!updated) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to load updated site provisioning key"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response<UpdateSiteProvisioningKeyResponse>(res, {
|
||||||
|
data: {
|
||||||
|
...updated,
|
||||||
|
orgId
|
||||||
|
},
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Site provisioning key updated successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
sites,
|
sites,
|
||||||
userOrgs
|
userOrgs
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
|
import { logAccessAudit } from "#private/lib/logAccessAudit";
|
||||||
import { isLicensedOrSubscribed } from "#private/lib/isLicencedOrSubscribed";
|
import { isLicensedOrSubscribed } from "#private/lib/isLicencedOrSubscribed";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
@@ -31,7 +32,7 @@ import HttpCode from "@server/types/HttpCode";
|
|||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { eq, or, and } from "drizzle-orm";
|
import { and, eq, inArray, or } from "drizzle-orm";
|
||||||
import { canUserAccessSiteResource } from "@server/auth/canUserAccessSiteResource";
|
import { canUserAccessSiteResource } from "@server/auth/canUserAccessSiteResource";
|
||||||
import { signPublicKey, getOrgCAKeys } from "@server/lib/sshCA";
|
import { signPublicKey, getOrgCAKeys } from "@server/lib/sshCA";
|
||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
@@ -125,7 +126,7 @@ export async function signSshKey(
|
|||||||
resource: resourceQueryString
|
resource: resourceQueryString
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
const userId = req.user?.userId;
|
const userId = req.user?.userId;
|
||||||
const roleId = req.userOrgRoleId!;
|
const roleIds = req.userOrgRoleIds ?? [];
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
return next(
|
return next(
|
||||||
@@ -133,6 +134,15 @@ export async function signSshKey(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (roleIds.length === 0) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"User has no role in organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const [userOrg] = await db
|
const [userOrg] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(userOrgs)
|
.from(userOrgs)
|
||||||
@@ -339,7 +349,7 @@ export async function signSshKey(
|
|||||||
const hasAccess = await canUserAccessSiteResource({
|
const hasAccess = await canUserAccessSiteResource({
|
||||||
userId: userId,
|
userId: userId,
|
||||||
resourceId: resource.siteResourceId,
|
resourceId: resource.siteResourceId,
|
||||||
roleId: roleId
|
roleIds
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
@@ -351,28 +361,39 @@ export async function signSshKey(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [roleRow] = await db
|
const roleRows = await db
|
||||||
.select()
|
.select()
|
||||||
.from(roles)
|
.from(roles)
|
||||||
.where(eq(roles.roleId, roleId))
|
.where(inArray(roles.roleId, roleIds));
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
let parsedSudoCommands: string[] = [];
|
const parsedSudoCommands: string[] = [];
|
||||||
let parsedGroups: string[] = [];
|
const parsedGroupsSet = new Set<string>();
|
||||||
try {
|
let homedir: boolean | null = null;
|
||||||
parsedSudoCommands = JSON.parse(roleRow?.sshSudoCommands ?? "[]");
|
const sudoModeOrder = { none: 0, commands: 1, all: 2 };
|
||||||
if (!Array.isArray(parsedSudoCommands)) parsedSudoCommands = [];
|
let sudoMode: "none" | "commands" | "all" = "none";
|
||||||
} catch {
|
for (const roleRow of roleRows) {
|
||||||
parsedSudoCommands = [];
|
try {
|
||||||
|
const cmds = JSON.parse(roleRow?.sshSudoCommands ?? "[]");
|
||||||
|
if (Array.isArray(cmds)) parsedSudoCommands.push(...cmds);
|
||||||
|
} catch {
|
||||||
|
// skip
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const grps = JSON.parse(roleRow?.sshUnixGroups ?? "[]");
|
||||||
|
if (Array.isArray(grps)) grps.forEach((g: string) => parsedGroupsSet.add(g));
|
||||||
|
} catch {
|
||||||
|
// skip
|
||||||
|
}
|
||||||
|
if (roleRow?.sshCreateHomeDir === true) homedir = true;
|
||||||
|
const m = roleRow?.sshSudoMode ?? "none";
|
||||||
|
if (sudoModeOrder[m as keyof typeof sudoModeOrder] > sudoModeOrder[sudoMode]) {
|
||||||
|
sudoMode = m as "none" | "commands" | "all";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try {
|
const parsedGroups = Array.from(parsedGroupsSet);
|
||||||
parsedGroups = JSON.parse(roleRow?.sshUnixGroups ?? "[]");
|
if (homedir === null && roleRows.length > 0) {
|
||||||
if (!Array.isArray(parsedGroups)) parsedGroups = [];
|
homedir = roleRows[0].sshCreateHomeDir ?? null;
|
||||||
} catch {
|
|
||||||
parsedGroups = [];
|
|
||||||
}
|
}
|
||||||
const homedir = roleRow?.sshCreateHomeDir ?? null;
|
|
||||||
const sudoMode = roleRow?.sshSudoMode ?? "none";
|
|
||||||
|
|
||||||
// get the site
|
// get the site
|
||||||
const [newt] = await db
|
const [newt] = await db
|
||||||
@@ -463,6 +484,24 @@ export async function signSshKey(
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await logAccessAudit({
|
||||||
|
action: true,
|
||||||
|
type: "ssh",
|
||||||
|
orgId: orgId,
|
||||||
|
resourceId: resource.siteResourceId,
|
||||||
|
user: req.user
|
||||||
|
? { username: req.user.username ?? "", userId: req.user.userId }
|
||||||
|
: undefined,
|
||||||
|
metadata: {
|
||||||
|
resourceName: resource.name,
|
||||||
|
siteId: resource.siteId,
|
||||||
|
sshUsername: usernameToUse,
|
||||||
|
sshHost: sshHost
|
||||||
|
},
|
||||||
|
userAgent: req.headers["user-agent"],
|
||||||
|
requestIp: req.ip
|
||||||
|
});
|
||||||
|
|
||||||
return response<SignSshKeyResponse>(res, {
|
return response<SignSshKeyResponse>(res, {
|
||||||
data: {
|
data: {
|
||||||
certificate: cert.certificate,
|
certificate: cert.certificate,
|
||||||
|
|||||||
@@ -1,14 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { clients, db, UserOrg } from "@server/db";
|
import stoi from "@server/lib/stoi";
|
||||||
import { userOrgs, roles } from "@server/db";
|
import { clients, db } from "@server/db";
|
||||||
|
import { userOrgRoles, userOrgs, roles } from "@server/db";
|
||||||
import { eq, and } from "drizzle-orm";
|
import { eq, and } from "drizzle-orm";
|
||||||
import response from "@server/lib/response";
|
import response from "@server/lib/response";
|
||||||
import HttpCode from "@server/types/HttpCode";
|
import HttpCode from "@server/types/HttpCode";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import stoi from "@server/lib/stoi";
|
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
||||||
|
|
||||||
@@ -17,11 +30,9 @@ const addUserRoleParamsSchema = z.strictObject({
|
|||||||
roleId: z.string().transform(stoi).pipe(z.number())
|
roleId: z.string().transform(stoi).pipe(z.number())
|
||||||
});
|
});
|
||||||
|
|
||||||
export type AddUserRoleResponse = z.infer<typeof addUserRoleParamsSchema>;
|
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "post",
|
method: "post",
|
||||||
path: "/role/{roleId}/add/{userId}",
|
path: "/user/{userId}/add-role/{roleId}",
|
||||||
description: "Add a role to a user.",
|
description: "Add a role to a user.",
|
||||||
tags: [OpenAPITags.Role, OpenAPITags.User],
|
tags: [OpenAPITags.Role, OpenAPITags.User],
|
||||||
request: {
|
request: {
|
||||||
@@ -111,20 +122,23 @@ export async function addUserRole(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let newUserRole: UserOrg | null = null;
|
let newUserRole: { userId: string; orgId: string; roleId: number } | null =
|
||||||
|
null;
|
||||||
await db.transaction(async (trx) => {
|
await db.transaction(async (trx) => {
|
||||||
[newUserRole] = await trx
|
const inserted = await trx
|
||||||
.update(userOrgs)
|
.insert(userOrgRoles)
|
||||||
.set({ roleId })
|
.values({
|
||||||
.where(
|
userId,
|
||||||
and(
|
orgId: role.orgId,
|
||||||
eq(userOrgs.userId, userId),
|
roleId
|
||||||
eq(userOrgs.orgId, role.orgId)
|
})
|
||||||
)
|
.onConflictDoNothing()
|
||||||
)
|
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
// get the client associated with this user in this org
|
if (inserted.length > 0) {
|
||||||
|
newUserRole = inserted[0];
|
||||||
|
}
|
||||||
|
|
||||||
const orgClients = await trx
|
const orgClients = await trx
|
||||||
.select()
|
.select()
|
||||||
.from(clients)
|
.from(clients)
|
||||||
@@ -133,17 +147,15 @@ export async function addUserRole(
|
|||||||
eq(clients.userId, userId),
|
eq(clients.userId, userId),
|
||||||
eq(clients.orgId, role.orgId)
|
eq(clients.orgId, role.orgId)
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
.limit(1);
|
|
||||||
|
|
||||||
for (const orgClient of orgClients) {
|
for (const orgClient of orgClients) {
|
||||||
// we just changed the user's role, so we need to rebuild client associations and what they have access to
|
|
||||||
await rebuildClientAssociationsFromClient(orgClient, trx);
|
await rebuildClientAssociationsFromClient(orgClient, trx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return response(res, {
|
return response(res, {
|
||||||
data: newUserRole,
|
data: newUserRole ?? { userId, orgId: role.orgId, roleId },
|
||||||
success: true,
|
success: true,
|
||||||
error: false,
|
error: false,
|
||||||
message: "Role added to user successfully",
|
message: "Role added to user successfully",
|
||||||
16
server/private/routers/user/index.ts
Normal file
16
server/private/routers/user/index.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export * from "./addUserRole";
|
||||||
|
export * from "./removeUserRole";
|
||||||
|
export * from "./setUserOrgRoles";
|
||||||
171
server/private/routers/user/removeUserRole.ts
Normal file
171
server/private/routers/user/removeUserRole.ts
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import stoi from "@server/lib/stoi";
|
||||||
|
import { db } from "@server/db";
|
||||||
|
import { userOrgRoles, userOrgs, roles, clients } from "@server/db";
|
||||||
|
import { eq, and } from "drizzle-orm";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
||||||
|
|
||||||
|
const removeUserRoleParamsSchema = z.strictObject({
|
||||||
|
userId: z.string(),
|
||||||
|
roleId: z.string().transform(stoi).pipe(z.number())
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.registerPath({
|
||||||
|
method: "delete",
|
||||||
|
path: "/user/{userId}/remove-role/{roleId}",
|
||||||
|
description:
|
||||||
|
"Remove a role from a user. User must have at least one role left in the org.",
|
||||||
|
tags: [OpenAPITags.Role, OpenAPITags.User],
|
||||||
|
request: {
|
||||||
|
params: removeUserRoleParamsSchema
|
||||||
|
},
|
||||||
|
responses: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function removeUserRole(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = removeUserRoleParamsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { userId, roleId } = parsedParams.data;
|
||||||
|
|
||||||
|
if (req.user && !req.userOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"You do not have access to this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [role] = await db
|
||||||
|
.select()
|
||||||
|
.from(roles)
|
||||||
|
.where(eq(roles.roleId, roleId))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!role) {
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.BAD_REQUEST, "Invalid role ID")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [existingUser] = await db
|
||||||
|
.select()
|
||||||
|
.from(userOrgs)
|
||||||
|
.where(
|
||||||
|
and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, role.orgId))
|
||||||
|
)
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!existingUser) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
"User not found or does not belong to the specified organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingUser.isOwner) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"Cannot change the roles of the owner of the organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const remainingRoles = await db
|
||||||
|
.select({ roleId: userOrgRoles.roleId })
|
||||||
|
.from(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, role.orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (remainingRoles.length <= 1) {
|
||||||
|
const hasThisRole = remainingRoles.some((r) => r.roleId === roleId);
|
||||||
|
if (hasThisRole) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"User must have at least one role in the organization. Remove the last role is not allowed."
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.transaction(async (trx) => {
|
||||||
|
await trx
|
||||||
|
.delete(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, role.orgId),
|
||||||
|
eq(userOrgRoles.roleId, roleId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const orgClients = await trx
|
||||||
|
.select()
|
||||||
|
.from(clients)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(clients.userId, userId),
|
||||||
|
eq(clients.orgId, role.orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const orgClient of orgClients) {
|
||||||
|
await rebuildClientAssociationsFromClient(orgClient, trx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response(res, {
|
||||||
|
data: { userId, orgId: role.orgId, roleId },
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "Role removed from user successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
163
server/private/routers/user/setUserOrgRoles.ts
Normal file
163
server/private/routers/user/setUserOrgRoles.ts
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of a proprietary work.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 Fossorial, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is licensed under the Fossorial Commercial License.
|
||||||
|
* You may not use this file except in compliance with the License.
|
||||||
|
* Unauthorized use, copying, modification, or distribution is strictly prohibited.
|
||||||
|
*
|
||||||
|
* This file is not licensed under the AGPLv3.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Request, Response, NextFunction } from "express";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { clients, db } from "@server/db";
|
||||||
|
import { userOrgRoles, userOrgs, roles } from "@server/db";
|
||||||
|
import { eq, and, inArray } from "drizzle-orm";
|
||||||
|
import response from "@server/lib/response";
|
||||||
|
import HttpCode from "@server/types/HttpCode";
|
||||||
|
import createHttpError from "http-errors";
|
||||||
|
import logger from "@server/logger";
|
||||||
|
import { fromError } from "zod-validation-error";
|
||||||
|
import { rebuildClientAssociationsFromClient } from "@server/lib/rebuildClientAssociations";
|
||||||
|
|
||||||
|
const setUserOrgRolesParamsSchema = z.strictObject({
|
||||||
|
orgId: z.string(),
|
||||||
|
userId: z.string()
|
||||||
|
});
|
||||||
|
|
||||||
|
const setUserOrgRolesBodySchema = z.strictObject({
|
||||||
|
roleIds: z.array(z.int().positive()).min(1)
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function setUserOrgRoles(
|
||||||
|
req: Request,
|
||||||
|
res: Response,
|
||||||
|
next: NextFunction
|
||||||
|
): Promise<any> {
|
||||||
|
try {
|
||||||
|
const parsedParams = setUserOrgRolesParamsSchema.safeParse(req.params);
|
||||||
|
if (!parsedParams.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedParams.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedBody = setUserOrgRolesBodySchema.safeParse(req.body);
|
||||||
|
if (!parsedBody.success) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
fromError(parsedBody.error).toString()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { orgId, userId } = parsedParams.data;
|
||||||
|
const { roleIds } = parsedBody.data;
|
||||||
|
|
||||||
|
if (req.user && !req.userOrg) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"You do not have access to this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uniqueRoleIds = [...new Set(roleIds)];
|
||||||
|
|
||||||
|
const [existingUser] = await db
|
||||||
|
.select()
|
||||||
|
.from(userOrgs)
|
||||||
|
.where(and(eq(userOrgs.userId, userId), eq(userOrgs.orgId, orgId)))
|
||||||
|
.limit(1);
|
||||||
|
|
||||||
|
if (!existingUser) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.NOT_FOUND,
|
||||||
|
"User not found in this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (existingUser.isOwner) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.FORBIDDEN,
|
||||||
|
"Cannot change the roles of the owner of the organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const orgRoles = await db
|
||||||
|
.select({ roleId: roles.roleId })
|
||||||
|
.from(roles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(roles.orgId, orgId),
|
||||||
|
inArray(roles.roleId, uniqueRoleIds)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (orgRoles.length !== uniqueRoleIds.length) {
|
||||||
|
return next(
|
||||||
|
createHttpError(
|
||||||
|
HttpCode.BAD_REQUEST,
|
||||||
|
"One or more role IDs are invalid for this organization"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await db.transaction(async (trx) => {
|
||||||
|
await trx
|
||||||
|
.delete(userOrgRoles)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId),
|
||||||
|
eq(userOrgRoles.orgId, orgId)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (uniqueRoleIds.length > 0) {
|
||||||
|
await trx.insert(userOrgRoles).values(
|
||||||
|
uniqueRoleIds.map((roleId) => ({
|
||||||
|
userId,
|
||||||
|
orgId,
|
||||||
|
roleId
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const orgClients = await trx
|
||||||
|
.select()
|
||||||
|
.from(clients)
|
||||||
|
.where(
|
||||||
|
and(eq(clients.userId, userId), eq(clients.orgId, orgId))
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const orgClient of orgClients) {
|
||||||
|
await rebuildClientAssociationsFromClient(orgClient, trx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return response(res, {
|
||||||
|
data: { userId, orgId, roleIds: uniqueRoleIds },
|
||||||
|
success: true,
|
||||||
|
error: false,
|
||||||
|
message: "User roles set successfully",
|
||||||
|
status: HttpCode.OK
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
return next(
|
||||||
|
createHttpError(HttpCode.INTERNAL_SERVER_ERROR, "An error occurred")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,10 +18,12 @@ import {
|
|||||||
} from "#private/routers/remoteExitNode";
|
} from "#private/routers/remoteExitNode";
|
||||||
import { MessageHandler } from "@server/routers/ws";
|
import { MessageHandler } from "@server/routers/ws";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import { handleConnectionLogMessage } from "#dynamic/routers/newt";
|
||||||
|
|
||||||
export const messageHandlers: Record<string, MessageHandler> = {
|
export const messageHandlers: Record<string, MessageHandler> = {
|
||||||
"remoteExitNode/register": handleRemoteExitNodeRegisterMessage,
|
"remoteExitNode/register": handleRemoteExitNodeRegisterMessage,
|
||||||
"remoteExitNode/ping": handleRemoteExitNodePingMessage
|
"remoteExitNode/ping": handleRemoteExitNodePingMessage,
|
||||||
|
"newt/access-log": handleConnectionLogMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (build != "saas") {
|
if (build != "saas") {
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export async function listAccessTokens(
|
|||||||
.where(
|
.where(
|
||||||
or(
|
or(
|
||||||
eq(userResources.userId, req.user!.userId),
|
eq(userResources.userId, req.user!.userId),
|
||||||
eq(roleResources.roleId, req.userOrgRoleId!)
|
inArray(roleResources.roleId, req.userOrgRoleIds!)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -91,3 +91,50 @@ export type QueryAccessAuditLogResponse = {
|
|||||||
locations: string[];
|
locations: string[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type QueryConnectionAuditLogResponse = {
|
||||||
|
log: {
|
||||||
|
sessionId: string;
|
||||||
|
siteResourceId: number | null;
|
||||||
|
orgId: string | null;
|
||||||
|
siteId: number | null;
|
||||||
|
clientId: number | null;
|
||||||
|
userId: string | null;
|
||||||
|
sourceAddr: string;
|
||||||
|
destAddr: string;
|
||||||
|
protocol: string;
|
||||||
|
startedAt: number;
|
||||||
|
endedAt: number | null;
|
||||||
|
bytesTx: number | null;
|
||||||
|
bytesRx: number | null;
|
||||||
|
resourceName: string | null;
|
||||||
|
resourceNiceId: string | null;
|
||||||
|
siteName: string | null;
|
||||||
|
siteNiceId: string | null;
|
||||||
|
clientName: string | null;
|
||||||
|
clientNiceId: string | null;
|
||||||
|
clientType: string | null;
|
||||||
|
userEmail: string | null;
|
||||||
|
}[];
|
||||||
|
pagination: {
|
||||||
|
total: number;
|
||||||
|
limit: number;
|
||||||
|
offset: number;
|
||||||
|
};
|
||||||
|
filterAttributes: {
|
||||||
|
protocols: string[];
|
||||||
|
destAddrs: string[];
|
||||||
|
clients: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
resources: {
|
||||||
|
id: number;
|
||||||
|
name: string | null;
|
||||||
|
}[];
|
||||||
|
users: {
|
||||||
|
id: string;
|
||||||
|
email: string | null;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import {
|
|||||||
getResourceByDomain,
|
getResourceByDomain,
|
||||||
getResourceRules,
|
getResourceRules,
|
||||||
getRoleResourceAccess,
|
getRoleResourceAccess,
|
||||||
getUserOrgRole,
|
|
||||||
getUserResourceAccess,
|
getUserResourceAccess,
|
||||||
getOrgLoginPage,
|
getOrgLoginPage,
|
||||||
getUserSessionWithUser
|
getUserSessionWithUser
|
||||||
} from "@server/db/queries/verifySessionQueries";
|
} from "@server/db/queries/verifySessionQueries";
|
||||||
|
import { getUserOrgRoles } from "@server/lib/userOrgRoles";
|
||||||
import {
|
import {
|
||||||
LoginPage,
|
LoginPage,
|
||||||
Org,
|
Org,
|
||||||
@@ -30,7 +30,6 @@ import { z } from "zod";
|
|||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { getCountryCodeForIp } from "@server/lib/geoip";
|
import { getCountryCodeForIp } from "@server/lib/geoip";
|
||||||
import { getAsnForIp } from "@server/lib/asn";
|
import { getAsnForIp } from "@server/lib/asn";
|
||||||
import { getOrgTierData } from "#dynamic/lib/billing";
|
|
||||||
import { verifyPassword } from "@server/auth/password";
|
import { verifyPassword } from "@server/auth/password";
|
||||||
import {
|
import {
|
||||||
checkOrgAccessPolicy,
|
checkOrgAccessPolicy,
|
||||||
@@ -797,7 +796,8 @@ async function notAllowed(
|
|||||||
) {
|
) {
|
||||||
let loginPage: LoginPage | null = null;
|
let loginPage: LoginPage | null = null;
|
||||||
if (orgId) {
|
if (orgId) {
|
||||||
const subscribed = await isSubscribed( // this is fine because the org login page is only a saas feature
|
const subscribed = await isSubscribed(
|
||||||
|
// this is fine because the org login page is only a saas feature
|
||||||
orgId,
|
orgId,
|
||||||
tierMatrix.loginPageDomain
|
tierMatrix.loginPageDomain
|
||||||
);
|
);
|
||||||
@@ -854,7 +854,10 @@ async function headerAuthChallenged(
|
|||||||
) {
|
) {
|
||||||
let loginPage: LoginPage | null = null;
|
let loginPage: LoginPage | null = null;
|
||||||
if (orgId) {
|
if (orgId) {
|
||||||
const subscribed = await isSubscribed(orgId, tierMatrix.loginPageDomain); // this is fine because the org login page is only a saas feature
|
const subscribed = await isSubscribed(
|
||||||
|
orgId,
|
||||||
|
tierMatrix.loginPageDomain
|
||||||
|
); // this is fine because the org login page is only a saas feature
|
||||||
if (subscribed) {
|
if (subscribed) {
|
||||||
loginPage = await getOrgLoginPage(orgId);
|
loginPage = await getOrgLoginPage(orgId);
|
||||||
}
|
}
|
||||||
@@ -916,9 +919,9 @@ async function isUserAllowedToAccessResource(
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const userOrgRole = await getUserOrgRole(user.userId, resource.orgId);
|
const userOrgRoles = await getUserOrgRoles(user.userId, resource.orgId);
|
||||||
|
|
||||||
if (!userOrgRole) {
|
if (!userOrgRoles.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -936,15 +939,14 @@ async function isUserAllowedToAccessResource(
|
|||||||
|
|
||||||
const roleResourceAccess = await getRoleResourceAccess(
|
const roleResourceAccess = await getRoleResourceAccess(
|
||||||
resource.resourceId,
|
resource.resourceId,
|
||||||
userOrgRole.roleId
|
userOrgRoles.map((r) => r.roleId)
|
||||||
);
|
);
|
||||||
|
if (roleResourceAccess && roleResourceAccess.length > 0) {
|
||||||
if (roleResourceAccess) {
|
|
||||||
return {
|
return {
|
||||||
username: user.username,
|
username: user.username,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
role: userOrgRole.roleName
|
role: userOrgRoles.map((r) => r.roleName).join(", ")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,7 +960,7 @@ async function isUserAllowedToAccessResource(
|
|||||||
username: user.username,
|
username: user.username,
|
||||||
email: user.email,
|
email: user.email,
|
||||||
name: user.name,
|
name: user.name,
|
||||||
role: userOrgRole.roleName
|
role: userOrgRoles.map((r) => r.roleName).join(", ")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export async function createClient(
|
|||||||
|
|
||||||
const { orgId } = parsedParams.data;
|
const { orgId } = parsedParams.data;
|
||||||
|
|
||||||
if (req.user && !req.userOrgRoleId) {
|
if (req.user && (!req.userOrgRoleIds || req.userOrgRoleIds.length === 0)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
||||||
);
|
);
|
||||||
@@ -234,7 +234,7 @@ export async function createClient(
|
|||||||
clientId: newClient.clientId
|
clientId: newClient.clientId
|
||||||
});
|
});
|
||||||
|
|
||||||
if (req.user && req.userOrgRoleId != adminRole.roleId) {
|
if (req.user && !req.userOrgRoleIds?.includes(adminRole.roleId)) {
|
||||||
// make sure the user can access the client
|
// make sure the user can access the client
|
||||||
trx.insert(userClients).values({
|
trx.insert(userClients).values({
|
||||||
userId: req.user.userId,
|
userId: req.user.userId,
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ export async function listClients(
|
|||||||
.where(
|
.where(
|
||||||
or(
|
or(
|
||||||
eq(userClients.userId, req.user!.userId),
|
eq(userClients.userId, req.user!.userId),
|
||||||
eq(roleClients.roleId, req.userOrgRoleId!)
|
inArray(roleClients.roleId, req.userOrgRoleIds!)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ export async function listUserDevices(
|
|||||||
.where(
|
.where(
|
||||||
or(
|
or(
|
||||||
eq(userClients.userId, req.user!.userId),
|
eq(userClients.userId, req.user!.userId),
|
||||||
eq(roleClients.roleId, req.userOrgRoleId!)
|
inArray(roleClients.roleId, req.userOrgRoleIds!)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,15 +1,54 @@
|
|||||||
import { sendToClient } from "#dynamic/routers/ws";
|
import { sendToClient } from "#dynamic/routers/ws";
|
||||||
import { db, olms, Transaction } from "@server/db";
|
import { db, newts, olms } from "@server/db";
|
||||||
|
import {
|
||||||
|
Alias,
|
||||||
|
convertSubnetProxyTargetsV2ToV1,
|
||||||
|
SubnetProxyTarget,
|
||||||
|
SubnetProxyTargetV2
|
||||||
|
} from "@server/lib/ip";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
import { Alias, SubnetProxyTarget } from "@server/lib/ip";
|
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
import semver from "semver";
|
||||||
|
|
||||||
|
const NEWT_V2_TARGETS_VERSION = ">=1.10.3";
|
||||||
|
|
||||||
|
export async function convertTargetsIfNessicary(
|
||||||
|
newtId: string,
|
||||||
|
targets: SubnetProxyTarget[] | SubnetProxyTargetV2[]
|
||||||
|
) {
|
||||||
|
// get the newt
|
||||||
|
const [newt] = await db
|
||||||
|
.select()
|
||||||
|
.from(newts)
|
||||||
|
.where(eq(newts.newtId, newtId));
|
||||||
|
if (!newt) {
|
||||||
|
throw new Error(`No newt found for id: ${newtId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the semver
|
||||||
|
if (
|
||||||
|
newt.version &&
|
||||||
|
!semver.satisfies(newt.version, NEWT_V2_TARGETS_VERSION)
|
||||||
|
) {
|
||||||
|
logger.debug(
|
||||||
|
`addTargets Newt version ${newt.version} does not support targets v2 falling back`
|
||||||
|
);
|
||||||
|
targets = convertSubnetProxyTargetsV2ToV1(
|
||||||
|
targets as SubnetProxyTargetV2[]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return targets;
|
||||||
|
}
|
||||||
|
|
||||||
export async function addTargets(
|
export async function addTargets(
|
||||||
newtId: string,
|
newtId: string,
|
||||||
targets: SubnetProxyTarget[],
|
targets: SubnetProxyTarget[] | SubnetProxyTargetV2[],
|
||||||
version?: string | null
|
version?: string | null
|
||||||
) {
|
) {
|
||||||
|
targets = await convertTargetsIfNessicary(newtId, targets);
|
||||||
|
|
||||||
await sendToClient(
|
await sendToClient(
|
||||||
newtId,
|
newtId,
|
||||||
{
|
{
|
||||||
@@ -22,9 +61,11 @@ export async function addTargets(
|
|||||||
|
|
||||||
export async function removeTargets(
|
export async function removeTargets(
|
||||||
newtId: string,
|
newtId: string,
|
||||||
targets: SubnetProxyTarget[],
|
targets: SubnetProxyTarget[] | SubnetProxyTargetV2[],
|
||||||
version?: string | null
|
version?: string | null
|
||||||
) {
|
) {
|
||||||
|
targets = await convertTargetsIfNessicary(newtId, targets);
|
||||||
|
|
||||||
await sendToClient(
|
await sendToClient(
|
||||||
newtId,
|
newtId,
|
||||||
{
|
{
|
||||||
@@ -38,11 +79,39 @@ export async function removeTargets(
|
|||||||
export async function updateTargets(
|
export async function updateTargets(
|
||||||
newtId: string,
|
newtId: string,
|
||||||
targets: {
|
targets: {
|
||||||
oldTargets: SubnetProxyTarget[];
|
oldTargets: SubnetProxyTarget[] | SubnetProxyTargetV2[];
|
||||||
newTargets: SubnetProxyTarget[];
|
newTargets: SubnetProxyTarget[] | SubnetProxyTargetV2[];
|
||||||
},
|
},
|
||||||
version?: string | null
|
version?: string | null
|
||||||
) {
|
) {
|
||||||
|
// get the newt
|
||||||
|
const [newt] = await db
|
||||||
|
.select()
|
||||||
|
.from(newts)
|
||||||
|
.where(eq(newts.newtId, newtId));
|
||||||
|
if (!newt) {
|
||||||
|
logger.error(`addTargetsL No newt found for id: ${newtId}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check the semver
|
||||||
|
if (
|
||||||
|
newt.version &&
|
||||||
|
!semver.satisfies(newt.version, NEWT_V2_TARGETS_VERSION)
|
||||||
|
) {
|
||||||
|
logger.debug(
|
||||||
|
`addTargets Newt version ${newt.version} does not support targets v2 falling back`
|
||||||
|
);
|
||||||
|
targets = {
|
||||||
|
oldTargets: convertSubnetProxyTargetsV2ToV1(
|
||||||
|
targets.oldTargets as SubnetProxyTargetV2[]
|
||||||
|
),
|
||||||
|
newTargets: convertSubnetProxyTargetsV2ToV1(
|
||||||
|
targets.newTargets as SubnetProxyTargetV2[]
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
await sendToClient(
|
await sendToClient(
|
||||||
newtId,
|
newtId,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ authenticated.put(
|
|||||||
logActionAudit(ActionsEnum.createSite),
|
logActionAudit(ActionsEnum.createSite),
|
||||||
site.createSite
|
site.createSite
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/sites",
|
"/org/:orgId/sites",
|
||||||
verifyOrgAccess,
|
verifyOrgAccess,
|
||||||
@@ -644,6 +646,7 @@ authenticated.delete(
|
|||||||
logActionAudit(ActionsEnum.deleteRole),
|
logActionAudit(ActionsEnum.deleteRole),
|
||||||
role.deleteRole
|
role.deleteRole
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
"/role/:roleId/add/:userId",
|
"/role/:roleId/add/:userId",
|
||||||
verifyRoleAccess,
|
verifyRoleAccess,
|
||||||
@@ -651,7 +654,7 @@ authenticated.post(
|
|||||||
verifyLimits,
|
verifyLimits,
|
||||||
verifyUserHasAction(ActionsEnum.addUserRole),
|
verifyUserHasAction(ActionsEnum.addUserRole),
|
||||||
logActionAudit(ActionsEnum.addUserRole),
|
logActionAudit(ActionsEnum.addUserRole),
|
||||||
user.addUserRole
|
user.addUserRoleLegacy
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
@@ -1202,6 +1205,22 @@ authRouter.post(
|
|||||||
}),
|
}),
|
||||||
newt.getNewtToken
|
newt.getNewtToken
|
||||||
);
|
);
|
||||||
|
|
||||||
|
authRouter.post(
|
||||||
|
"/newt/register",
|
||||||
|
rateLimit({
|
||||||
|
windowMs: 15 * 60 * 1000,
|
||||||
|
max: 30,
|
||||||
|
keyGenerator: (req) =>
|
||||||
|
`newtRegister:${req.body.provisioningKey?.split(".")[0] || ipKeyGenerator(req.ip || "")}`,
|
||||||
|
handler: (req, res, next) => {
|
||||||
|
const message = `You can only register a newt ${30} times every ${15} minutes. Please try again later.`;
|
||||||
|
return next(createHttpError(HttpCode.TOO_MANY_REQUESTS, message));
|
||||||
|
},
|
||||||
|
store: createStore()
|
||||||
|
}),
|
||||||
|
newt.registerNewt
|
||||||
|
);
|
||||||
authRouter.post(
|
authRouter.post(
|
||||||
"/olm/get-token",
|
"/olm/get-token",
|
||||||
rateLimit({
|
rateLimit({
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { Request, Response, NextFunction } from "express";
|
import { Request, Response, NextFunction } from "express";
|
||||||
import { eq, sql } from "drizzle-orm";
|
import { sql } from "drizzle-orm";
|
||||||
import { sites } from "@server/db";
|
|
||||||
import { db } from "@server/db";
|
import { db } from "@server/db";
|
||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import createHttpError from "http-errors";
|
import createHttpError from "http-errors";
|
||||||
@@ -31,7 +30,10 @@ const MAX_RETRIES = 3;
|
|||||||
const BASE_DELAY_MS = 50;
|
const BASE_DELAY_MS = 50;
|
||||||
|
|
||||||
// How often to flush accumulated bandwidth data to the database
|
// How often to flush accumulated bandwidth data to the database
|
||||||
const FLUSH_INTERVAL_MS = 30_000; // 30 seconds
|
const FLUSH_INTERVAL_MS = 300_000; // 300 seconds
|
||||||
|
|
||||||
|
// Maximum number of sites to include in a single batch UPDATE statement
|
||||||
|
const BATCH_CHUNK_SIZE = 250;
|
||||||
|
|
||||||
// In-memory accumulator: publicKey -> AccumulatorEntry
|
// In-memory accumulator: publicKey -> AccumulatorEntry
|
||||||
let accumulator = new Map<string, AccumulatorEntry>();
|
let accumulator = new Map<string, AccumulatorEntry>();
|
||||||
@@ -75,13 +77,33 @@ async function withDeadlockRetry<T>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a raw SQL query that returns rows, in a way that works across both
|
||||||
|
* the PostgreSQL driver (which exposes `execute`) and the SQLite driver (which
|
||||||
|
* exposes `all`). Drizzle's typed query builder doesn't support bulk
|
||||||
|
* UPDATE … FROM (VALUES …) natively, so we drop to raw SQL here.
|
||||||
|
*/
|
||||||
|
async function dbQueryRows<T extends Record<string, unknown>>(
|
||||||
|
query: Parameters<(typeof sql)["join"]>[0][number]
|
||||||
|
): Promise<T[]> {
|
||||||
|
const anyDb = db as any;
|
||||||
|
if (typeof anyDb.execute === "function") {
|
||||||
|
// PostgreSQL (node-postgres via Drizzle) — returns { rows: [...] } or an array
|
||||||
|
const result = await anyDb.execute(query);
|
||||||
|
return (Array.isArray(result) ? result : (result.rows ?? [])) as T[];
|
||||||
|
}
|
||||||
|
// SQLite (better-sqlite3 via Drizzle) — returns an array directly
|
||||||
|
return (await anyDb.all(query)) as T[];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush all accumulated site bandwidth data to the database.
|
* Flush all accumulated site bandwidth data to the database.
|
||||||
*
|
*
|
||||||
* Swaps out the accumulator before writing so that any bandwidth messages
|
* Swaps out the accumulator before writing so that any bandwidth messages
|
||||||
* received during the flush are captured in the new accumulator rather than
|
* received during the flush are captured in the new accumulator rather than
|
||||||
* being lost or causing contention. Entries that fail to write are re-queued
|
* being lost or causing contention. Sites are updated in chunks via a single
|
||||||
* back into the accumulator so they will be retried on the next flush.
|
* batch UPDATE per chunk. Failed chunks are discarded — exact per-flush
|
||||||
|
* accuracy is not critical and re-queuing is not worth the added complexity.
|
||||||
*
|
*
|
||||||
* This function is exported so that the application's graceful-shutdown
|
* This function is exported so that the application's graceful-shutdown
|
||||||
* cleanup handler can call it before the process exits.
|
* cleanup handler can call it before the process exits.
|
||||||
@@ -108,76 +130,76 @@ export async function flushSiteBandwidthToDb(): Promise<void> {
|
|||||||
`Flushing accumulated bandwidth data for ${sortedEntries.length} site(s) to the database`
|
`Flushing accumulated bandwidth data for ${sortedEntries.length} site(s) to the database`
|
||||||
);
|
);
|
||||||
|
|
||||||
// Aggregate billing usage by org, collected during the DB update loop.
|
// Build a lookup so post-processing can reach each entry by publicKey.
|
||||||
|
const snapshotMap = new Map(sortedEntries);
|
||||||
|
|
||||||
|
// Aggregate billing usage by org across all chunks.
|
||||||
const orgUsageMap = new Map<string, number>();
|
const orgUsageMap = new Map<string, number>();
|
||||||
|
|
||||||
for (const [publicKey, { bytesIn, bytesOut, exitNodeId, calcUsage }] of sortedEntries) {
|
// Process in chunks so individual queries stay at a reasonable size.
|
||||||
|
for (let i = 0; i < sortedEntries.length; i += BATCH_CHUNK_SIZE) {
|
||||||
|
const chunk = sortedEntries.slice(i, i + BATCH_CHUNK_SIZE);
|
||||||
|
const chunkEnd = i + chunk.length - 1;
|
||||||
|
|
||||||
|
// Build a parameterised VALUES list: (pubKey, bytesIn, bytesOut), ...
|
||||||
|
// Both PostgreSQL and SQLite (≥ 3.33.0, which better-sqlite3 bundles)
|
||||||
|
// support UPDATE … FROM (VALUES …), letting us update the whole chunk
|
||||||
|
// in a single query instead of N individual round-trips.
|
||||||
|
const valuesList = chunk.map(([publicKey, { bytesIn, bytesOut }]) =>
|
||||||
|
sql`(${publicKey}, ${bytesIn}, ${bytesOut})`
|
||||||
|
);
|
||||||
|
const valuesClause = sql.join(valuesList, sql`, `);
|
||||||
|
|
||||||
|
let rows: { orgId: string; pubKey: string }[] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updatedSite = await withDeadlockRetry(async () => {
|
rows = await withDeadlockRetry(async () => {
|
||||||
const [result] = await db
|
return dbQueryRows<{ orgId: string; pubKey: string }>(sql`
|
||||||
.update(sites)
|
UPDATE sites
|
||||||
.set({
|
SET
|
||||||
megabytesOut: sql`COALESCE(${sites.megabytesOut}, 0) + ${bytesIn}`,
|
"bytesOut" = COALESCE("bytesOut", 0) + v.bytes_in,
|
||||||
megabytesIn: sql`COALESCE(${sites.megabytesIn}, 0) + ${bytesOut}`,
|
"bytesIn" = COALESCE("bytesIn", 0) + v.bytes_out,
|
||||||
lastBandwidthUpdate: currentTime,
|
"lastBandwidthUpdate" = ${currentTime}
|
||||||
})
|
FROM (VALUES ${valuesClause}) AS v(pub_key, bytes_in, bytes_out)
|
||||||
.where(eq(sites.pubKey, publicKey))
|
WHERE sites."pubKey" = v.pub_key
|
||||||
.returning({
|
RETURNING sites."orgId" AS "orgId", sites."pubKey" AS "pubKey"
|
||||||
orgId: sites.orgId,
|
`);
|
||||||
siteId: sites.siteId
|
}, `flush bandwidth chunk [${i}–${chunkEnd}]`);
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}, `flush bandwidth for site ${publicKey}`);
|
|
||||||
|
|
||||||
if (updatedSite) {
|
|
||||||
if (exitNodeId) {
|
|
||||||
const notAllowed = await checkExitNodeOrg(
|
|
||||||
exitNodeId,
|
|
||||||
updatedSite.orgId
|
|
||||||
);
|
|
||||||
if (notAllowed) {
|
|
||||||
logger.warn(
|
|
||||||
`Exit node ${exitNodeId} is not allowed for org ${updatedSite.orgId}`
|
|
||||||
);
|
|
||||||
// Skip usage tracking for this site but continue
|
|
||||||
// processing the rest.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (calcUsage) {
|
|
||||||
const totalBandwidth = bytesIn + bytesOut;
|
|
||||||
const current = orgUsageMap.get(updatedSite.orgId) ?? 0;
|
|
||||||
orgUsageMap.set(updatedSite.orgId, current + totalBandwidth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Failed to flush bandwidth for site ${publicKey}:`,
|
`Failed to flush bandwidth chunk [${i}–${chunkEnd}], discarding ${chunk.length} site(s):`,
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
// Discard the chunk — exact per-flush accuracy is not critical.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Re-queue the failed entry so it is retried on the next flush
|
// Collect billing usage from the returned rows.
|
||||||
// rather than silently dropped.
|
for (const { orgId, pubKey } of rows) {
|
||||||
const existing = accumulator.get(publicKey);
|
const entry = snapshotMap.get(pubKey);
|
||||||
if (existing) {
|
if (!entry) continue;
|
||||||
existing.bytesIn += bytesIn;
|
|
||||||
existing.bytesOut += bytesOut;
|
const { bytesIn, bytesOut, exitNodeId, calcUsage } = entry;
|
||||||
} else {
|
|
||||||
accumulator.set(publicKey, {
|
if (exitNodeId) {
|
||||||
bytesIn,
|
const notAllowed = await checkExitNodeOrg(exitNodeId, orgId);
|
||||||
bytesOut,
|
if (notAllowed) {
|
||||||
exitNodeId,
|
logger.warn(
|
||||||
calcUsage
|
`Exit node ${exitNodeId} is not allowed for org ${orgId}`
|
||||||
});
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calcUsage) {
|
||||||
|
const current = orgUsageMap.get(orgId) ?? 0;
|
||||||
|
orgUsageMap.set(orgId, current + bytesIn + bytesOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process billing usage updates outside the site-update loop to keep
|
// Process billing usage updates after all chunks are written.
|
||||||
// lock scope small and concerns separated.
|
|
||||||
if (orgUsageMap.size > 0) {
|
if (orgUsageMap.size > 0) {
|
||||||
// Sort org IDs for consistent lock ordering.
|
|
||||||
const sortedOrgIds = [...orgUsageMap.keys()].sort();
|
const sortedOrgIds = [...orgUsageMap.keys()].sort();
|
||||||
|
|
||||||
for (const orgId of sortedOrgIds) {
|
for (const orgId of sortedOrgIds) {
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ const bodySchema = z.strictObject({
|
|||||||
namePath: z.string().optional(),
|
namePath: z.string().optional(),
|
||||||
scopes: z.string().nonempty(),
|
scopes: z.string().nonempty(),
|
||||||
autoProvision: z.boolean().optional(),
|
autoProvision: z.boolean().optional(),
|
||||||
tags: z.string().optional()
|
tags: z.string().optional(),
|
||||||
|
variant: z.enum(["oidc", "google", "azure"]).optional().default("oidc")
|
||||||
});
|
});
|
||||||
|
|
||||||
export type CreateIdpResponse = {
|
export type CreateIdpResponse = {
|
||||||
@@ -77,7 +78,8 @@ export async function createOidcIdp(
|
|||||||
namePath,
|
namePath,
|
||||||
name,
|
name,
|
||||||
autoProvision,
|
autoProvision,
|
||||||
tags
|
tags,
|
||||||
|
variant
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -121,7 +123,8 @@ export async function createOidcIdp(
|
|||||||
scopes,
|
scopes,
|
||||||
identifierPath,
|
identifierPath,
|
||||||
emailPath,
|
emailPath,
|
||||||
namePath
|
namePath,
|
||||||
|
variant
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ const bodySchema = z.strictObject({
|
|||||||
autoProvision: z.boolean().optional(),
|
autoProvision: z.boolean().optional(),
|
||||||
defaultRoleMapping: z.string().optional(),
|
defaultRoleMapping: z.string().optional(),
|
||||||
defaultOrgMapping: z.string().optional(),
|
defaultOrgMapping: z.string().optional(),
|
||||||
tags: z.string().optional()
|
tags: z.string().optional(),
|
||||||
|
variant: z.enum(["oidc", "google", "azure"]).optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type UpdateIdpResponse = {
|
export type UpdateIdpResponse = {
|
||||||
@@ -96,7 +97,8 @@ export async function updateOidcIdp(
|
|||||||
autoProvision,
|
autoProvision,
|
||||||
defaultRoleMapping,
|
defaultRoleMapping,
|
||||||
defaultOrgMapping,
|
defaultOrgMapping,
|
||||||
tags
|
tags,
|
||||||
|
variant
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
|
|
||||||
if (process.env.IDENTITY_PROVIDER_MODE === "org") {
|
if (process.env.IDENTITY_PROVIDER_MODE === "org") {
|
||||||
@@ -159,7 +161,8 @@ export async function updateOidcIdp(
|
|||||||
scopes,
|
scopes,
|
||||||
identifierPath,
|
identifierPath,
|
||||||
emailPath,
|
emailPath,
|
||||||
namePath
|
namePath,
|
||||||
|
variant
|
||||||
};
|
};
|
||||||
|
|
||||||
keysToUpdate = Object.keys(configData).filter(
|
keysToUpdate = Object.keys(configData).filter(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
orgs,
|
orgs,
|
||||||
Role,
|
Role,
|
||||||
roles,
|
roles,
|
||||||
|
userOrgRoles,
|
||||||
userOrgs,
|
userOrgs,
|
||||||
users
|
users
|
||||||
} from "@server/db";
|
} from "@server/db";
|
||||||
@@ -35,11 +36,13 @@ import { usageService } from "@server/lib/billing/usageService";
|
|||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
import { calculateUserClientsForOrgs } from "@server/lib/calculateUserClientsForOrgs";
|
import { calculateUserClientsForOrgs } from "@server/lib/calculateUserClientsForOrgs";
|
||||||
import { isSubscribed } from "#dynamic/lib/isSubscribed";
|
import { isSubscribed } from "#dynamic/lib/isSubscribed";
|
||||||
|
import { isLicensedOrSubscribed } from "#dynamic/lib/isLicencedOrSubscribed";
|
||||||
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
import { tierMatrix } from "@server/lib/billing/tierMatrix";
|
||||||
import {
|
import {
|
||||||
assignUserToOrg,
|
assignUserToOrg,
|
||||||
removeUserFromOrg
|
removeUserFromOrg
|
||||||
} from "@server/lib/userOrg";
|
} from "@server/lib/userOrg";
|
||||||
|
import { unwrapRoleMapping } from "@app/lib/idpRoleMapping";
|
||||||
|
|
||||||
const ensureTrailingSlash = (url: string): string => {
|
const ensureTrailingSlash = (url: string): string => {
|
||||||
return url;
|
return url;
|
||||||
@@ -366,7 +369,7 @@ export async function validateOidcCallback(
|
|||||||
const defaultRoleMapping = existingIdp.idp.defaultRoleMapping;
|
const defaultRoleMapping = existingIdp.idp.defaultRoleMapping;
|
||||||
const defaultOrgMapping = existingIdp.idp.defaultOrgMapping;
|
const defaultOrgMapping = existingIdp.idp.defaultOrgMapping;
|
||||||
|
|
||||||
const userOrgInfo: { orgId: string; roleId: number }[] = [];
|
const userOrgInfo: { orgId: string; roleIds: number[] }[] = [];
|
||||||
for (const org of allOrgs) {
|
for (const org of allOrgs) {
|
||||||
const [idpOrgRes] = await db
|
const [idpOrgRes] = await db
|
||||||
.select()
|
.select()
|
||||||
@@ -378,8 +381,6 @@ export async function validateOidcCallback(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
let roleId: number | undefined = undefined;
|
|
||||||
|
|
||||||
const orgMapping = idpOrgRes?.orgMapping || defaultOrgMapping;
|
const orgMapping = idpOrgRes?.orgMapping || defaultOrgMapping;
|
||||||
const hydratedOrgMapping = hydrateOrgMapping(
|
const hydratedOrgMapping = hydrateOrgMapping(
|
||||||
orgMapping,
|
orgMapping,
|
||||||
@@ -404,38 +405,55 @@ export async function validateOidcCallback(
|
|||||||
idpOrgRes?.roleMapping || defaultRoleMapping;
|
idpOrgRes?.roleMapping || defaultRoleMapping;
|
||||||
if (roleMapping) {
|
if (roleMapping) {
|
||||||
logger.debug("Role Mapping", { roleMapping });
|
logger.debug("Role Mapping", { roleMapping });
|
||||||
const roleName = jmespath.search(claims, roleMapping);
|
const roleMappingJmes = unwrapRoleMapping(
|
||||||
|
roleMapping
|
||||||
|
).evaluationExpression;
|
||||||
|
const roleMappingResult = jmespath.search(
|
||||||
|
claims,
|
||||||
|
roleMappingJmes
|
||||||
|
);
|
||||||
|
const roleNames = normalizeRoleMappingResult(
|
||||||
|
roleMappingResult
|
||||||
|
);
|
||||||
|
|
||||||
if (!roleName) {
|
const supportsMultiRole = await isLicensedOrSubscribed(
|
||||||
logger.error("Role name not found in the ID token", {
|
org.orgId,
|
||||||
roleName
|
tierMatrix.fullRbac
|
||||||
|
);
|
||||||
|
const effectiveRoleNames = supportsMultiRole
|
||||||
|
? roleNames
|
||||||
|
: roleNames.slice(0, 1);
|
||||||
|
|
||||||
|
if (!effectiveRoleNames.length) {
|
||||||
|
logger.error("Role mapping returned no valid roles", {
|
||||||
|
roleMappingResult
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [roleRes] = await db
|
const roleRes = await db
|
||||||
.select()
|
.select()
|
||||||
.from(roles)
|
.from(roles)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(
|
||||||
eq(roles.orgId, org.orgId),
|
eq(roles.orgId, org.orgId),
|
||||||
eq(roles.name, roleName)
|
inArray(roles.name, effectiveRoleNames)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!roleRes) {
|
if (!roleRes.length) {
|
||||||
logger.error("Role not found", {
|
logger.error("No mapped roles found in organization", {
|
||||||
orgId: org.orgId,
|
orgId: org.orgId,
|
||||||
roleName
|
roleNames: effectiveRoleNames
|
||||||
});
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
roleId = roleRes.roleId;
|
const roleIds = [...new Set(roleRes.map((r) => r.roleId))];
|
||||||
|
|
||||||
userOrgInfo.push({
|
userOrgInfo.push({
|
||||||
orgId: org.orgId,
|
orgId: org.orgId,
|
||||||
roleId
|
roleIds
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -570,32 +588,28 @@ export async function validateOidcCallback(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update roles for existing auto-provisioned orgs where the role has changed
|
// Sync roles 1:1 with IdP policy for existing auto-provisioned orgs
|
||||||
const orgsToUpdate = autoProvisionedOrgs.filter(
|
for (const currentOrg of autoProvisionedOrgs) {
|
||||||
(currentOrg) => {
|
const newRole = userOrgInfo.find(
|
||||||
const newOrg = userOrgInfo.find(
|
(newOrg) => newOrg.orgId === currentOrg.orgId
|
||||||
(newOrg) => newOrg.orgId === currentOrg.orgId
|
);
|
||||||
);
|
if (!newRole) continue;
|
||||||
return newOrg && newOrg.roleId !== currentOrg.roleId;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (orgsToUpdate.length > 0) {
|
await trx
|
||||||
for (const org of orgsToUpdate) {
|
.delete(userOrgRoles)
|
||||||
const newRole = userOrgInfo.find(
|
.where(
|
||||||
(newOrg) => newOrg.orgId === org.orgId
|
and(
|
||||||
|
eq(userOrgRoles.userId, userId!),
|
||||||
|
eq(userOrgRoles.orgId, currentOrg.orgId)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
if (newRole) {
|
|
||||||
await trx
|
for (const roleId of newRole.roleIds) {
|
||||||
.update(userOrgs)
|
await trx.insert(userOrgRoles).values({
|
||||||
.set({ roleId: newRole.roleId })
|
userId: userId!,
|
||||||
.where(
|
orgId: currentOrg.orgId,
|
||||||
and(
|
roleId
|
||||||
eq(userOrgs.userId, userId!),
|
});
|
||||||
eq(userOrgs.orgId, org.orgId)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +623,10 @@ export async function validateOidcCallback(
|
|||||||
|
|
||||||
if (orgsToAdd.length > 0) {
|
if (orgsToAdd.length > 0) {
|
||||||
for (const org of orgsToAdd) {
|
for (const org of orgsToAdd) {
|
||||||
|
if (org.roleIds.length === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const [fullOrg] = await trx
|
const [fullOrg] = await trx
|
||||||
.select()
|
.select()
|
||||||
.from(orgs)
|
.from(orgs)
|
||||||
@@ -619,9 +637,9 @@ export async function validateOidcCallback(
|
|||||||
{
|
{
|
||||||
orgId: org.orgId,
|
orgId: org.orgId,
|
||||||
userId: userId!,
|
userId: userId!,
|
||||||
roleId: org.roleId,
|
|
||||||
autoProvisioned: true,
|
autoProvisioned: true,
|
||||||
},
|
},
|
||||||
|
org.roleIds,
|
||||||
trx
|
trx
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -748,3 +766,25 @@ function hydrateOrgMapping(
|
|||||||
}
|
}
|
||||||
return orgMapping.split("{{orgId}}").join(orgId);
|
return orgMapping.split("{{orgId}}").join(orgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeRoleMappingResult(
|
||||||
|
result: unknown
|
||||||
|
): string[] {
|
||||||
|
if (typeof result === "string") {
|
||||||
|
const role = result.trim();
|
||||||
|
return role ? [role] : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
return [
|
||||||
|
...new Set(
|
||||||
|
result
|
||||||
|
.filter((value): value is string => typeof value === "string")
|
||||||
|
.map((value) => value.trim())
|
||||||
|
.filter(Boolean)
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
verifyApiKey,
|
verifyApiKey,
|
||||||
verifyApiKeyOrgAccess,
|
verifyApiKeyOrgAccess,
|
||||||
verifyApiKeyHasAction,
|
verifyApiKeyHasAction,
|
||||||
|
verifyApiKeyCanSetUserOrgRoles,
|
||||||
verifyApiKeySiteAccess,
|
verifyApiKeySiteAccess,
|
||||||
verifyApiKeyResourceAccess,
|
verifyApiKeyResourceAccess,
|
||||||
verifyApiKeyTargetAccess,
|
verifyApiKeyTargetAccess,
|
||||||
@@ -595,7 +596,7 @@ authenticated.post(
|
|||||||
verifyLimits,
|
verifyLimits,
|
||||||
verifyApiKeyHasAction(ActionsEnum.addUserRole),
|
verifyApiKeyHasAction(ActionsEnum.addUserRole),
|
||||||
logActionAudit(ActionsEnum.addUserRole),
|
logActionAudit(ActionsEnum.addUserRole),
|
||||||
user.addUserRole
|
user.addUserRoleLegacy
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.post(
|
authenticated.post(
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import { eq, and } from "drizzle-orm";
|
|||||||
import config from "@server/lib/config";
|
import config from "@server/lib/config";
|
||||||
import {
|
import {
|
||||||
formatEndpoint,
|
formatEndpoint,
|
||||||
generateSubnetProxyTargets,
|
generateSubnetProxyTargetV2,
|
||||||
SubnetProxyTarget
|
SubnetProxyTargetV2
|
||||||
} from "@server/lib/ip";
|
} from "@server/lib/ip";
|
||||||
|
|
||||||
export async function buildClientConfigurationForNewtClient(
|
export async function buildClientConfigurationForNewtClient(
|
||||||
@@ -143,7 +143,7 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
.from(siteResources)
|
.from(siteResources)
|
||||||
.where(eq(siteResources.siteId, siteId));
|
.where(eq(siteResources.siteId, siteId));
|
||||||
|
|
||||||
const targetsToSend: SubnetProxyTarget[] = [];
|
const targetsToSend: SubnetProxyTargetV2[] = [];
|
||||||
|
|
||||||
for (const resource of allSiteResources) {
|
for (const resource of allSiteResources) {
|
||||||
// Get clients associated with this specific resource
|
// Get clients associated with this specific resource
|
||||||
@@ -168,12 +168,14 @@ export async function buildClientConfigurationForNewtClient(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const resourceTargets = generateSubnetProxyTargets(
|
const resourceTarget = generateSubnetProxyTargetV2(
|
||||||
resource,
|
resource,
|
||||||
resourceClients
|
resourceClients
|
||||||
);
|
);
|
||||||
|
|
||||||
targetsToSend.push(...resourceTargets);
|
if (resourceTarget) {
|
||||||
|
targetsToSend.push(resourceTarget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export async function createNewt(
|
|||||||
|
|
||||||
const { newtId, secret } = parsedBody.data;
|
const { newtId, secret } = parsedBody.data;
|
||||||
|
|
||||||
if (req.user && !req.userOrgRoleId) {
|
if (req.user && (!req.userOrgRoleIds || req.userOrgRoleIds.length === 0)) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
createHttpError(HttpCode.FORBIDDEN, "User does not have a role")
|
||||||
);
|
);
|
||||||
|
|||||||
13
server/routers/newt/handleConnectionLogMessage.ts
Normal file
13
server/routers/newt/handleConnectionLogMessage.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { MessageHandler } from "@server/routers/ws";
|
||||||
|
|
||||||
|
export async function flushConnectionLogToDb(): Promise<void> {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function cleanUpOldLogs(orgId: string, retentionDays: number) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const handleConnectionLogMessage: MessageHandler = async (context) => {
|
||||||
|
return;
|
||||||
|
};
|
||||||
@@ -6,11 +6,13 @@ import { db, ExitNode, exitNodes, Newt, sites } from "@server/db";
|
|||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
import { sendToExitNode } from "#dynamic/lib/exitNodes";
|
||||||
import { buildClientConfigurationForNewtClient } from "./buildConfiguration";
|
import { buildClientConfigurationForNewtClient } from "./buildConfiguration";
|
||||||
|
import { convertTargetsIfNessicary } from "../client/targets";
|
||||||
import { canCompress } from "@server/lib/clientVersionChecks";
|
import { canCompress } from "@server/lib/clientVersionChecks";
|
||||||
|
|
||||||
const inputSchema = z.object({
|
const inputSchema = z.object({
|
||||||
publicKey: z.string(),
|
publicKey: z.string(),
|
||||||
port: z.int().positive()
|
port: z.int().positive(),
|
||||||
|
chainId: z.string()
|
||||||
});
|
});
|
||||||
|
|
||||||
type Input = z.infer<typeof inputSchema>;
|
type Input = z.infer<typeof inputSchema>;
|
||||||
@@ -42,7 +44,7 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { publicKey, port } = message.data as Input;
|
const { publicKey, port, chainId } = message.data as Input;
|
||||||
const siteId = newt.siteId;
|
const siteId = newt.siteId;
|
||||||
|
|
||||||
// Get the current site data
|
// Get the current site data
|
||||||
@@ -127,13 +129,16 @@ export const handleGetConfigMessage: MessageHandler = async (context) => {
|
|||||||
exitNode
|
exitNode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const targetsToSend = await convertTargetsIfNessicary(newt.newtId, targets);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message: {
|
message: {
|
||||||
type: "newt/wg/receive-config",
|
type: "newt/wg/receive-config",
|
||||||
data: {
|
data: {
|
||||||
ipAddress: site.address,
|
ipAddress: site.address,
|
||||||
peers,
|
peers,
|
||||||
targets
|
targets: targetsToSend,
|
||||||
|
chainId: chainId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||||||
|
|
||||||
const siteId = newt.siteId;
|
const siteId = newt.siteId;
|
||||||
|
|
||||||
const { publicKey, pingResults, newtVersion, backwardsCompatible } =
|
const { publicKey, pingResults, newtVersion, backwardsCompatible, chainId } =
|
||||||
message.data;
|
message.data;
|
||||||
if (!publicKey) {
|
if (!publicKey) {
|
||||||
logger.warn("Public key not provided");
|
logger.warn("Public key not provided");
|
||||||
@@ -211,7 +211,8 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||||||
udp: udpTargets,
|
udp: udpTargets,
|
||||||
tcp: tcpTargets
|
tcp: tcpTargets
|
||||||
},
|
},
|
||||||
healthCheckTargets: validHealthCheckTargets
|
healthCheckTargets: validHealthCheckTargets,
|
||||||
|
chainId: chainId
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
|||||||
@@ -8,3 +8,5 @@ export * from "./handleNewtPingRequestMessage";
|
|||||||
export * from "./handleApplyBlueprintMessage";
|
export * from "./handleApplyBlueprintMessage";
|
||||||
export * from "./handleNewtPingMessage";
|
export * from "./handleNewtPingMessage";
|
||||||
export * from "./handleNewtDisconnectingMessage";
|
export * from "./handleNewtDisconnectingMessage";
|
||||||
|
export * from "./handleConnectionLogMessage";
|
||||||
|
export * from "./registerNewt";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user