Question - How can I access the logged-in user on the frontend in a way that does not delay the loading time of the application [in a secure way]?
Hi, I'm new to go
and I'm building an application with golang
on the backend
and a create-react-app
app on the frontend
. I'm not very experienced in authentication either. I'm using goth
to implement google authentication
using oAuth2.0
. I'm using sessions
- I heard they are more secure than JWT Tokens.
There are a couple of ways I can think of, but none seem like efficient or secure solutions :
Pass the userID and/or email in the URL when the callback redirects to the success page after login. Problem - this doesn't sound secure since user information like ID, etc will be visible in the URL.
Make a get call to
/api/me
and request user information, then store it on the state in the frontend - but this delays the loading time of the application. User experience will be affected negatively. I've seen apps achieve almost no loading time when it comes to authentication. How do they do this securely?I could store user information in
local storage
orsession storage
- but again, heard these are really bad choices for authentication.
If any of my above knowledge is wrong, please let me know that too. I'd love to learn.