Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
6123bba9
Unverified
Commit
6123bba9
authored
Jun 09, 2023
by
John Wang
Committed by
GitHub
Jun 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add reset-encrypt-key-pair cmd for self hosted mode (#325)
parent
d5ab3b50
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
1 deletion
+31
-1
commands.py
api/commands.py
+31
-1
No files found.
api/commands.py
View file @
6123bba9
...
...
@@ -3,15 +3,19 @@ import random
import
string
import
click
from
flask
import
current_app
from
libs.password
import
password_pattern
,
valid_password
,
hash_password
from
libs.helper
import
email
as
email_validate
from
extensions.ext_database
import
db
from
models.account
import
InvitationCode
from
libs.rsa
import
generate_key_pair
from
models.account
import
InvitationCode
,
Tenant
from
models.model
import
Account
import
secrets
import
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'
))
@
click
.
command
(
'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.'
)
@
click
.
confirmation_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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment