api-platform.com

api-platform : how secure custom operation

二次信任 提交于 2019-12-08 02:07:47
问题 I want to know how to secure custom itemsOperation with api-platform, I found this code on documentation: /** * Secured resource. * * @ApiResource( * attributes={"access_control"="is_granted('ROLE_USER')"}, * collectionOperations={ * "get"={"method"="GET"}, * "post"={"method"="POST", "access_control"="is_granted('ROLE_ADMIN')"} * }, * itemOperations={ * "get"{"method"="GET","access_control"="is_granted('ROLE_USER') and object.owner == user"} * } * ) * @ORM\Entity */ But I want to do something

401 JWT Token not found

主宰稳场 提交于 2019-12-06 09:24:54
I provided two versions of the security.yaml file. The second version according to API Platform documentation. API Platform sends to the creation a custom user provider . For the second option security.yaml recommended at API Platform docs, I need to create two additional files. I did not attach them to the topic, but will do it if necessary. But I think that problem it is in JWT. Environment: node v8.9.4 chrome 64.0.3282.119 Ubuntu 16.04 axios version: 0.16.2 Vue.js 2.4.2 vue-axios 2.0.2 api-platform/api-pack: 1.0 Symfony 4.0.4 User.php <?php namespace App\Entity; use Doctrine\ORM\Mapping as

api-platform : how secure custom operation

两盒软妹~` 提交于 2019-12-06 06:25:19
I want to know how to secure custom itemsOperation with api-platform, I found this code on documentation: /** * Secured resource. * * @ApiResource( * attributes={"access_control"="is_granted('ROLE_USER')"}, * collectionOperations={ * "get"={"method"="GET"}, * "post"={"method"="POST", "access_control"="is_granted('ROLE_ADMIN')"} * }, * itemOperations={ * "get"{"method"="GET","access_control"="is_granted('ROLE_USER') and object.owner == user"} * } * ) * @ORM\Entity */ But I want to do something like: /** * @ApiResource(itemOperations={ * "get"={"method"="GET"} //Public route, * "special"={"route

How to get API-Platform to load related (e.g. Many2One) resources/entities?

瘦欲@ 提交于 2019-12-06 05:15:02
According to the documentation , api-platform will eager-load related resources by default. But on the default configuration, all my queries to resources with relations (mostly with typical Many2One relationships) populate these properties with the object IRI instead of the serialized object. E.g., for this entity: /** * @ORM\Entity(repositoryClass="App\Repository\BoostLeadContactActionRepository") * @ORM\Table(name="BoostLeadContactActions") */ class BoostLeadContactAction { /** * @ORM\Id() * @ORM\GeneratedValue() * @ORM\Column(type="integer") */ private $id; /** * @ORM\ManyToOne(targetEntity

Symfony 4: Test DB for JWT and Behat

人盡茶涼 提交于 2019-12-06 04:48:43
问题 I am using API Platform 2.1 with Symfony 4 and I am using the LexikJWTAuthenticationBundle for authentication, and Behat for testing. I am unable to set things up properly. Here is my configuration so far: Feature: Books feature @createSchema @dropSchema Scenario: Adding a new book When I add "Content-Type" header equal to "application/json" And I add "Accept" header equal to "application/json" And I send a "POST" request to "/api/books" with body: """ { "title": "King", "author": "T. M.

API Platform - how to document authentication routes

两盒软妹~` 提交于 2019-12-06 01:12:59
I'm using API Platform v2.2.5 in a Symfony 4 Flex application, consisting of a functioning API with JWT Authentication , a number of resources and the default Open API/Swagger documentation page that is accessible via the /api route. Each API resource is included in the documentation automatically via the platform configuration, as per the library docs . How do you generate documentation for custom operations such as the security component's auth routes? The API Platform Documentation does not seem to include these instructions. I found the answer thanks to this comment in a Github issue .

Symfony 4: Test DB for JWT and Behat

邮差的信 提交于 2019-12-04 11:18:41
I am using API Platform 2.1 with Symfony 4 and I am using the LexikJWTAuthenticationBundle for authentication, and Behat for testing. I am unable to set things up properly. Here is my configuration so far: Feature: Books feature @createSchema @dropSchema Scenario: Adding a new book When I add "Content-Type" header equal to "application/json" And I add "Accept" header equal to "application/json" And I send a "POST" request to "/api/books" with body: """ { "title": "King", "author": "T. M. Frazier", "enabled": true } """ Then the response status code should be 201 And the response should be in

API-Platform JWT : No route found for “GET /api/login”

半城伤御伤魂 提交于 2019-12-01 10:11:29
I successfully installed API Platform, it works well with all my entities. Now i'm trying to add JWT authentication whith LexikJWTAuthenticationBundle, but when i send the request for login i get : No route found for "GET /api/login" My request : http://localhost:8000/api/login?username=john&password=doe I'm using Symfony 4, here is my security.yaml : encoders: App\Entity\User: algorithm: bcrypt providers: entity_provider: entity: class: App\Entity\User property: username firewalls: login: pattern: ^/api/login stateless: true anonymous: true provider: entity_provider json_login: check_path:

API-Platform JWT : No route found for “GET /api/login”

笑着哭i 提交于 2019-12-01 07:55:55
问题 I successfully installed API Platform, it works well with all my entities. Now i'm trying to add JWT authentication whith LexikJWTAuthenticationBundle, but when i send the request for login i get : No route found for "GET /api/login" My request : http://localhost:8000/api/login?username=john&password=doe I'm using Symfony 4, here is my security.yaml : encoders: App\Entity\User: algorithm: bcrypt providers: entity_provider: entity: class: App\Entity\User property: username firewalls: login: