PHP code example of itinance / slim-basic-auth-pass-through

1. Go to this page and download the library: Download itinance/slim-basic-auth-pass-through 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/ */

    

itinance / slim-basic-auth-pass-through example snippets


use itinance\Middleware\PassThroughHttpBasicAuthentication

$app = new \Slim\App($config);

$app->add(new PassThroughHttpBasicAuthentication([
    "realm" => "Protected",
]));

// Define app routes
$app->post('/soapProxy/{methodName}', function (\Slim\Http\Request $request, \Slim\Http\Response $response, $args) {

    $user = $params['PHP_AUTH_USER'];
    $pass = $params['PHP_AUTH_PW'];

    // Proxy-Call to another API with Username and Password happens here
    // ...proxyCall($user, $pass, ...)
});

// Run app
$app->run();