A Laravel package to authenticate with Azure Redis using Managed Identity tokens instead of static access keys.
- The server must be using an Azure VM with Managed Identities enabled
- The VM user must have the correct permissions to access the Redis service.
- For local token caching using the database, the cache table migration must be run. It can be generated and applied with the following commands:
php artisan cache:table
php artisan migration
Add repository to composer.json
"repositories": [
{
"type": "vcs",
"url": "[email protected]:PDERAS/azure-redis.git"
},
]
composer require pderas/azure-redis
php artisan vendor:publish --provider="Pderas\AzureRedis\AzureRedisAuthServiceProvider"
Set redis.client
in config/database.php
to 'azure'. This can be done with an env variable.
// config/database.php
return [
// ...
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
// ...
],
];
Then, in your .env
REDIS_CLIENT=azure
The token generated with this package will be cached with the database driver by default. You can change this behaviour with the following env variable:
AZURE_REDIS_TOKEN_CACHE=
Note: "redis" cannot be used for this option as this will create a circular dependency
If you want to manually override these values with anything other than env variables, the config file can be published.
php artisan vendor:publish --tag=azure-redis-auth-config