大摇大摆的安全 Laravel

swagger security Laravel

我安装了 "darkaonline/l5-swagger": "~3.0" 以在我的 Laravel 5.3 项目中获取 Swagger,我想为测试我的 api_key 的用户设置一个值=27=] 通过大摇大摆获得访问权限或不比较他输入的 api_key 值与一个我的值。

我有这个 security.php:

/**
 * @SWG\SecurityScheme(
 *   securityDefinition="api_key",
 *   type="apiKey",
 *   in="header",
 *   name="api_key"
 * )
 */

在我的用户控制器上:

/**
     * @SWG\Post(
     *     path="/add_user",
     *     tags={"user"},
     *     operationId="adduser",
     *     summary="Add a new user to the store",
     *     description="",
     *     produces={"application/xml", "application/json"},
     *     @SWG\Parameter(
     *         name="name",
     *         in="formData",
     *         type="string",
     *         description="Name of the user",
     *         required=true,
     *     ),
     *      @SWG\Parameter(
     *         name="lastname",
     *         in="formData",
     *         type="string",
     *         description="Lastname of the user",
     *         required=true,
     *     ),     
     *      @SWG\Parameter(
     *         name="email",
     *         in="formData",
     *         type="string",
     *         description="Email of the user",
     *         required=true,
     *     ),
     *     @SWG\Parameter(
     *         name="password",
     *         in="formData",
     *         type="string",
     *         description="password of the user",
     *         required=true,
     *     ),
     *      @SWG\Parameter(
     *         name="website",
     *         in="formData",
     *         type="string",
     *         description="website of the user",
     *         required=true,
     *     ),
     *      @SWG\Parameter(
     *         name="platform",
     *         in="formData",
     *         type="string",
     *         description="website of the user",
     *         required=true,
     *     ),
     *     @SWG\Response(
     *         response=405,
     *         description="Invalid input",
     *     ),
     *     security={
     *         {
     *             "api_key": {},
     *         }
     *     },
     * )
     */

但我可以存储一个新用户,即使我没有在我的 url 或授权对话框中添加 api_key 值。我错过了什么?

apikey还是要自己查。 Swagger 只是用来生成文档,它不会影响您的实际代码。