CodeIgniter Forums
How to protect a route if using shield ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: How to protect a route if using shield ? (/showthread.php?tid=85245)



How to protect a route if using shield ? - kikloo - 12-09-2022

Hi,
I'm new to CI4. I'm trying to make a simple website with admin backend and just installed shield.
How can I protect the /admin route using shield ?
It seems shield is also new and much documentation is not available.
Can anyone please guide / help ?
Thanks in advance.


RE: How to protect a route if using shield ? - datamweb - 12-09-2022

Hi, to protect /admin refer to the method explained here:
https://codeigniter4.github.io/shield/install/#protect-all-pages

Documents are available here:
https://codeigniter4.github.io/shield

Use https://github.com/codeigniter4/shield/discussions if you need to ask a question.


RE: How to protect a route if using shield ? - kikloo - 12-10-2022

Hi,

When I do the following:

---
$routes->get('admin', ' App\Controllers\Admin\Admin::index', ['filter' => 'admin-auth']);
---

I get error:

---
CodeIgniter\Filters\Exceptions\FilterException #3
admin-auth filter must have a matching alias defined.
---

Any help ?

Thanks.


RE: How to protect a route if using shield ? - datamweb - 12-11-2022

What is admin-auth?!

Shield currently has six filters, session, tokens, chained , auth-rates, permission and group.

You can use it as follows:

PHP Code:
$routes->get('/admin''Admin\Admin::index' ,['filter' => 'session']); 

I edited this post, added two new filters permission and group in the development branch. Also, spelling mistake sessions was corrected.