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

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

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