wso2 api manager如何保护后端apis(wso2 api manager how to protect backend apis)
我正在转向WSO2 API Manager云。 我自己在AWS中托管了我的后端API和wso2 API Manager。 对后端API的访问仅限于WSO2 API Manager EC2 Mahcine的IP。 这样每个请求都必须经过WSO2 Machine。
如何在使用WSO2 Cloud时实现同样的目标?保护我的后端API的理想方式是什么? 或者是否有推荐的方法来保护后端API? 可能会检查后端代码中的某个标记以查看是否通过WSO2 API Mananger发出请求?
I am moving to WSO2 API Manager cloud. I have hosted my backend API's and wso2 API Manager in AWS myself. The access to backend API's were limited only to WSO2 API Manager EC2 Mahcine's IP. So that every request will have to go through WSO2 Machine.
How to achieve the same when using WSO2 Cloud?What is the ideal way to protect my Back End API's? OR is there a recommended approach for protecting backend API's? May be check for some token in the backend code to see if request comes via WSO2 API Mananger?
原文:https://stackoverflow.com/questions/47761739
最满意答案
正如文档所说, 它是驾驶员的特殊能力 。 它会自动将
cursor[0]
转换为cursor.toArray()[0]
。 您可以通过使用print函数覆盖toArray()
或使用new Error().stack
来证明它,以获得callstack。 这里是:at DBQuery.a.toArray ((shell):1:32) at DBQuery.arrayAccess (src/mongo/shell/query.js:290:17) at (shell):1:2
如您所见,索引调用
arrayAccess
。 怎么样? 这里我们有一个dbQueryIndexAccess
函数 ,它调用arrayAccess
。v8::Handle<v8::Value> arrayAccess = info.This()->GetPrototype()->ToObject()->Get( v8::String::New("arrayAccess")); ... v8::Handle<v8::Function> f = arrayAccess.As<v8::Function>(); ... return f->Call(info.This(), 1, argv);
这里我们有一个代码 ,它为这个函数设置了索引属性处理程序 。 WOW,v8 API让我们能够添加这个处理程序!
DBQueryFT()->InstanceTemplate()->SetIndexedPropertyHandler(dbQueryIndexAccess);
...并将其注入到JS游标类中,该游标类最初是在JS中定义的。
injectV8Function("DBQuery", DBQueryFT(), _global);
Tl; dr :它是用mongo shell的C ++源代码攻击的 。
As documentation says, it is special ability of driver. It automagicly converts
cursor[0]
tocursor.toArray()[0]
. You can prove it by overridingtoArray()
with print function ornew Error().stack
to get callstack back. Here it is:at DBQuery.a.toArray ((shell):1:32) at DBQuery.arrayAccess (src/mongo/shell/query.js:290:17) at (shell):1:2
As you can see, indexing calls
arrayAccess
. How? Here we have adbQueryIndexAccess
function, which callsarrayAccess
.v8::Handle<v8::Value> arrayAccess = info.This()->GetPrototype()->ToObject()->Get( v8::String::New("arrayAccess")); ... v8::Handle<v8::Function> f = arrayAccess.As<v8::Function>(); ... return f->Call(info.This(), 1, argv);
And here we have a code, which sets indexed property handler to this function. WOW, v8 API gives us ability to add this handler!
DBQueryFT()->InstanceTemplate()->SetIndexedPropertyHandler(dbQueryIndexAccess);
... and injects it into JS cursor class, which is defined originaly in JS.
injectV8Function("DBQuery", DBQueryFT(), _global);
Tl;dr: It is hacked in C++ source code of mongo shell.
相关问答
更多-
该功能已在版本4.12(最新的atm)中添加,并且尚未真正记录。 默认情况下, eachAsync以并发1运行,但您可以在参数“parallel”中更改它。 ( 如此处所示 ) 因此,您的代码看起来像这样: const playerProfileCursor = PlayerProfile.find({}, { tag: 1 }).cursor({ batchSize: 5000 }) const p2 = new Promise
>((resolve, reject) => { ... -
如何检查某个字段是否在mongodb中编入索引?(How to check whether a certain field is indexed in mongodb or not?)[2023-03-31]
是的,您可以使用以下查询轻松查看您的字段是否已编入索引: db.collection.stats().indexSizes().c2_YOUR_FIELD_NAME 在上面的查询中,使用您自己的集合名称和字段名称。 如果它在控制台上返回某个值,则该字段将被编入索引。 这将给你很多深刻的知识 Yes, you can easily view whether you field is indexed or not using below query: db.collection.stats().index ... -
Mongodb游标方法排序(Mongodb cursor method sort)[2022-03-09]
在PHP中,用于对Mongodb集合进行排序的语法是 // Sort on field x, ascending $cursor->sort(array('x' => 1)); 您的代码可以修改为: - static function simpleSelect($key, $value, $collection) { $con = \Core\Model\Mongo::getConnect(); $query = new \MongoDB\Driver\Query( a ... -
没有索引的MongoDB查询将进行表扫描,我们应该知道mongodb的数据大小与mysql相比要多得多。 我猜这可能是进行全扫描时缓慢的问题之一。 关于带索引的查询,mongoDB可能因为缓存而变得更快,没有复杂的查询优化器计划(如mysql)等。 集合的大小不是问题。 实际上,一个集合中可以轻松处理1000万个。 如果您需要归档数据,那么您可以分成较小的集合,这将使过程变得简单。 MongoDB queries without the index will be doing table scan and ...
-
mongoDB中的游标隔离(Cursor isolation in mongoDB)[2022-04-23]
好吧,基本上MongoDB直接从100个批量读取数据文件(可以用batch_size更改为最大16MB,基本上返回是单个BSON文档)。 这与写出静态结果集的SQL形成对比。 因此,您立即了解游标,如果它们具有与它们交错的操作,则可以返回文档,如果它们在排序中发生更改,即如果您有此查询: db.c.find().sort({s:1}); 其中s是一个整数,由此你修改了第一个找到最高s文档,使它出现在后面,你实际上可以(通过最后一批)再次获得该文档。 当然,这是一个很大的问题。 在某些情况下,您最终可能会绕 ... -
mongodb索引与$ where(mongodb indexes with $where)[2023-02-18]
不,在这种情况下不会使用索引。 您可以运行explain()来验证。 No, an index won't be used in that case. You can run an explain() to verify. -
Mongodb - 没有使用索引(Mongodb - index not being used)[2022-05-28]
你必须在这样的嵌套字段上创建索引 db.index.createIndex({ “id.pid.f1”:1, “id.pid.f2”:1}) you have to create index on nested fields like this db.index.createIndex({"id.pid.f1":1,"id.pid.f2":1}) -
正如文档所说, 它是驾驶员的特殊能力 。 它会自动将cursor[0]转换为cursor.toArray()[0] 。 您可以通过使用print函数覆盖toArray()或使用new Error().stack来证明它,以获得callstack。 这里是: at DBQuery.a.toArray ((shell):1:32) at DBQuery.arrayAccess (src/mongo/shell/query.js:290:17) at (shell):1:2 如您所见,索引调用arrayAcce ...
-
就MongoDB索引而言,您可以考虑几种不同的方法。 多键索引 索引名称和变体的常用方法是基于搜索项数组实现多键搜索(如您所见)。 MongoDB手册中还有一个示例: 支持关键字搜索的模型数据 。 使用此方法,您可以索引多个相关关键字以进行搜索,并控制其他关键字。 索引字通常以小写形式存储,具有常见变体,因此您不必使用正则表达式匹配。 如果正则表达式区分大小写并且在匹配字符串的开头有一个锚(^),则正则表达式匹配只能有效地使用索引。 MongoDB 2.4文本搜索 MongoDB 2.4引入了一个新的文本搜 ...
-
MongoDB不支持检索索引的内容,以获取索引文档的详细信息。 但是,您可以使用与索引中的过滤器相同的过滤器对集合运行查询,以获取索引文档: db.collection.find({ "IsArchived": { "$eq": true } }) 另外,如果你想获得计数,你可以在最后加上.count() : db.collection.find({ "IsArchived": { "$eq": true } }).count() 为了查看您的索引是否被使用,您可以运行以下查询: db.collecti ...