Parcourir la source

feat: hidden api key enhancement. (#1468)

tags/0.3.30
Garfield Dai il y a 2 ans
Parent
révision
c1e7193c4b
Aucun compte lié à l'adresse e-mail de l'auteur
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7
    1
      api/fields/api_based_extension_fields.py

+ 7
- 1
api/fields/api_based_extension_fields.py Voir le fichier



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 = {

Chargement…
Annuler
Enregistrer