Welcome Guest, Not a member yet? Register   Sign In
Multi-level routing filters not working
#1

(This post was last modified: 11-28-2024, 12:45 AM by WitER.)

Good day!
I want restrict routing groups by shield permissions , but filter working only for parent group. In children groups permission filter not working. Where my bad?
CI 4.5.5 \ Shield 1.1.0

PHP Code:
$routes->group('admin', ['filter' => 'permission:admin.access'], static function (RouteCollection $routes) { // permission:admin.access is working
    $routes->get('/''Admin::index', ['as' => 'admin']);

    $routes->group('users', ['filter' => 'permission:users.access'], static function (RouteCollection $routes) { // permission:users.access is ignoring
        $routes->get('/''Auth\Users::index', ['as' => 'admin-users']);
    });
}); 
Reply
#2

Code:
For this to work you have to enable multiple filters in Config/Feature.php
PHP Code:
public bool $multipleFilters true
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(11-28-2024, 09:55 PM)InsiteFX Wrote:
Code:
For this to work you have to enable multiple filters in Config/Feature.php
PHP Code:
public bool $multipleFilters true

It's not work for me, and search by multipleFilters in project or vendor directory not founding any using for this parameter.
Maybe there are any other ideas? Or is there something wrong with my configuration in principle?
Reply
#4

!Important

Since v4.5.0, Multiple Filters are always enabled. Prior to v4.5.0, Multiple Filters were disabled by
default. If you want to use with prior to v4.5.0, See Upgrading from 4.1.4 to 4.1.5 for the details.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(This post was last modified: 11-30-2024, 03:36 AM by WitER.)

(11-29-2024, 10:29 PM)InsiteFX Wrote: !Important

Since v4.5.0, Multiple Filters are always enabled. Prior to v4.5.0, Multiple Filters were disabled by
default. If you want to use with prior to v4.5.0, See Upgrading from 4.1.4 to 4.1.5 for the details.

Yep, but i created project from v4.5.0, now 4.5.5 and filters for nested routing groups does not work.
Reply
#6

If you think there is a problem then open up an issue on GitHub for it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

See in console or test controller command():
spark routes
spark filter:check /users
https://codeigniter.com/user_guide/incom...lter-check
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#8

(12-01-2024, 09:26 PM)ozornick Wrote: See in console or test controller command():
spark routes
spark filter:check /users
https://codeigniter.com/user_guide/incom...lter-check

spark routes
Code:
CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-12-02 11:47:12 UTC+00:00

+--------+------------------------------+-------------------------------------+--------------------------------------------------------------------+------------------------------------+-----------------------+
| Method | Route                        | Name                                | Handler                                                            | Before Filters                    | After Filters        |
+--------+------------------------------+-------------------------------------+--------------------------------------------------------------------+------------------------------------+-----------------------+
| GET    | /                            | main                                | \App\Controllers\Home::index                                      | csrf                              |                      |
| GET    | profile                      | »                                  | \App\Controllers\Auth\Profile::index                              | csrf session session              | session              |
| GET    | profile/(.*)                | profile-tab                        | \App\Controllers\Auth\Profile::index/$1                            | csrf session session              | session              |
| GET    | admin                        | »                                  | \App\Controllers\Admin::index                                      | csrf session permission            | permission            |
| GET    | admin/users                  | admin-users                        | \App\Controllers\Auth\Users::index                                | csrf session permission permission | permission permission |
| GET    | register                    | »                                  | \CodeIgniter\Shield\Controllers\RegisterController::registerView  | csrf auth-rates                    |                      |
| GET    | login                        | »                                  | \CodeIgniter\Shield\Controllers\LoginController::loginView        | csrf auth-rates                    |                      |
| GET    | login/magic-link            | magic-link                          | \CodeIgniter\Shield\Controllers\MagicLinkController::loginView    | csrf auth-rates                    |                      |
| GET    | login/verify-magic-link      | verify-magic-link                  | \CodeIgniter\Shield\Controllers\MagicLinkController::verify        | csrf auth-rates                    |                      |
| GET    | logout                      | »                                  | \CodeIgniter\Shield\Controllers\LoginController::logoutAction      | csrf                              |                      |
| GET    | auth/a/show                  | auth-action-show                    | \CodeIgniter\Shield\Controllers\ActionController::show            | csrf auth-rates                    |                      |
| POST  | profile/update              | update-profile                      | \App\Controllers\Auth\Profile::update                              | csrf session session              | session              |
| POST  | profile/change-password      | update-profile-password            | \App\Controllers\Auth\Profile::changePassword                      | csrf session session              | session              |
| POST  | profile/toggle-2fa          | update-profile-2fa                  | \App\Controllers\Auth\Profile::toggle2FA                          | csrf session session              | session              |
| POST  | profile/purge-remember-token | update-profile-purge-remember-token | \App\Controllers\Auth\Profile::purgeRememberToken                  | csrf session session              | session              |
| POST  | register                    | »                                  | \CodeIgniter\Shield\Controllers\RegisterController::registerAction | csrf auth-rates                    |                      |
| POST  | login                        | »                                  | \CodeIgniter\Shield\Controllers\LoginController::loginAction      | csrf auth-rates                    |                      |
| POST  | login/magic-link            | »                                  | \CodeIgniter\Shield\Controllers\MagicLinkController::loginAction  | csrf auth-rates                    |                      |
| POST  | auth/a/handle                | auth-action-handle                  | \CodeIgniter\Shield\Controllers\ActionController::handle          | csrf auth-rates                    |                      |
| POST  | auth/a/verify                | auth-action-verify                  | \CodeIgniter\Shield\Controllers\ActionController::verify          | csrf auth-rates                    |                      |
+--------+------------------------------+-------------------------------------+--------------------------------------------------------------------+------------------------------------+-----------------------+

and check
Code:
php spark filter:check GET /admin/users/

CodeIgniter v4.5.5 Command Line Tool - Server Time: 2024-12-02 11:48:42 UTC+00:00

+--------+---------------+---------------------------------------------------------+-----------------------------------------------------+
| Method | Route        | Before Filters                                          | After Filters                                      |
+--------+---------------+---------------------------------------------------------+-----------------------------------------------------+
| GET    | /admin/users/ | forcehttps pagecache csrf session permission permission | permission permission pagecache performance toolbar |
+--------+---------------+---------------------------------------------------------+-----------------------------------------------------+
Reply




Theme © iAndrew 2016 - Forum software by © MyBB