[英]How to restrict APIGEE proxy to certain resources
I have Restful API with 40 endpoints like: 我有40个端点的Restful API,例如:
GET /user/:id GET /users POST /users GET / user /:id GET / users POST / users
and etc.... 等等....
I want to proxy API by Apigee but only certain endpoints, for example only one: 我想通过Apigee代理API,但仅某些端点(例如仅一个):
GET /users GET /用户
Can't find the way how to do it. 找不到方法。
When I add proxy it maps to all routes. 当我添加代理时,它会映射到所有路由。
Assuming your Target API is at http://hostname/basepath/
Assuming that GET /users
is equivalent to GET http://hostname/basepath/users
and so on.. You'll need to create a API proxy with the Target URL: http://hostname/basepath
Then, inside the API proxy, you need to create a resource for each valid (permitted) verb + resource path. 假设您的目标API位于
http://hostname/basepath/
假设GET /users
等效于GET http://hostname/basepath/users
,依此类推。等等。您需要使用目标URL创建一个API代理: http://hostname/basepath
之后,API代理中,你需要为每个有效(允许)动词+资源路径的资源 。 For example, If GET /users
and GET /users/:id
is permitted, you need to create 2 resources in your API proxy: GET /users
GET /users/*
This can be done from the UI at the Overview section in the API proxy. 例如,如果允许
GET /users
和GET /users/:id
则需要在API代理中创建2个资源: GET /users
GET /users/*
这可以通过API中“ 概述”部分的UI来完成。代理。
Once you finished defining the allowed resources, you need to add a Conditional Flow
with NO Condition, that only responds with an Error (you can use a Raise Fault Policy). 完成定义允许的资源后,您需要添加一个
Conditional Flow
,该Conditional Flow
的Conditional Flow
为NO,仅以错误响应(您可以使用“提出故障策略”)。 This can be done in the Develop section in the API proxy. 可以在API代理的“ 开发”部分中完成此操作。 This Conditional Flow, MUST be at the end, so if the request does not match any of the resources, it will match this default Conditional Flow, and it will trigger your Raise Fault policy.
该条件流必须位于末尾,因此,如果请求与任何资源都不匹配,它将与该默认条件流匹配,并会触发“引发故障”策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.