node.js - Passport.js session management without cookie -
i'm pretty new node world. have looked around few days, , can't find way existing npm "official" solutions. if there apologies, i'll better in finding right node resources.
i have implemented working passport local policy following various examples available on internet. works well
i want implement session management, don't want use cookies , use get
/post
parameters instead. reason behind i'm building api service might have work custom protocols (other http) cookies/headers don't exist.
i have seen sessions support implementation passport , seems rely on express/connect session package, that, in turn, seems support cookie , have no way read/write sessions key in post
/get
parameters.
before roll out own bespoke solution, point me available, if exists?
so can this.
passport.js uses npm express-session middleware actual session infrastructure.
since express supports pipelined arbitrary middleware managed use following workaround:
in express setup, add middleware function before express session middleware.
in middleware function, check see if session token/id exists on request (as header or in body required) , if so, read the session token/id it.
set session token/id onto request.cookies object (if you're using cookie-parser) and/or append serialised cookies in headers: request.headers.cookie += ...my new cookie goes here...
make sure name cookie after name pass express-session
express-session should able pick off request resuscitation.
Comments
Post a Comment