1. Go to this page and download the library: Download deadmerc/rabbitmq-auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$authenticationChecker = new ChainAuthenticationChecker(array(
new UserPasswordTokenChecker(), // Check the username AND the password, during the authentication process
new UserTokenChecker(), // Check only username, append with topic, vhost, resource action
));
$authenticator = new Authenticator(
$userProvider,
$authenticationChecker
);
$authenticationManager = new AuthenticationProviderManager(array($authenticator));
$defaultVoter = new DefaultVoter(array(
'admin' => array(
'isAdmin' => true,
),
'user-1' => array(
'/' => array(
'ip' => '.*', // to control the vhost ip access
'read' => '.*', // to control the resource/topic read access
'write' => '.*', // to control the resource/topic write access
'configure' => '.*', // to control the resource/topic configure access
),
),
));
$accessDecisionManager = new AccessDecisionManager(array($defaultVoter));
$tokenStorage = new TokenStorage();
$authorizationChecker = new AuthorizationChecker(
$tokenStorage,
$authenticationManager,
$accessDecisionManager
);