Skip to content

feature: add doc for #230 #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 8, 2017
Merged

feature: add doc for #230 #231

merged 11 commits into from
Sep 8, 2017

Conversation

Simperfit
Copy link
Contributor

No description provided.

core/security.md Outdated
@@ -6,6 +6,52 @@ section.
Using API Platform, you can leverage all security features provided by the [Symfony Security component](http://symfony.com/doc/current/book/security.html).
For instance, if you wish to restrict the access of some endpoints, you can use [access controls directives](http://symfony.com/doc/current/book/security.html#securing-url-patterns-access-control).

You can also add security directly in the entity using the [Symfony's access control expressions](https://symfony.com/doc/current/expressions.html#security-complex-access-controls-with-expressions).
Here is a little exemple for this :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 2.1, you can add security through Symfony's access control expressions in your entities.

Here is an example:

core/security.md Outdated
Here is a little exemple for this :

```php

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line?

core/security.md Outdated
/**
* Secured resource.
*
* @author Kévin Dunglas <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed here

core/security.md Outdated
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line missing

@dunglas
Copy link
Member

dunglas commented Jun 27, 2017

Thanks for handling this Hamza! Can you just add sentence explaining what the example do?

@teohhanhui
Copy link
Contributor

Uhh... I've never noticed this, but is_granted is a really awkward attribute name.

@teohhanhui
Copy link
Contributor

teohhanhui commented Jul 3, 2017

By the way this is documenting api-platform/core#938

@Simperfit
Copy link
Contributor Author

@dunglas, I will update this asap :p

@meyerbaptiste
Copy link
Member

@Simperfit, can you replace is_granted by access_control and add a sentence explaining what the example do? It would be nice to merge it hamzap!

@meyerbaptiste
Copy link
Member

ping @Simperfit

@Simperfit Simperfit force-pushed the feature/add-security branch from e0a78d0 to 18678c3 Compare September 8, 2017 14:25
@Simperfit
Copy link
Contributor Author

done

core/security.md Outdated
}
```

This exemple is going to allow only fetching the book related to the current user, if he try to fetch a book that is not linked to his account that will not return the resource and only admins are able to create books which means that a user could not create a book.
Copy link
Member

@meyerbaptiste meyerbaptiste Sep 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Add a dot here: current user. If he
  • is linked to his account, that will
  • Replace try by tries
  • return the resource. In addition, only admins are

core/security.md Outdated
* Secured resource.
*
* @ApiResource(
* attributes={"is_granted"="has_role('ROLE_USER')"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access_control too.

Amrouche Hamza added 2 commits September 8, 2017 16:38
core/security.md Outdated
}
```

This exemple is going to allow only fetching the book related to the current user. if he tries to fetch a book that is linked to his account, that will not return the resource. In addition, only admins are are able to create books which means that a user could not create a book.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are are able areuh areuh?

@meyerbaptiste
Copy link
Member

core/security.md Outdated
public $title;

/**
* @ORM\Column(type="text")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be string or a relation.

Amrouche Hamza added 3 commits September 8, 2017 17:02
@meyerbaptiste meyerbaptiste merged commit fd0f21e into master Sep 8, 2017
@meyerbaptiste meyerbaptiste deleted the feature/add-security branch September 8, 2017 15:11
meyerbaptiste pushed a commit to meyerbaptiste/doc that referenced this pull request Sep 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants