Skip to content

Conversation

@datamweb
Copy link
Collaborator

Hello friends.
We have answered how to protect routes by several users in several discussions.
However, I recently received a similar message about how to protect the site panel.
I have covered this topic in this PR.

@datamweb
Copy link
Collaborator Author

datamweb commented Sep 10, 2022

Actually, I wanted to make the route protection more understandable by changing the session filter, but I think you disagree with this change. So I did nothing.

if (url_is('login*') || url_is('register*')){
    return;
}

Restrict Admin's Routes

For example, if you want to limit all routes leading to localhost:8080/admin and localhost:8080/panel, you need to add the following code in the app\Config\Filters.php file.

public $filters = [
    'session' => [
        'before' => [
            'admin*', 
            'panel*',
        ]
    ]
];

@datamweb datamweb added the documentation Improvements or additions to documentation label Sep 10, 2022
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kenjis kenjis merged commit 90c5eec into codeigniter4:develop Sep 14, 2022
@datamweb datamweb deleted the add-set-filter branch September 14, 2022 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants