rkusa / koa-passport

Passport middleware for Koa
MIT License
774 stars 55 forks source link

Use koa-passport without koa-session #135

Open walkerlangley opened 4 years ago

walkerlangley commented 4 years ago

Is it possible to use koa-passport without using koa-session? We've been using a much older version of koa-passport (1.3.0), aren't calling (app.use(passport.session()) and are able to authenticate users based off a jwt token passed in the header of a request. However, once I updated to the current version of koa-passport, the only way I can get authentication to work is if I also use koa-session. If I don't use koa-session, ctx.isAuthenticated() is always false. I've googled around and it se

walkerlangley commented 4 years ago

Ok, may have solved the issue.

It seems that when vaildating the JWT token, I needed to call

ctx.state.user = user;
//Before we were calling
ctx.request.user = user;