Angular / Express SSO authentication error

1

I have a local server made with express and angular 9 for client side. I try to authenticate using a npm module called node-expose-sspi but I always get 401 Unauthorized with error:

UnauthorizedError: Error while doing SSO: AcceptSecurityContext: SECURITY_STATUS incorrect (<0): (error code: 0x80090308) The token supplied to the function is invalid

Angular request

this.http.get("/api/auth/sso", {
  withCredentials: true,
});

Angular proxy.config file

{
  "/api/*": {
    "target": "https://localhost:3000",
    "secure": false
  }
}

Express server (https)

app.use(cors({ credentials: true, origin: true }));
app.use(express.json());

app.enable("trust proxy");
app.use(function (req, res, next) {
  if (req.secure) {
    next();
  } else {
    res.redirect("https://" + req.headers.host + req.url);
  }
});
app.use(helmet());

app.get("/sso", sso.auth(), async (req, res) => {
  try {
    return res.send("Success");
  } catch (error) {
    return res.status(400).send("Error");
  }
});

Note that if I use this express server with a diferent client(a plain index.html file with a fetch script inside) it works fine.

angular
express
authentication
single-sign-on
asked on Stack Overflow Feb 25, 2021 by Cata John

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0