Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using passport-windowsauth locally #61

Open
ndomenic opened this issue Jul 3, 2019 · 0 comments
Open

Using passport-windowsauth locally #61

ndomenic opened this issue Jul 3, 2019 · 0 comments

Comments

@ndomenic
Copy link

ndomenic commented Jul 3, 2019

I have tried to get passport-windowsauth to work locally on my machine, however I am continually getting Unauthorized when trying to get from my test endpoint. This works fine on IIS, however. Is there a way to set up so that I can still use passport-windowsauth locally? My code is as follows:

web.config

<configuration>
  <system.webServer>
    <iisnode node_env="production" promoteServerVars="LOGON_USER"/>
  </system.webServer>
</configuration>

index.js

const passport = require('passport');
const WindowsStrategy = require('passport-windowsauth');

app.use(passport.initialize());
app.use(passport.session());

passport.serializeUser(function(user, done) {
  done(null, user);
});

passport.deserializeUser(function(user, done) {
  done(null, user);
});

passport.use(new WindowsStrategy({
    integrated: true 
  }, function(profile,done) {
    var user = {
        id: profile.id,
    };
    done(null, user);
}));

app.all("*", passport.authenticate("WindowsAuthentication"), function (req, res, next){
  next();
});

app.get('/testAuth', (req, res, next) => {
  res.send(req.user.id + " is authenticated");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant