ricardosaracino / nestjs-sp

OpenAM Nest JS Samlv2 Service Provider
10 stars 2 forks source link

Error: Failed to serialize user into session #10

Closed chriskacerguis closed 3 years ago

chriskacerguis commented 3 years ago

Hello ricardo, thanks a lot for this repos, it was a big help to me. I put your example code into my app, and it seemed to be working fine, but on the redirect from my SAML provider I'm getting the following error:

Error: Failed to serialize user into session

I did some quick debugging, and added this:

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

So, I see in the output (before that error), the following:

serializeUser
undefined

so I know that serializeUser is getting called. Would you happen to be able to provide any tip on what I could be doing wrong?

Thanks!

chriskacerguis commented 3 years ago

Hello @ricardosaracino thanks again for your lib. I solved the issue.

For anyone who is comes across this from Google, when using Okta as the SSO provider, you need to change

export const User = createParamDecorator((data, req) => req.user);

to this

export const User = createParamDecorator((data, req) => req.args[0].user.nameID);

in user.decorator.ts