Skip to content
Protect pages for authenticated users
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github adjust default login page behavior May 28, 2019
blueprints/fields some labels adjusted Jun 3, 2019
examples/site/blueprints examples added May 23, 2019
src loginform artefacts moved in subfolder May 29, 2019
vendor kirby-uniform added May 28, 2019
.buildpath
.editorconfig Template import May 16, 2019
.gitattributes update gitattributes to ignore .github folder May 28, 2019
.gitignore pdated to be prepared for composer dependency May 28, 2019
.project Template import May 16, 2019
LICENSE.md Template import May 16, 2019
README.md version update Jun 3, 2019
composer.json version update Jun 3, 2019
composer.lock kirby-uniform added May 28, 2019
index.php loginform artefacts moved in subfolder May 29, 2019

README.md

Kirby Secured Pages

Version License Kirby

With this plugin for Kirby CMS you can prevent unauthorized users to access a page or a hierarchy of pages. The permission will be granted by a user group. If the user is not yet logged in, a login page will be displayed.

Requirements

  • Kirby CMS, Version 3.x

Installation

Download

Download and extract this repository, rename the folder to securedpages and drop it into the plugins folder of your Kirby 3 installation. You should end up with a folder structure like this:

site/plugins/securedpages/

Composer

If you are using Composer, you can install the plugin with

composer require kerli81/securedpages

Git submodule

git submodule add https://github.com/kerli81/kerby-securedpages.git site/plugins/securedpages

Usage

Blueprint

To enable the configuration for the page security your blueprint needs to include the security field. Here an example ho such a page blueprint could look like.

title: Protected Page

columns:
  # main
  - width: 2/3
    sections:
      content:
        type: fields
        fields:
          text:
            text:
            type: textarea
            size: large
            
  # sidebar
  - width: 1/3
    sections:
        securityconfig:
            type: fields
            fields:
                security: fields/kerli81.securedpages.pageconfiguration
        pages:
            type: pages
        files:
            type: files

Template

User Group

The plugin will check if a user is part of a certain user group. To create such a group, create a *.yml file in folder blueprints/users/. You will find below an example of a group definition.

title: Webpage Access
description: Usergroup for frontend access

permissions:
  access:
    panel: false

To use the group create a new user on the panel.

Secure a page incl. sub pages

Go to the page which you will protected and enable the protection. After you enabled it a user group selction field will be displayed. Select the just defined group.

Protection Configuration

Options

Default Behavior

If you navigate to a page which is protected and you are not logged in or your user is not part of the correct user group, your request is forwarded to /no-permission. On this page a login form will be displayed. After correct login you will be forward to your requested page.

Adjust texts of default behavior

to adjust the texts just override the provided options:

Option Default Description
kerli81.securedpages.loginform.username.name Username Name of the field 'username'
kerli81.securedpages.loginform.username.error Please enter your username Error message for the field 'username'
kerli81.securedpages.loginform.password.name Password Name of the field 'password'
kerli81.securedpages.loginform.password.error Please enter your password Error message for the field 'password'

Login Form

display another error page

If you would like to show your custom error page, just update following options:

Option Value Description
kerli81.securedpages.logintype custom Will trigger the page to display. Possible values are: [loginform, custom]
kerli81.securedpages.custom.page --- The url (url-slug) to navigate to.
You can’t perform that action at this time.