T
tRPC

Auth with passport.js

Auth with passport.js

Mmagicspon11/12/2022
Evening all,
Has anyone successfully setup trpc with passport.js for auth?
RRammstein12/16/2022
Any progress regarding this? I am facing a similar challenge
Mmsalsbery12/16/2022
What particular issues using passport auth with tRPC? While passport auth may not fit with tRPC APIs, it can certainly be used with tRPC. With tRPC middleware, context, and custom links one has pretty good access to the request/response pipeline when using the Express adapter, so it's pretty flexible
UUUnknown User1/14/2023
Message Not Public
Sign In & Join Server To View
Nnlucas1/14/2023
tRPC expects a middleware to return opts.next(opts) I haven't used passport, but if passport returns the result of the next which you're passing to it, you can just add a return, and then might need to pass something like () => opts.next(opts) to it The docs are worth a read: https://trpc.io/docs/middlewares
Mmsalsbery1/14/2023
@NT I don’t think you can use Express (connect) middleware directly as tRPC middleware (I could be wrong). I would put the Passport middleware in an Express router before the tRPC adapter
Nnlucas1/14/2023
That's also a good point if it's designed for Express. Probably there are some lower level APIs you could use to build a tRPC middleware via Passport, or someone has published one already. I wouldn't hoist the middleware up out of tRPC in most cases though; you might want to vary how auth is handled based on the procedure in the future
Mmsalsbery1/14/2023
For me I use a hybrid of Express and tRPC routers. Super flexible, and for Passport, it depends on which authentication strategy I’m using. For basic authentication and tokens I just roll my own. For more complex strategies I’ll hoist Passport to Express and expose whatever I need in tRPC context/middleware

Looking for more? Join the community!

T
tRPC

Auth with passport.js

Join Server
Recommended Posts
Object keeps getting overwrittenI feel like i'm missing something fundamental here. when I add a new entry into object ``b`` it resAccessToken for API callsWhat would be the best approach to pass the AccessToken from NextAuth Session to the Http Client whiRequest or Response Specification Definition DocumentI am developing a backend service using trpc, but I need to dispatch trpc in another programming lanabortOnUnmount config errorI'm encountering an error when passing abortOnUnmount saying that it does not exist as a possible pazustand + trpc (basic data fetching)im trying to use zustand with trpc, but having trouble setting some data to global state. What am i TypeError Cannot destructure property 'abortOnUnmount' of 'useContext(...)' as it is null.Zero Clue what is error mean exactly....First time learning trpc really good tool. help with setting cookies on front end.Hello how do you use tRPC to make a cookie and send it to the front end. or is there any other methoHow do we add settings in each query like before?Since the new update, bee super confused. I used to do this, and can't recreate it now. ``` const Handling error globallyAccording to the docs on errors https://trpc.io/docs/v10/error-handling I should get such error objecant access trpc endpoints via the browseri'm converting some express endpoints to trpc, and I cant figure out how to access my endpoints via tRPC without SSRWhen using tRPC with ssr it uses `getInitialProps`, which has kinda of a cool effect in terms how a trpc + expo react native issueDoes anyone know how to solve this? Im not familiar with webpack at all. I’m a junior frontend.Can you chain middlewares in v10?Would I be able to make a rate limit and isAuthed middleware, then put queries behind both middlewarLoad data client-side via react-query while using tRPC with SSRIs there any way to load data client-side when using tRPC? I want my page to be rendered and load daServing clients in another repository?Would it be possible for tRPC to act as a server for clients in another repository and if so how wouWhen not to use tRPC?Is there any scenario when building a mobile and/or a web app with backend that you would not recommBi directional infinite query example with prismaI'm working on a project that is using this pattern, but my `hasPreviousPages` gets blown away when Websockets not sending dataHi, I have a websocket route that doesn't seem to be sending any data I added a setInterval to tes