Configuring PHP Middleware for API Requests

Viewed 26

I have been having success in implementing my new API based on the mevdschee/php-crud-api package. I have been stuck on the issue of configuring the best API Key method for Authentication. In the below code I am trying to configure the use of an API Key and setting the key on the apiKeyAuth.keys parameter. Using Postman, my API works but when using API Key authentication it will not accept my API key. It may be that my syntax is wrong but any direction is appreciated.

PHP Code to config API (values taken out for security):

$config = new Config([
        'driver' => 'mysql',
        'address' => 'localhost',
        'port' => 'PORT_NUMBER',
        'username' => 'DATABSE_USERNAME',
        'password' => 'DATABSE_PASS',
        'database' => 'DATABASE_NAME',
        'debug' => true,
        'tables' => 'TABLES_ALLOWED',
        'middlewares' => 'apiKeyAuth',
        'apiKeyAuth.keys' => 'MY_API_KEY',
    ]);
0 Answers
Related