• 请不要在回答技术问题时复制粘贴 AI 生成的内容
ethusdt
0.01D
V2EX  ›  程序员

有什么方法可以防止泄漏某些 API KEY?

  •  
  •   ethusdt · Jun 15, 2022 · 4915 views
    This topic created in 1605 days ago, the information mentioned may be changed or developed.

    像 openweather 或者 barcodelookup 这种工具, 注册后提供一个 API KEY 来进行接口请求, 而且这些请求都不是免费的, 需要花钱买请求次数. 那么问题来了, app 或者网页端如何保证这些 key 不泄漏?

    ps. 就不考虑 app 防止抓包策略了.

    https://openweathermap.org/api

    https://www.barcodelookup.com/api

    sutra
    sutra
    Jun 15, 2022❤️1
    1
    自己的服务器中转一下?
    SenLief
    SenLief
    Jun 15, 2022
    2
    自己服务器中转了,不过被抓了包,用处也不大吧,一样不是能模拟客户端发出的。
    cczhrd
    cczhrd
    Jun 15, 2022
    3
    加多一个中间层
    pelloz
    pelloz
    Jun 15, 2022❤️1
    4
    当然是自己服务器中转了,你们还能添加缓存,不是每次请求都一定要回源到收费 api 的。
    ethusdt
    ethusdt
    OP
    Jun 15, 2022
    5
    @cczhrd
    @sutra
    app/前端 请求服务器接口, 服务器那边利用这个 apikey 来请求服务商. 是这样吧.
    服务器来做一些过滤, 防止某用户一次请求多个.
    fuchaofather
    fuchaofather
    Jun 15, 2022❤️1
    6
    我们一般是经过自己服务器中转,记录调用情况。后续如果有问题可以审计分析
    Kasumi20
    Kasumi20
    Jun 15, 2022❤️1
    7
    这种 API 就不是给客户端直接用的吧,都是服务端去接入
    caqiko
    caqiko
    Jun 15, 2022 via Android
    8
    自己服务器中转,终端用户鉴权➕限制请求速度。
    Alliot
    Alliot
    Jun 15, 2022 via Android
    9
    vault
    cczhrd
    cczhrd
    Jun 17, 2022
    10
    @FaiChou 是的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2152 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 12:33 · PVG 20:33 · LAX 04:33 · JFK 07:33
    ♥ Do have faith in what you're doing.