Google Cloud Endpoints - 当端点有斜杠时 apiKeyRequired 不起作用

电子粘土

我在 Google Cloud Endpoints Frameworks for App Engine (Java) 中有一个端点。端点仅限于需要这样的 API 密钥:

    @ApiMethod(name = "echo", path = "echo",  apiKeyRequired = AnnotationBoolean.TRUE, httpMethod = ApiMethod.HttpMethod.GET)

哪个有效。但是,如果我在调用时添加尾部斜杠,端点将返回没有 api 密钥要求的数据。

我试图在 api 定义中全局限制 api 访问,如下所示:

@Api(
name = "myapi",
version = "v1",
apiKeyRequired = AnnotationBoolean.TRUE,

然而,这似乎不起作用。我重新生成了 openapi.json 并重新部署了 openapi.js 和应用程序引擎应用程序,如果端点有斜杠,则仍然可以访问,但并非没有。

有谁知道我如何防止这种情况?任何见解都非常感谢。

电子粘土

我无法在 Google Endpoints 中解决这个问题,所以我使用了 tuckey 的 urlrewrite 来删除过滤器中的尾部斜杠

网页.xml

         <filter>
        <filter-name>UrlRewriteFilter</filter-name>
        <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
           <init-param>
                <param-name>confPath</param-name>
                <param-value>/WEB-INF/urlrewrite.xml</param-value>
            </init-param>
    </filter>
    <filter-mapping>
        <filter-name>UrlRewriteFilter</filter-name>
        <url-pattern>/_ah/api/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

urlrewrite.xml

    <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.1//EN" "http://www.tuckey.org/res/dtds/urlrewrite3.1.dtd">
<urlrewrite>
    <rule match-type="regex">  
      <note>Remove trailing slash</note>
      <from>^(.*)/$</from>
      <to type="redirect">$1</to>
    </rule>  
</urlrewrite>

更多信息:

http://www.tuckey.org/urlrewrite/manual/4.0/index.html

注意:到目前为止,它没有正确重定向。我正在继续努力,并将发布更新,但现在至少我得到了带有斜杠的版本的 404,而不是没有 api 密钥的响应数据,这满足了我目前的安全需求

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

没有Google帐户的Google Cloud Endpoints

来自分类Dev

没有Google帐户的Google Cloud Endpoints

来自分类Dev

预热请求在 Cloud Endpoints Objectify 中不起作用

来自分类Dev

Google Cloud Endpoints EOFException

来自分类Dev

Google Cloud Endpoints EOFException

来自分类Dev

Google Cloud Endpoints EOFException

来自分类Dev

Google Cloud Run中带有Sidekiq的Rails作业不起作用

来自分类Dev

Google Cloud Endpoints返回列表

来自分类Dev

Google Cloud Endpoints设置问题

来自分类Dev

GoogleAuthException:Google Cloud Endpoints未知

来自分类Dev

Google Cloud Endpoints设置问题

来自分类Dev

带有Android的Google Cloud Endpoints-缓存响应吗?

来自分类Dev

具有Cloud NAT的VPC无服务器连接器出口的Google Cloud功能不起作用

来自分类Dev

Python子进程在Google Cloud Functions中不起作用

来自分类Dev

在开发服务器(在本地主机上)上运行用于Google Cloud Endpoints的API Explorer不再起作用

来自分类Dev

在Google Cloud Endpoints中登录Facebook

来自分类Dev

从Google Cloud Endpoints的请求路径获取参数

来自分类Dev

外部客户在Google Cloud Endpoints中的授权

来自分类Dev

在Google Cloud Endpoints中登录Facebook

来自分类Dev

Google Cloud Endpoints从方法返回值

来自分类Dev

从Google Cloud Endpoints获取已部署的配置

来自分类Dev

Google Cloud Endpoints:Websockets 和 JWT

来自分类Dev

对 Google Cloud Endpoints API 进行授权调用

来自分类Dev

调用Google Cloud Endpoints API时,Google App Engine任务队列获取404

来自分类Dev

Google字体不起作用..有时

来自分类Dev

是否可以使用内置有Google+ Domains API身份验证的Google Cloud Endpoints?

来自分类Dev

EndpointsServlet 类在 Google 的 Endpoints 中有什么作用?

来自分类Dev

使用Google Cloud Endpoints JavaScript客户端时,在HTTP请求中包含cookie

来自分类Dev

使用Android Studio的Google Cloud Endpoints模板时进行Proguard配置

Related 相关文章

  1. 1

    没有Google帐户的Google Cloud Endpoints

  2. 2

    没有Google帐户的Google Cloud Endpoints

  3. 3

    预热请求在 Cloud Endpoints Objectify 中不起作用

  4. 4

    Google Cloud Endpoints EOFException

  5. 5

    Google Cloud Endpoints EOFException

  6. 6

    Google Cloud Endpoints EOFException

  7. 7

    Google Cloud Run中带有Sidekiq的Rails作业不起作用

  8. 8

    Google Cloud Endpoints返回列表

  9. 9

    Google Cloud Endpoints设置问题

  10. 10

    GoogleAuthException:Google Cloud Endpoints未知

  11. 11

    Google Cloud Endpoints设置问题

  12. 12

    带有Android的Google Cloud Endpoints-缓存响应吗?

  13. 13

    具有Cloud NAT的VPC无服务器连接器出口的Google Cloud功能不起作用

  14. 14

    Python子进程在Google Cloud Functions中不起作用

  15. 15

    在开发服务器(在本地主机上)上运行用于Google Cloud Endpoints的API Explorer不再起作用

  16. 16

    在Google Cloud Endpoints中登录Facebook

  17. 17

    从Google Cloud Endpoints的请求路径获取参数

  18. 18

    外部客户在Google Cloud Endpoints中的授权

  19. 19

    在Google Cloud Endpoints中登录Facebook

  20. 20

    Google Cloud Endpoints从方法返回值

  21. 21

    从Google Cloud Endpoints获取已部署的配置

  22. 22

    Google Cloud Endpoints:Websockets 和 JWT

  23. 23

    对 Google Cloud Endpoints API 进行授权调用

  24. 24

    调用Google Cloud Endpoints API时,Google App Engine任务队列获取404

  25. 25

    Google字体不起作用..有时

  26. 26

    是否可以使用内置有Google+ Domains API身份验证的Google Cloud Endpoints?

  27. 27

    EndpointsServlet 类在 Google 的 Endpoints 中有什么作用?

  28. 28

    使用Google Cloud Endpoints JavaScript客户端时,在HTTP请求中包含cookie

  29. 29

    使用Android Studio的Google Cloud Endpoints模板时进行Proguard配置

热门标签

归档