Repository navigation
Extension Points
This page is the reference of what a plugin can change in KeyAnyWhere without touching the core: configuration keys under Kaw.*, services in the dependency container, events, and API routes. Each entry says what it does and shows a minimal example.
A plugin writes a Kaw.* key in its bootstrap() (or config/bootstrap.php) only when the key isn't set yet:
if (!Configure::check('Kaw.Login.elementos')) {
Configure::write('Kaw.Login.elementos', ['MyPlugin.help']);
}That way the installation's config/app_local.php, which is loaded before any plugin's bootstrap, can still override it. The core's own tests rely on the same rule.
| Key | Type | Effect |
|---|---|---|
Kaw.Menu.configuracoes |
list of menu items | Adds items to the administrator-only Configurações section of the menu. |
Kaw.Menu.outros |
list of menu items | Adds items to an Outros (Other) section, shown only when it has items. |
Kaw.Login.elementos |
list of element names | Elements rendered below the login form, such as a help link. |
Kaw.Layout.avisos |
list of element names | Elements rendered above the content of every page, such as a maintenance notice. |
Kaw.Configuracoes.regionalEditavel |
bool (default true) |
false hides Configurações gerais and makes its actions redirect home, for installations whose time zone and language are set by something else. |
Kaw.Seguranca.csp |
array of directive ⇒ sources | Extra sources added to the default Content-Security-Policy, per directive, for example ['script-src' => ['https://js.example.com'], 'frame-src' => ['https://frame.example.com']]. Production only, like the CSP itself. |
Kaw.ConfigInicial.urlRecusa |
string or route array | Where to send a visitor refused by the first-run setup, instead of the plain 403, for example a page that explains how to get the token. |
A menu item is an array:
[
'url' => ['plugin' => 'MyPlugin', 'controller' => 'Reports', 'action' => 'index'], // or a string
'icone' => 'bi-graph-up', // a Bootstrap Icons class
'rotulo' => 'Relatórios', // translated with __d($dominio, $rotulo)
'dominio' => 'default', // translation domain
'somenteRoot' => false, // true: only administrators see it
]Application::services() registers two interfaces in CakePHP's dependency container. A plugin replaces the implementation in its own services():
public function services(ContainerInterface $container): void
{
$container->extend(VerificadorSenhaInseguraInterface::class)
->setConcrete(MyPasswordChecker::class);
}| Interface | Default | Used by |
|---|---|---|
App\Service\VerificadorSenhaInseguraInterface |
VerificadorSenhaInseguraTabela: looks the password up in the insecure_passwords table. |
The insecure password warning of the entry form (EntradasController::senhaInsegura()). |
App\Service\AutorizadorConfigInicialInterface |
AutorizadorConfigInicialToken: allows only whoever opened the setup with the installation's CONFIG_INICIAL_TOKEN (or ConfigInicial.token in Configure), at least 32 characters. |
The first-run setup (UsersController::configInicial() and configInicialTfa()). |
Both events are dispatched on CakePHP's global event manager, for example from a plugin's events(). Each can fire more than once (on every visit to the page), so listeners must be idempotent.
| Constant | Name | When |
|---|---|---|
UsersController::EVENTO_CONFIG_INICIAL_INICIO |
Kaw.ConfigInicial.inicio |
The first step of the first-run setup opens while the system has no configured user. |
UsersController::EVENTO_CONFIG_INICIAL_SEGUNDO_FATOR |
Kaw.ConfigInicial.segundoFator |
The 2FA step opens; the first user is in $event->getData('user'). |
The core has no API, but it treats every path that is /api or starts with /api/ as an API route, so a plugin can add one in its routes():
- authentication is by token, not by the session cookie, so these routes skip CSRF and are never redirected to the login page;
- errors are answered as JSON,
{"mensagem": "..."}, even for an/api/...path that has no route.
The plugin is responsible for authenticating the token.
Source code · Issues · Releases · Packagist · Online demo · Hosted edition
1. Getting started
2. Installing in production
- Overview
- Preparing the Server
- Installing KeyAnyWhere
- File Permissions
- Generating Security Keys
- Environment Variables
- Configuration Files
- Database Setup
- Insecure Password Catalog
- Web Server and HTTPS
- First-Run Setup
3. Operating your installation
4. Using KeyAnyWhere
5. Security
6. Development
7. Extending