Skip to content

[Proposal] Implement per-operation access control rules #234

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

Closed
wants to merge 1 commit into from

Conversation

teohhanhui
Copy link
Contributor

Using Security expressions to control access to each operation.

# app/config/services.yml
services:
    resource.product:
        parent: api.resource
        arguments:
            - AppBundle\Entity\Product
        calls:
            - method: initAccessControlRules
              arguments:
                  - collection:
                        POST: "has_role('ROLE_ADMIN')"
                    item:
                        PUT: "has_role('ROLE_ADMIN')"
                        DELETE: "has_role('ROLE_ADMIN')"
        tags:
            - name: api.resource

@dunglas
Copy link
Member

dunglas commented Aug 19, 2015

Interesting approach. However I'll refactor the resource and operation system (they will be moved in the metadata system).
IMO the rule must be related to the operation and not to the resource.

@teohhanhui
Copy link
Contributor Author

That will be ideal, but it doesn't make sense for me to recreate each and every default operation (tens or hundreds of them). Of course, that's #142

@teohhanhui
Copy link
Contributor Author

I guess I'll wait until after your refactoring is complete. In the meantime, my needs are simple enough to be served by hardcoded logic in a single listener.

@sroze
Copy link
Contributor

sroze commented Aug 19, 2015

Even if I'm not fond of the expression component, I like the idea too 👍

@teohhanhui
Copy link
Contributor Author

@sroze Why? Isn't it essentially DSL? Or at least afford you to create your own DSL easily? You can give your user just enough flexibility without having to account for every possible use case (a rather impossible task).

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.

3 participants