can't do passport-saml logout redirection

54 views Asked by At

I am working on my saml configuration. Can you inform me about how to do the logout redirection? I would be very grateful if you give answers via code. I am using passport-saml. my passport-saml version is 0.6.0. I am using Zoho as IDP. If you see any errors in the code other than logout redirection, do not hesitate to tell me.

passport.use(
    new samlStrategy(
      {
        entryPoint: process.env.SAML_ENTRY_POINT,
        issuer: process.env.SAML_ISSUER,
        path: process.env.SAML_PATH || "/login/callback/",
        cert: process.env.SAML_CERT,
        logoutUrl: process.env.SAML_LOGOUT,
        logoutCallbackUrl: process.env.SAML_LOGOUT_CALLBACK || "/logout/callback",
      },
      (profile, done) => {
        console.log('profile', profile);
        return done(null,
          {
            nameID: profile.nameID,
            email: profile.nameID,
            fullName: profile.FullName,
            firstName: profile.EmailID,
            nameIDFormat: profile.nameIDFormat
          });
      }
    )
  );

  app.use(cookieParser());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(session({ secret: 'secret', resave: false, saveUninitialized: false }));
  app.use(passport.initialize());
  app.use(passport.session());

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

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

  app.get('/login',
    (req, res, next) => {
      next();
    },
    passport.authenticate('saml', { failureRedirect: '/login/fail' }),
    function (req, res) {
      res.redirect('/');
    }
  );

  app.post('/login/callback',
  (req, res, next) => {
    next();
  },
  passport.authenticate('saml', { failureRedirect: '/login/fail' }),
  function (req, res) {
    console.log("GİRİŞ BAŞARILI");
    res.redirect('/');
  }
);

app.use(function(req, res, next){
  if(req.user){
    next();
  } 
  else {
    res.redirect('/login');
  }
})

I am waiting for a sample logout routing as a response from you. thank you in advance for your help

information on how to redirect saml logout

0

There are 0 answers