1

I'm relatively new to Strongloop's Loopback.

A project I'm working on requires HTTP-Digest to use as authentication.

I have setup the ACL on the models (and endpoints). SPA client uses REST to consume services.

I'm stuck on how to use http digest auth (username:realm:password) / nonce instead of the plain login of username/password.

I still would like to use the token auth also.

I'm currently looking at the ff 3 projects though:

Any help would be appreciated! Thank you!

1 Answers1

1

You can use Express Middleware to configure HTTP authentication:

Use this node module: http-auth

Create digest-auth.js boot script in server/boot folder

var auth = require('http-auth');
var basic = auth.basic({
    realm: "<your authentication realm>",
    file: __dirname + "<path to your .htpasswd file"
});

module.exports = function (app) {
    app.use(auth.connect(basic));

    // Setup route. 
    app.get("/", (req, res) => {
        res.send("Secured resource access granted!");
    });
}

You can check more option available with "http-auth" module to use "username:realm:password" for authentication

Hope this would help you !

Nahid Ali
  • 636
  • 3
  • 11