我应该采取哪些步骤来保护我的 Google Maps API 密钥? [英] What steps should I take to protect my Google Maps API Key?

查看:28
本文介绍了我应该采取哪些步骤来保护我的 Google Maps API 密钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的域获得了一个 Google Maps API 密钥.

I have obtained a Google Maps API key for my domain.

我获取密钥时提供的示例显示了请求参数中嵌入的密钥,例如:

The examples provided when I obtained my key show the key embedded in request parameters, for example:

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=my-key" type="text/javascript"></script>

我明白请求中的引用字段必须与我的域匹配,让我的密钥在脚本标签等中可见是否安全?或者我应该采取什么其他步骤?

I appreciate that the referrer field in requests must match my domain, is it safe to make my key visible in script tags and the like? Or are there any other steps I should take?

推荐答案

考虑到该键必须包含在 HTML 页面的 <script> 标签中,以加载 JS 文件/数据从谷歌的服务器,你无能为力:

Considering that key has to be included in the <script> tags of your HTML pages, to load the JS files/data from google's servers, there is nothing you can do :

  • 你必须把它放在你的 HTML 文件中
  • 每个人都可以看看这些.

不过,这并不重要:如果有人试图在其他域上使用此密钥而不是您的域,他们将收到 Javascript 警报——这对他们的用户不利.

Still, it doesn't really matter : if anyone tries to use this key on another domain than yours, they will get a Javascript alert -- which is not nice for ther users.

所以:

  • 你无能为力;这是它的工作方式
  • 我想说,您不必担心太多.

这篇关于我应该采取哪些步骤来保护我的 Google Maps API 密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆