Add security to demo

Open
#1 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php, symfony

Research direction

Start by reviewing the demo's current dashboard permission setup and its User, Post, and Comment voter entry points. Compare the requested ROLE_ADMIN, record-owner, and edit permissions with the existing configuration, then verify that the demo demonstrates the intended behavior and explains whether voters or the expression language are used.

Written by the indexing model from the issue text.

Description

I quite like the demo for seeing "Best Practices" of now to configure EasyAdmin, thanks for releasing it and the package itself.

I think it'd be great to see the demo with a more complete security setup. What I'd like to see is

  • Anyone can view the dashboard, subject to the ->setPermission()
  • ROLE_ADMIN can do anything
  • USER_EDIT permissions are granted for ROLE_ADMIN and when the user record email matches the logged in user's email.
  • POST_EDIT -- only ROLE_ADMIN and POST_EDIT
  • COMMENT_EDIT -- configure COMMENT_EDIT in CommentVoter to be ROLE_ADMIN or comment->getUser->getEmail === $user->getEmail()

At least that's the way I'm configuring my voters. Perhaps there's a better way?

It's possible that using the expression language is sufficient and and the Voter is overkill, though I quite like the Symfony Voter system, and of course it integrates beautifully with EasyAdmin.

Mostly I'm looking for more examples and best practices.

Thanks.

Dominant language
PHP
Stars
18
Forks
9
Avg merge
4h 35m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EasyCorp/easyadmin-demo

All issues in EasyCorp/easyadmin-demo

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.