Skip to content
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

Bug: permission filter ignored on modules #640

Open
bedrijfsportaal opened this issue Feb 15, 2023 · 6 comments
Open

Bug: permission filter ignored on modules #640

bedrijfsportaal opened this issue Feb 15, 2023 · 6 comments
Labels
waiting for info Issues or pull requests that need further clarification from the author

Comments

@bedrijfsportaal
Copy link

bedrijfsportaal commented Feb 15, 2023

PHP Version

8.1.6

CodeIgniter4 Version

4.3.1

Shield Version

latest commit

Which operating systems have you tested for this bug?

Windows (happens on server Linux as well)

Which server did you use?

cli-server (PHP built-in webserver)

Database

MariaDB 10.4.24

Did you customize Shield?

No

What happened?

The filters in my module doesn't seem to be working on permission the filter group is working as expected.

Steps to Reproduce

Working from App directory like below:

  • App\Addons\Woocommerce\Config\Routes.php
  • The filter permission is set like normally the case would be ['filter' => 'permission:beta.access']
  • Just noticed this on the current commit, don't know since when this is broken.

From this point nothing is done, checking the filter in routes from spark command results

image

Expected Output

The filter to be working on the routes when set from own directory.

Anything else?

No response

@bedrijfsportaal bedrijfsportaal added the bug Something isn't working label Feb 15, 2023
@bedrijfsportaal
Copy link
Author

I think i've found the issue/solution for this:

  • Inside CodeIgniter4\shield\src\Filters\PermissionFilter.php
  • On checking with if (auth()->user()->can($permission)) { } this fails.
  • On checking with if (auth()->user()->hasPermission($permission)) { } this works.

The only problem with this, according to the docs, it disregards any groups if they are a part of it.

@kenjis kenjis added bug Something isn't working and removed bug Something isn't working labels Mar 14, 2023
@kenjis
Copy link
Member

kenjis commented Mar 14, 2023

It seems if hasPermission($permission) returns true, can($permission) also returns true.

And if hasPermission($permission) works, the filter defined in the module is working.

@kenjis kenjis removed the bug Something isn't working label Apr 26, 2023
@kenjis
Copy link
Member

kenjis commented Sep 19, 2023

@bedrijfsportaal Do you still have this issue?

@kenjis kenjis added the waiting for info Issues or pull requests that need further clarification from the author label Sep 19, 2023
@bedrijfsportaal
Copy link
Author

bedrijfsportaal commented Sep 25, 2023 via email

@datamweb
Copy link
Collaborator

I offer my condolences on behalf of Codeigniter community.
Rest in peace.

@mshannaq
Copy link
Contributor

mshannaq commented Oct 8, 2023

@bedrijfsportaal
this makes me sad . my condolences
Rest in peace.
😔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for info Issues or pull requests that need further clarification from the author
Projects
None yet
Development

No branches or pull requests

4 participants