einfallstoll / express-ntlm

An express middleware to have basic NTLM-authentication in node.js.
BSD 2-Clause "Simplified" License
89 stars 26 forks source link

Skip ntlm auth in some cases in same url #90

Closed baur closed 2 years ago

baur commented 2 years ago

Hi, Cant I skip NTLM auth in some cases in the same URL

For example

const auth = require("./ldap");
...
app.get('/Link/:LinkGUID', auth.ldap, asyncHandler(async (req, res) => {
...
const ldap = ntlm({
  check: function (request, response, next) {
             if (req.params.LinkGUID === "cef184e1-d49f-46a6-bd5d-5f765a6eb993") {
                   next()}
             },
  domain: "domen",
  domaincontroller: "ldap://server",
});
baur commented 2 years ago

or

const ldap = ntlm({
  check: function (request, response, next) {
               if (res.locals.SkipNTLM) {next()}
             }
  domain: "domen",
  domaincontroller: "ldap://server",
});
baur commented 2 years ago

anyway I'd like to skip NTLM in some cases (same route)

einfallstoll commented 2 years ago

You can skip the module whenever you want (just don't add it as a middleware). This is not something that needs to be built into this module.