←back to thread

200 points dcu | 1 comments | | HN request time: 0.202s | source
Show context
fkyoureadthedoc ◴[] No.44456481[source]
> Another important file is _users.csv which contains user credentials and roles. It has the same format as other resources, but with a special _users collection name. There is no way to add new users via API, they must be created manually by editing this file:

    admin,1,salt,5V5R4SO4ZIFMXRZUL2EQMT2CJSREI7EMTK7AH2ND3T7BXIDLMNVQ====,"admin"
    alice,1,salt,PXHQWNPTZCBORTO5ASIJYVVAINQLQKJSOAQ4UXIAKTR55BU4HGRQ====,
> Here we have user ID which is user name, version number (always 1), salt for password hashing, and the password itself (hashed with SHA-256 and encoded as Base32). The last column is a list of roles assigned to the user.

I haven't had to handle password hashing in like a decade (thanks SSO), but isn't fast hashing like SHA-256 bad for it? Bcrypt was the standard last I did it. Or is this just an example and not what is actually used in the code?

replies(4): >>44456509 #>>44457381 #>>44457415 #>>44457642 #
reactordev ◴[] No.44456509[source]
Indeed bcrypt is preferred but this is just a simple backend. My first ick was using CSV as storage as opposed to golang’s builtin SQLite support.

A SQLite connection can be made with just a sqlite://data.db connection string.

replies(1): >>44456539 #
jitl ◴[] No.44456539[source]
Golang does not have built in SQLite. It has a SQL database abstraction in the stdlib but you must supply a sqlite driver, for example one of these: https://github.com/cvilsmeier/go-sqlite-bench

However using the stdlib abstraction adds a lot of performance overhead; although it’ll still be competitive with CSV files.

replies(1): >>44456608 #
reactordev ◴[] No.44456608[source]
Ok, one additional dependency to your go.mod - big deal. And by builtin I was referring to the database/sql module which was designed for this.
replies(3): >>44456835 #>>44456856 #>>44457711 #
1. gtufano ◴[] No.44456856[source]
Most of the more common SQLite implementations for go require CGO and this is a pretty steep request, it's definitely more than a line in go.mod