LionC / express-basic-auth

Plug & play basic auth middleware for express
325 stars 57 forks source link

Add login request on authorizer #55

Closed ViniMnzs closed 9 months ago

ViniMnzs commented 1 year ago

I need to setup a login request with axios as authentication method inside the express-basic-auth, to access my swagger. Is it possible? How can I do it? I tried with authorizer, but failed.

example:

app.use(['/${SWAGGER_API_PATH}'], basicAuth({ authorizer: myAuthorizer })); ` function myAuthorizer(username, password) { const response = axios.post('http://localhost:3000/api/auth', {username, password});`

if(response.status === 200){ return true; }; else{ return false; } };

LionC commented 9 months ago

Check the readme on how to do asynchronous authorizers.