瀏覽代碼

feat: hidden api key enhancement. (#1468)

tags/0.3.30
Garfield Dai 2 年之前
父節點
當前提交
c1e7193c4b
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 7 行新增1 行删除
  1. 7
    1
      api/fields/api_based_extension_fields.py

+ 7
- 1
api/fields/api_based_extension_fields.py 查看文件

@@ -5,7 +5,13 @@ from libs.helper import TimestampField

class HiddenAPIKey(fields.Raw):
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 = {

Loading…
取消
儲存