Comments (7)
I've removed the deprecation warning for now; published as 2.2.2
. The user
is still accessible through ctx.state.user
. @gingerich I am still eager to adhere to Koa's way of doing things. However, I've test implemented workarounds to get passport to work with having the user
in ctx.state
. But since methods like login()
are actively using req.user
, the amount of required workarounds is unreasonable high. Maybe an ideal solution can only be achieved by implementing authentication for Koa from scratch. Unfortunately, this is not possible with keeping compatibility to all passport strategies, which would make such an undertaking a tremendous and unreasonable amount of work 😕
from koa-passport.
@rkusa not guessing monkey-patching all use
d strategies would work?
from koa-passport.
Thanks for the feedback! Since passport is adding things to req
anyway, the question would be: what is better, monkey-patching all strategies, or living with having the user
property in multiple places. I personally don't like both, what probably prefer the latter. But I am open to hearing other opinions on that!
from koa-passport.
@rkusa the best option would be making a different authentication library (clean codebase), but it would be a shame to discard the sheer amount of Passport strategies available.
from koa-passport.
Easiest path would be proxying the ctx.req.user
getters and setters to ctx.state
- that way everyone is happy I guess, and will maintain backward comp with other libraries
from koa-passport.
Yep, in an ideal world we would have a passport written for Koa from scratch. But writing all the strategies again... and going through all security issues again... does not sound too good.
I am currently copying the user value over to ctx.state
. A getter and setter would definitely better. Especially since the user on the req
is already a getter and setter. However, I ran into a weird bug today and I hadn't the time to debug it, which is why I went for copying for now. I'll replace this by a getter and setter later.
from koa-passport.
The user
object now lives only in one single place, which is ctx.state.user
.
from koa-passport.
Related Issues (20)
- koa-passport doesn't work with local-strategy? HOT 1
- Delegate Koa's ctx.protocol in request HOT 1
- external session storage does not work HOT 2
- The callback in ctx.login() is not being executed, "Error: Failed to serialize user into session" HOT 9
- Strange behavior for passport.authenticate() function HOT 8
- passport.authenticate("jwt", {session: false}) will not executed. Does koa-passport support JWT strategies? HOT 1
- passport serialize user: next is not a function HOT 2
- mocking request loses original koa app instance, breaking resolving of req.subdomains, because req.app.subdomainOffset is undefined HOT 4
- Documentation | authenticate() HOT 2
- Use koa-passport without koa-session HOT 1
- Not work well with @koa/router in Typescript HOT 2
- koa-passport@next is broken! HOT 1
- Passing multiple strategies to passport.authenticate() HOT 1
- export `AuthenticateOptions` HOT 1
- Should `ctx.state.user` contains `password`? HOT 1
- Update passport to latest version HOT 2
- req.session.regenerate is not a function HOT 17
- Mix of express/koa with passport in both breaks HOT 3
- Passport authentification - LocalStrategy async/await issue
- userProperty option doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-passport.