我目前正在使用 NestJS 创建一个 Rest API(顺便说一下,它真的很酷)。
在此 API 中,我使用 JWT(JSON Web 令牌)来允许用户根据其角色登录并查看不同的资源。
但是,我想实现一个 API 密钥系统来保护 API 本身。我不希望任何开发人员能够使用我的 API。我希望他通过这个 API 密钥来使用我的 API。
通过 URL 中的查询:https://domaine.com?api_key=${API_KEY}或通过标头:
GET /v1/some-resource
Host: docmaine.com
Accept: application/json
X-API-KEY: MyAwes0m3API_KeY
Run Code Online (Sandbox Code Playgroud)
您有教程、课程或曲目可以为我提供建议吗?
我想知道如何在我的FormType(EntityType) 中恢复当前用户?
目前,我只能检索注册用户列表,而不能检索当前(已连接)用户。
我的电流 FormType
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class OneNewCarType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(
'author',
EntityType::class, [
'label' => 'Ville',
'class' => User::class,
'attr' => [
'class' => 'selectpicker'
],
'choice_label' => function ($author) {
return $author->getCity();
}
]
);
}
public function getBlockPrefix()
{
return 'oneNewCarType';
}
}
Run Code Online (Sandbox Code Playgroud)
我知道如何直接在我的控制器中恢复它。但是,当使用步进器包CraueFormFlowBundle时,我不知道该怎么做
这是我当前的控制器
/**
* @Route("/classified/{id}/edit", name="classified_edit")
* @param CarVehicle $carVehicle
* …Run Code Online (Sandbox Code Playgroud)