Welcome Guest, Not a member yet? Register   Sign In
How to protect a route if using shield ?
#1

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.
Reply
#2

Hi, to protect /admin refer to the method explained here:
https://codeigniter4.github.io/shield/in...-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.
Reply
#3

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.
Reply
#4

(This post was last modified: 12-30-2022, 06:12 AM by datamweb.)

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB