无服务器 自建短链服务 Url-Shorten-Worker 保护password

需求

有PR提到, password应该要保护起来.

https://github.com/crazypeace/Url-Shorten-Worker/pull/6

也有评论提到, 要避免显示password.


思路

定一个 protect_keylist 

const protect_keylist = [
  "password",
]

判断list是否包含指定元素, 用 protect_keylist.includes(req_key)

在 add, del, qry 时, 判断key属于 protect_keylist 就返回报错.


在 qryall 时, 遇到 protect_keylist 就不要放到返回结果中.



========

Github: https://github.com/crazypeace/Url-Shorten-Worker

演示站: https://1way.eu.org/bodongshouqulveweifengci 你用 loadKV 查不到 password 的结果


评论

The Hot3 in Last 30 Days

无服务器 自建短链服务 Url-Shorten-Worker 完整的部署教程

ClouDNS .asia免费域名 托管到CloudFlare开CDN白嫖Websocket WS通道翻墙 / desec.io