#Am I using middleware appropriately for auth?

3 messages · Page 1 of 1 (latest)

wary forge
#

I'm using the middleware as one layer of authentication. Within it, if the user is authenticated with Cognito, I make a request to my db to grab user info and store it in cookies, so it's faster to access on the client side.

I don't rely solely on this for auth, all api routes have their own protection implemented, so a user inserting a fake cookie wouldn't give them any access.

My question is whether I should be making a db request within my middleware. I actually make this request through a server action, not directly in the middleware, the middleware just calls the server action. Is this ok? I know the middleware runs on the edge and want to respect best practices for efficiency.

shell galleonBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

wary forge
#

Just bumping this