API authentication
The Tancredi administrative API does not implement an authentication method by itself, but it is possible to plug in a custom one:
In the
/etc/tancredi.conf
configuration file specify the authentication class name. For instance typeauth_class = "MyAuth"
.Put a file
MyAuth.php
in thesrc/Entity
directory. This is an example class:<?php namespace Tancredi\Entity; class MyAuth { private $config; public function __construct($config = null) { // You can use configuration file variables here $this->config = $config; } public function __invoke($request, $response, $next) { if ($request->hasHeader('foo') and $request->getHeaderLine('foo') === 'bar') { $response = $next($request, $response); } else { return $response->withStatus(403); } } }