Welcome Guest, Not a member yet? Register   Sign In
Let's make auto routes disable
#19

(03-25-2022, 04:44 PM)kenjis Wrote: @ChicagoPhil Okay, Good question.

See this tutorial:
https://www.binaryboxtuts.com/php-tutori...ntication/

You will create app/Controllers/User.php.

And you will define routes:
PHP Code:
$routes->group("api", function ($routes) {
    $routes->post("register""Register::index");
    $routes->post("login""Login::index");
    $routes->get("users""User::index", ['filter' => 'authFilter']);
}); 

If you will navigate to http://example.com/api/users (defined route), the authFilter will be applied.
But if you will navigate to http://example.com/user/index (auto route), the filter will not be applied.

So because the routes are defined and auto routing is on, the filter is not executed but this doesn't seem to be a vulnerability in the routing as much as a coding error. I never intended to use the before filter for the library that I'm building. My plan was to get the user status in the base controller constructor and then execute a permissions check in each method by default. That would avoid the pitfalls of using filters or auto routing?
It's the way I did things in CI3. I even added a Core folder to CI4 because I'm a dinosaur that is stuck in my ways. :-)
Reply


Messages In This Thread
Let's make auto routes disable - by kenjis - 02-21-2022, 07:45 PM
RE: Let's make auto routes disable - by iRedds - 02-21-2022, 09:54 PM
RE: Let's make auto routes disable - by kenjis - 02-21-2022, 10:42 PM
RE: Let's make auto routes disable - by InsiteFX - 02-22-2022, 02:06 AM
RE: Let's make auto routes disable - by iRedds - 02-22-2022, 02:11 AM
RE: Let's make auto routes disable - by luckmoshy - 02-22-2022, 05:26 AM
RE: Let's make auto routes disable - by kilishan - 02-22-2022, 07:25 AM
RE: Let's make auto routes disable - by kenjis - 02-22-2022, 04:25 PM
RE: Let's make auto routes disable - by kilishan - 02-22-2022, 09:43 PM
RE: Let's make auto routes disable - by seunex - 02-22-2022, 11:26 PM
RE: Let's make auto routes disable - by kenjis - 02-26-2022, 03:04 AM
RE: Let's make auto routes disable - by luckmoshy - 02-26-2022, 03:36 AM
RE: Let's make auto routes disable - by kenjis - 03-01-2022, 06:02 PM
RE: Let's make auto routes disable - by InsiteFX - 03-02-2022, 01:41 AM
RE: Let's make auto routes disable - by kenjis - 03-25-2022, 04:15 AM
RE: Let's make auto routes disable - by sneakyimp - 02-08-2023, 06:50 PM
RE: Let's make auto routes disable - by kenjis - 03-25-2022, 04:44 PM
RE: Let's make auto routes disable - by ChicagoPhil - 03-25-2022, 08:08 PM
RE: Let's make auto routes disable - by kenjis - 03-25-2022, 09:10 PM
RE: Let's make auto routes disable - by kenjis - 03-26-2022, 02:52 AM
RE: Let's make auto routes disable - by kenjis - 03-30-2022, 07:20 PM
RE: Let's make auto routes disable - by kenjis - 02-08-2023, 06:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB