←back to thread

200 points dcu | 5 comments | | HN request time: 0s | 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 #
1. 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 #
2. fkyoureadthedoc ◴[] No.44456835[source]
maybe this is why they used sha-256 too, it's in the stdlib whereas bcrypt is a package (even if "official")
replies(1): >>44456932 #
3. 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
4. ncruces ◴[] No.44456932[source]
The standard lib has pbkdf2 though.

I'm guessing the goal is that the file can be managed more easily with a text editor and some shell utils.

5. jitl ◴[] No.44457711[source]
Well the project goal seems to be extreme minimalism and stdlib only, and the choice of human readable data stores and manually editing the user list suggests a goal is to only need `vim` and `sha256sum` for administration