tuupola / slim-basic-auth

PSR-7 and PSR-15 HTTP Basic Authentication Middleware
MIT License
440 stars 66 forks source link

401 error in postman #87

Closed mixtapeco closed 4 years ago

mixtapeco commented 4 years ago

Having trouble implementing this.

Here's my middleware setup:

`use Slim\App;

return function (App $app) { $app->options('/{routes:.+}', function ($request, $response, $args) { return $response; });

$app->add(new Tuupola\Middleware\HttpBasicAuthentication([
    "users" => [
        "root" => '$2y$10$1lwCIlqktFZwEBIppL4ak.I1AHxjoKy9stLnbedwVMrt92aGz82.O',
        "somebody" => '$2y$10$6/vGXuMUoRlJUeDN.bUWduge4GhQbgPkm6pfyGxwgEWT0vEkHKBUW'
    ],
]));

$app->add(function ($req, $res, $next) {
    $response = $next($req, $res);
    return $response
            ->withHeader('Access-Control-Allow-Origin', '*')
            ->withHeader('Access-Control-Expose-Headers', '*')
            ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Accept, Origin, Authorization')
            ->withHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
});

}; `

Trying to use basic auth username and password that matches "root" => "$2y$10$1lwCIlqktFZwEBIppL4ak.I1AHxjoKy9stLnbedwVMrt92aGz82.O"

Screenshot 2019-12-06 09 46 07
tuupola commented 4 years ago

You need to submit the cleartext password not the password hash.

mixtapeco commented 4 years ago

Thank you so much for responding! It worked right away.

tuupola commented 4 years ago

No problem :)