To use this plugin's auth setup, do the following.
Enable the auth setup in your configuration data:
- Copy this plugin's
config/datacenter.php
configuration file to the app'sconfig
directory - Update the app's copy of the file so that the
DataCenter.auth.enabled
value istrue
Add to src/Application.php
:
use DataCenter\Plugin as DataCenterPlugin;
use Authentication\AuthenticationServiceInterface;
use Authentication\AuthenticationServiceProviderInterface;
use Authorization\AuthorizationServiceInterface;
use Authorization\AuthorizationServiceProviderInterface;
use Psr\Http\Message\ServerRequestInterface;
class Application extends BaseApplication implements
AuthenticationServiceProviderInterface,
AuthorizationServiceProviderInterface
/**
* Returns the authorization service
*
* @param \Psr\Http\Message\ServerRequestInterface $request Server request
* @return \Authorization\AuthorizationServiceInterface
*/
public function getAuthorizationService(ServerRequestInterface $request): AuthorizationServiceInterface
{
return DataCenterPlugin::getAuthorizationService($request);
}
/**
* Returns a service provider instance.
*
* @param \Psr\Http\Message\ServerRequestInterface $request Request
* @return \Authentication\AuthenticationServiceInterface
*/
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
{
return DataCenterPlugin::getAuthenticationService($request);
}
- Have
UsersController
extendDataCenter\Controller\UsersController
- In each controller with publicly-accessible actions, list those action names in a class constant called
ALLOW
, e.g.public const ALLOW = ['index', 'view'];
- Have the
User
class extendDataCenter\Model\Entity\User
- Have the
UsersTable
class extendDataCenter\Model\Table\UsersTable
To override the templates for UsersController
actions managed by the plugin (such as the login page), create files in
the application such as this:
templates/plugin/DataCenter/Users/login.php