Skip to content

thasmo/kirby.webhooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webhooks-Plugin for Kirby

Push Kirby hook events to HTTP endpoints.

GitHub Release License


About

The Kirby webhooks-plugin will send a POST request to the configured HTTP endpoints holding a application/json body with the hook name, the user-data of the user who triggered the hook and the actual page data including a diff with the old page data.

  • hook holds the name of the triggered hook.
  • host holds the hostname from where the request originated.
  • user holds the data of the user who triggered the hook.
  • data holds the new page data.
  • diff holds the page's old page data which changed.

Example of the Request-Body (shortened)

{
    "hook": "panel.page.update",
    "host": "127.0.0.1",
    "user": {
        "username": "user",
        "email": "user@domain.tld",
        "language": "en",
        "role": "admin",
        "firstname": "first",
        "lastname":" last",
        "history": []
    },
    "data":{
        "id": "page/subpage",
        "title": "Subpage",
        "content": {
            "name": "New name!"
        }
    },
    "diff": {
        "content": {
            "name": "Old name."
        }
    }
}

Installation

Choose your preferred installation method below and enable the plugin in the configuration.

Kirby CLI

kirby plugin:install thasmo/kirby.webhooks

Composer

{
    "name": "my-kirby-installation",
    "require": {
        "mnsami/composer-custom-directory-installer": "1.0.*",
        "thasmo/kirby.webhooks": "0.1.0"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "thasmo/kirby.webhooks",
                "version": "0.1.0",
                "source": {
                    "type": "git",
                    "url": "https://github.com/thasmo/kirby.webhooks.git",
                    "reference": "v0.1.0"
                }
            }
        }
    ],
    "extra": {
        "installer-paths": {
            "./site/plugins/webhooks": ["thasmo/kirby.webhooks"]
        }
    }
}

Manual

Download the latest release and unpack it to site/plugins/webhooks.

Usage

Configuration

webhooks required, default: false
Enable the webhooks-plugin.

c::set('webhooks', true);

webhooks.endpoints required default: null
Define HTTP endpoints.

c::set('webhooks.endpoints', [
    'http://domain-1.com/all-events/',
    'http://domain-2.com/page-events-only/' => ['panel.page'],
    'http://domain-3.com/user-events-only/' => ['panel.user'],
]);

webhooks.blacklist optional, default: ['password', 'secret']
Set property-names which should not be passed to the endpoints.

c::set('webhooks.blacklist', ['password', 'secret', 'email']);

forthebadge

About

Push Kirby hook events to HTTP endpoints.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages