Code Monkey home page Code Monkey logo

Comments (3)

ildyria avatar ildyria commented on August 19, 2024

@agademer

Could you please double check your finding? Especially that:

  • users have may_upload=0
  • users do not have upload rights to root directory
  • users do not have edit rights to shared directory

class AddPhotoRequest extends BaseApiRequest implements HasAbstractAlbum
{
use HasAbstractAlbumTrait;
use AuthorizeCanEditAlbumTrait;

Ensures the Authorization.

trait AuthorizeCanEditAlbumTrait
{
/**
* {@inheritDoc}
*/
public function authorize(): bool
{
return Gate::check(AlbumPolicy::CAN_EDIT, [AbstractAlbum::class, $this->album]);

This calls the policy:

public function canEdit(User $user, AbstractAlbum|null $album): bool
{
// The root album and smart albums get a pass
if ($album === null || $album instanceof BaseSmartAlbum) {
return $user->may_upload;
}
if ($album instanceof BaseAlbum) {
return $this->isOwner($user, $album) ||
$album->current_user_permissions()?->grants_edit === true ||
$album->public_permissions()?->grants_edit === true;
}
return false;

I don't see any error in the code or I am missing an edge case.
Only thing I could think of is that the token would be giving admin perm instead of user perm which would be seriously worrisome.

from lychee.

agademer avatar agademer commented on August 19, 2024

from lychee.

ildyria avatar ildyria commented on August 19, 2024

Hope this helps,

A LOT!
By creating the album the user get ownership, and as a result uploads rights:

$this->isOwner($user, $album)

Hummmm.

from lychee.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.