1. Go to this page and download the library: Download sunkan/aws-auth-policy 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/ */
sunkan / aws-auth-policy example snippets
use Sunkan\AwsAuthPolicy\AuthPolicy;
$policy = new AuthPolicy(
'me',
'50505050',
[
'region' => 'eu-west-1',
'stage' => 'prod',
],
);
$policy->allowAll();
echo json_encode($policy->build());
use Bref\Context\Context;
use Bref\Event\Handler;
use Sunkan\AwsAuthPolicy\AuthPolicy;
final class AuthorizerAction implements Handler
{
public function handle($event, Context $context)
{
$policy = AuthPolicy::fromMethodArn($event['methodArn']);
// validate $event['authorizationToken']
if ($validToken) {
$policy->allowAll();
}
else {
$policy->denyAll();
}
return $policy;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.