Any React/Apollo devs here that can help teach me ...
# orm-help
a
Any React/Apollo devs here that can help teach me Authentication/Authorization? I would like to learn how to set it up so that it's production ready. Email/password login, protected routes, roles, etc. Please I could really use the help.
l
I use accounts-js. Documentation can be a bit light, but it is quite simple to set up.
a
I would like to set it up without third-party auth solutions if possible..
Once I learn it then in the future I can opt for things like auth-0 okta or firebase
l
I'm using Prisma 1 where there is no built-in auth-solution. I don't think there is in Prisma 2 either, but maybe it is in the plans.
Accounts.js is nice as it is a plugin solution
a
I would prefer to learn to set it up with JWT/refresh tokens
but thanks for the suggestion
l
accounts.js supports that too ... Also I don't understand why you won't use a 3rd party library, authentication is not generally part of the data provider role, so whatever you ends up making yourself, or via Prisma, will be less ready for production than a dedicated 3rd party solution.
a
Because I want to learn how to do it without 3rd party library...
I'm just learning. I want to learn. It's not like I'm working on a project that's handling extremely sensitive data. If I learn how to implement it this way, then I can use these third party solutions if the need arises. Idk why every keeps recommending these things to me even when I say I don't want to use them. No one seems to be interested in helping me with what I'm actually trying to learn. All the online solutions I find keep showing incomplete solutions and don't do it this way because it's not really secure but this is just a brief overview of how auth works solutions for toy applications... What's the point of people making these tutorials if you're never suppose to do it on your own and you have to rely on third party auth solutions?
l
Fair enough, but you did mention taking to production, in which case I truly suggest using existing solutions. The overall concepts of authentication and authorization are simple for anyone to learn, but the implementations are more complex (and in my experience) handled by specific employees and/or departments, as it is so important for an application in production that it shouldn't be handled by someone not fully into it, and experienced. This may be the reason that more complete solutions, available as an example, are not really available. Generally I have learnt from examples in code, applications I've worked on and e.g. the source code of accounts-js (which I have used in an application that will go into production later this year)
👍 1
r
@Awey - try this, I learnt a bit from it. It's very comprehensive and step by step:

https://www.youtube.com/watch?v=25GS0MLT8JU

a
@Richard Ward Are you using nexus?
r
I'm using apollo-server
a
I'm not sure how to create a
refresh_token
end point with nexus
r
aah - yeah, I'm using express and apollo-server, so adding an endpoint is easy..
👍 1
a
I'll ask the nexus team if this is possible
r
yeah - sorry - I've never used it
a
no problem.
@Lars Ivar Igesund Okay but then how am I suppose to learn to use these solutions with nexus/prisma? It's not like there are tutorials out there using this stack. I've tried using firebase and auth0 before and they just confused the heck out of me. I just really need to finish this instagram clone I'm working on and I'm being blocked from progressing because of authentication/authorization. Just a couple hours ago I tried setting up a custom Auth system using firebase and failed to make any progress. Looking at accounts-js, in the database section. If I'm using postgres on my backend, do I have to learn to use TypeORM? That's not even something I can use with my stack I believe, since I'm using prisma.
l
@Awey Right. I am using Mongo, so that was straightforward with accounts-js, I am not familiar with TypeORM myself, so don't know how difficult that is.
@Awey See the random channel if you're using next.js