Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat: add reset-encrypt-key-pair cmd for self hosted mode (#325)
John Wang6123bba96d19
diff --git a/api/commands.py b/api/commands.pyindex 11123336217..10beec6c9ac 100644--- a/api/commands.py+++ b/api/commands.py@@ -3,15 +3,19 @@ import randomimport stringimport click+from flask import current_appfrom libs.password import password_pattern, valid_password, hash_passwordfrom libs.helper import email as email_validatefrom extensions.ext_database import db-from models.account import InvitationCode+from libs.rsa import generate_key_pair+from models.account import InvitationCode, Tenantfrom models.model import Accountimport secretsimport base64+from models.provider import Provider+@click.command('reset-password', help='Reset the account password.')@click.option('--email', prompt=True, help='The email address of the account whose password you need to reset')@@ -73,6 +77,31 @@ def reset_email(email, new_email, email_confirm):click.echo(click.style('Congratulations!, email has been reset.', fg='green'))[email protected]('reset-encrypt-key-pair', help='Reset the asymmetric key pair of workspace for encrypt LLM credentials. '+ 'After the reset, all LLM credentials will become invalid, '+ 'requiring re-entry.'+ 'Only support SELF_HOSTED mode.')[email protected]_option(prompt=click.style('Are you sure you want to reset encrypt key pair?'+ ' this operation cannot be rolled back!', fg='red'))+def reset_encrypt_key_pair():+ if current_app.config['EDITION'] != 'SELF_HOSTED':+ click.echo(click.style('Sorry, only support SELF_HOSTED mode.', fg='red'))+ return++ tenant = db.session.query(Tenant).first()+ if not tenant:+ click.echo(click.style('Sorry, no workspace found. Please enter /install to initialize.', fg='red'))+ return++ tenant.encrypt_public_key = generate_key_pair(tenant.id)++ db.session.query(Provider).filter(Provider.provider_type == 'custom').delete()+ db.session.commit()++ click.echo(click.style('Congratulations! '+ 'the asymmetric key pair of workspace {} has been reset.'.format(tenant.id), fg='green'))++@click.command('generate-invitation-codes', help='Generate invitation codes.')@click.option('--batch', help='The batch of invitation codes.')@click.option('--count', prompt=True, help='Invitation codes count.')@@ -134,3 +163,4 @@ def register_commands(app):app.cli.add_command(reset_password)app.cli.add_command(reset_email)app.cli.add_command(generate_invitation_codes)+ app.cli.add_command(reset_encrypt_key_pair)