2

Currently I have a portal page with sso authentication, the user click on a 'Sign in' button and automatically the app redirect the user to the SSO login. All this is working fine with React in the frontend and Express in the backend.

The backend code to for the authentication it´s really simple with the library passport and passport-saml.

Here's a example:

// initialize SAML auth
var samlStrategy = new saml.Strategy(
  {
    callbackUrl: process.env.CALLBACK_URL,
    entryPoint: process.env.ENTRY_POINT,
    issuer: process.env.ISSUER,
    cert: process.env.CERTIFICATE
  },
  function (profile, done) {
    return done(null, profile);
  }
)

//the middleware
app.use(passport.initialize()); // init passport on every route call.
app.use(passport.session()); // allow passport to use "express-session".

// passport lifecycle
passport.use(samlStrategy);
passport.serializeUser(function(user, done) {
  done(null, user);
});
passport.deserializeUser(function(user, done) {
  done(null, user);
});

The CALLBACK_URL string it´s something like this: https://login.microsoftonline.com/xxx/saml2

And the entry point it´s a AWS cognito link urn:amazon:cognito:sp:{zone_string}_{code}

Now, I´m want to migrate the app to NextJS and let Next handle the authentication without requesting a express server for that.

There's any way to make NextJS handle all of this? Can I implement passport in NextJS?(I tried but failed)

Thanks for your help

0