Skip to content

Authentication #23

Answered by maddalax
lewinkedrs asked this question in Q&A
Oct 18, 2024 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

Hey, thanks for using it!

For authentication, I think the simplest route would be to store users in your database (sqlite or pg, or whatever), and use cookies to store a sessionId

Something like:

users:
id
username (or email)
password (hashed with bcrypt or some good algo)

auth_tokens:
user_id
token

Have a page that allows a user to register acc / login, and then the backend can verify the password, create an auth token, and use the h.RequestContext to set the auth token as a cookie on the response

From there on you can look up the auth token from the cookie and get the user id associated from that

I could probably make a sample authentication flow using it to show how it may work

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@lewinkedrs
Comment options

@maddalax
Comment options

Answer selected by lewinkedrs
Comment options

You must be logged in to vote
1 reply
@lewinkedrs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants