sunkan / aws-auth-policy
Library to help with generating auth policies for AWS Gateway API Authorizers
Installs: 5 304
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^11.0
README
Installation
$ composer require sunkan/aws-auth-policy
Usage
use Sunkan\AwsAuthPolicy\AuthPolicy; $policy = new AuthPolicy( 'me', '50505050', [ 'region' => 'eu-west-1', 'stage' => 'prod', ], ); $policy->allowAll(); echo json_encode($policy->build());
Usage with Bref
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; } }