mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 19:15:55 +08:00
feat: hidden api key enhancement. (#1468)
This commit is contained in:
parent
2423563d45
commit
c1e7193c4b
@ -5,7 +5,13 @@ from libs.helper import TimestampField
|
|||||||
|
|
||||||
class HiddenAPIKey(fields.Raw):
|
class HiddenAPIKey(fields.Raw):
|
||||||
def output(self, key, obj):
|
def output(self, key, obj):
|
||||||
return obj.api_key[:3] + '***' + obj.api_key[-3:]
|
api_key = obj.api_key
|
||||||
|
# If the length of the api_key is less than 8 characters, show the first and last characters
|
||||||
|
if len(api_key) <= 8:
|
||||||
|
return api_key[0] + '******' + api_key[-1]
|
||||||
|
# If the api_key is greater than 8 characters, show the first three and the last three characters
|
||||||
|
else:
|
||||||
|
return api_key[:3] + '******' + api_key[-3:]
|
||||||
|
|
||||||
|
|
||||||
api_based_extension_fields = {
|
api_based_extension_fields = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user