jetcod / laravel-iam-db-auth
AWS IAM db auth package for laravel
1.0.0
2024-03-22 14:55 UTC
Requires
- php: ^8.0
- ext-pdo: *
- aws/aws-sdk-php-laravel: ^3.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.49
- laravel/framework: ^9.0|^10.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.0|^10.0|^11.0
This package is not auto-updated.
Last update: 2024-12-17 10:41:31 UTC
README
This is a package to connect Laravel with a AWS RDS instance using IAM authentication.
It includes a service provider that gives the framework our overridden MySQL/PGSQL connector class when it asks for an MySQL/PGSQL connection.
Installation
require this package with composer:
composer require jetcod/laravel-iam-db-auth
Add a missing variables in connection to the config array in config/database.php
<?php [ 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'database_name'), 'username' => env('DB_USERNAME', 'database_username'), 'password' => '', 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'strict' => false, 'engine' => null, 'aws_region' => env('AWS_REGION'), 'use_iam_auth' => env('DB_USE_IAM_AUTH', true), 'options' => array( 'MYSQLI_READ_DEFAULT_FILE' => env('MYSQL_CNF_FILE', '/path/to/cnf/file'), PDO::MYSQL_ATTR_SSL_CA => base_path('vendor/pixelvide/laravel-iam-db-auth/certs/rds-ca-2019-root.pem'), ), ], ];
<?php [ 'pgsql' => [ 'driver' => 'pgsql', 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'database_name'), 'username' => env('DB_USERNAME', 'database_username'), 'password' => '', 'charset' => 'utf8mb4', 'aws_region' => env('AWS_REGION'), 'use_iam_auth' => env('DB_USE_IAM_AUTH', true), 'options' => array( PDO::ATTR_PERSISTENT => env('DB_PERSISTENT', false), ), ], ];
Obtain the rds-combined-ca-bundle.pem from https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html