我正在开发一个Web API.身份验证是通过cookie.所有端点都JSON在请求正文中接收参数.
我是否需要实施CSRF token保护它们?这怎么可以被利用?是否可以通过普通<form>元素发送JSON ?
攻击者有可能拥有这样的东西吗?
<form type="application/json" method="POST">
<input name="json" value="{ my json code here }">
<input type="submit">Send</input>
<form>
Run Code Online (Sandbox Code Playgroud) 我有一个使用 AWS Amplify 托管的网站,每个具有location查询参数的 URL 都会返回类似以下内容的内容:
403 Forbidden
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>THSG05EH8EYB1E7N</RequestId>
<HostId>n6Ycon+6kmnmIMiH47lLxNiXhXduG4QzJstmzNeEfBYy3AV19PisdKfXHN99LIAE2cZgvLJ1FBQ=</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)
假设我的网站是: https: //example.com
进入:
https://example.com --> works
https://example.com?anyotherparam=anyvalue --> works
https://example.com/ --> works
https://example.com/anyurl --> works
https://example.com/anyurl?anyotherparam=anyvalue --> works
https://example.com/any/sub/url -> works
https://example.com/any/sub/url?anyotherparam=anyvalue -> works
https://example.com?location --> returns 403
https://example.com?location?anyvalue --> returns 403
https://example.com/anyurl?location --> returns 403
https://example.com/anyurl?location=anyvalue --> returns 403
https://example.com/any/sub/url?location --> returns 403
https://example.com/any/sub/url?location=anyvalue --> returns 403
Run Code Online (Sandbox Code Playgroud)
知道什么会导致这种情况吗?
编辑:我不知道是否相关...但在 Amplify 重定向中,我配置了 AWSDoc 建议的 SPA 重定向规则:
Address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
DestinationAddress: /index.html
RedirectType: 200
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用"findAndModify"来实现"getOrCreate"行为.我正在使用本机驱动程序在nodejs中工作.
我有:
var matches = db.collection("matches");
matches.findAndModify({
//query
users: {
$all: [ userA_id, userB_id ]
},
lang: lang,
category_id: category_id
},
[[ "_id", "asc"]], //order
{
$setOnInsert: {
users: [userA_id, userB_id],
category_id: category_id,
lang: lang,
status: 0
}
},
{
new:true,
upsert:true
}, function(err, doc){
//Do something with doc
});
Run Code Online (Sandbox Code Playgroud)
我想要做的是:"找到与指定用户,lang和类别的特定匹配...如果找不到,插入一个具有指定数据的新用户"
Mongo抛出这个错误:
Error getting/creating match { [MongoError: exception: cannot infer query fields to set, path 'users' is matched twice]
name: 'MongoError',
message: 'exception: cannot infer query fields to set, path …Run Code Online (Sandbox Code Playgroud) 我正在使用symfony2,我想知道是否可以重命名表单中的字段.
我的意思是......假设我有一个实体
class MyEntity{
private $name
//more code
}
Run Code Online (Sandbox Code Playgroud)
我为这个实体创建了一个类型:
class MyEntityType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'AppBundle\Entity\MyEntity'
));
}
public function getName()
{
return 'entity';
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法重命名name窗体中的字段,但映射name属性工作.就像是:
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('MySuperName', null, array("mapping" => "name"))
;
}
Run Code Online (Sandbox Code Playgroud)
那么表单参数名称变为entity[MySuperName]而不是entity[name]填充name实体上的属性?
我有一个应用程序,其中购买流程是:
PHP并Purchase Status API验证购买并向用户提供“itemX”。我遇到了一个问题,在第 3 步之后的某个时候,MYAPP 失去了通信,第 4 步没有成功。因此,用户已付费,但您的“项目”中没有“itemX”。
我查看了 Google Developer Console,但它只显示“订单 ID”,而不显示购买令牌。
有没有办法从 MYAPP/MYSERVER/GOOGLECONSOLE 获取丢失的 purchaseToken 以便我可以将此购买恢复给该用户?
是否有连接到 socket.io 的所有套接字的“原型”?
我想定义一些可用于每个连接的套接字的函数。
目前我有:
io.sockets.on('connection', function(socket) {
//Define properties and functions for socket
socket.hello = function(){
console.log("hello from "+socket.id);
}
socket.hello();
});
Run Code Online (Sandbox Code Playgroud)
但我正在为每个套接字定义一个“新”hello 函数。有套接字原型吗?所以我可以有类似的东西:
Socket.prototype.hello = function(){
console.log("hello from "+socket.id);
}
io.sockets.on('connection', function(socket) {
socket.hello();
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Stripe实现付款,我正在使用Stripe connect.
我正在阅读"通过平台充电"的文档,它说:
\Stripe\Stripe::setApiKey(PLATFORM_SECRET_KEY);
\Stripe\Charge::create(array(
'amount' => 1000,
'currency' => 'gbp',
'source' => {TOKEN},
'destination' => {CONNECTED_STRIPE_ACCOUNT_ID}
));
Run Code Online (Sandbox Code Playgroud)
我有PLATFORM_SECRET_KEY,和CONNECTED_STRIPE_ACCOUNT_ID(从带有条纹连接的oauth流程获得),但是需要TOKEN什么?
我已经知道可以从"条带形式"获取令牌,但是如果我需要向用户请求卡数据,那么"连接"条带帐户有什么意义呢?
我是否错过了流量中的某些内容?
有没有办法从用户帐户创建令牌?
我需要创建一个客户吗?
注意:我是带条纹支付的新手.
javascript ×2
php ×2
android ×1
api-design ×1
aws-amplify ×1
csrf ×1
mongodb ×1
node.js ×1
socket.io ×1
sockets ×1
symfony ×1