This project is currently work-in-progress. Anything can happen, hell, this might even disappear! It is designed specifically for small, personal projects requiring a straightforward, simple storage API that you can host yourself. It also requires you to specify a list of known-users, simplifying it greatly as there is no need for handling any sign-up process of new users.
First, create a .env and specify the initial usernames and passwords for access. Make sure to fill out GENESIS_JWT_SECRET with a secure, random string, for that you can use openssl rand -hex 32. You can specify the remaining values, but the defaults are good for medium-sized projects such as ocular.
Second, start the server via go run .. That's it. Head to the api documentation to see how to use it.
The json is pre-processed by the minify package to minimize and validate it.
You can run genesis using docker by using pre-build images:
docker run -p 8080:8080 -v "$(pwd)/.data:/app/.data" --env-file .env ghcr.io/simonwep/genesis:latestGenesis should then be accessible under port 8080.
The API is kept as simple as possible, there is nothing more than user, data and account management.
POST /login- Authenticates a user.- Takes either a
userandpasswordas json object and returns the user-data and a session cookie or, if a session-cookie exists, the current user. - Returns
401the password is invalid or the user doesn't exist.
- Takes either a
POST /logout- Invalidates the current refresh token and logs out a user.POST /account/update- Takes a
newPasswordandcurrentPasswordas json object. - Returns
200if the password was successfully updated, otherwise400.
- Takes a
The JWT token is returned as strict same-site, secure and http-only cookie!
When changing the password, the new password must fulfill the same requirements for adding a new user.
GET /data- Retrieves all data from the current user as object.GET /data/:key- Retrieves the data stored for the givenkey. Returns204if there is no content.POST /data/:key- Stores / overrides the data forkey.DELETE /data/:key- Removes the data forkey, always returns200, even ifkeydoesn't exist.
Validation parameters for those endpoints are defined in .env.
This includes a key-pattern, the max amount per user and a size-limit.
These endpoints can only be used by admins!
GET /user- Fetch all users as{ name: string, admin: boolean }[].POST /user- Create a user, takes a json object withuser,passwordandadmin(all mandatory,adminis a boolean).POST /user/:name- Update a user byname, takes a json object withpasswordandadmin(both optional).DELETE /user/:name- Delete a user byname.
The username is validated against the pattern defined in .env.
The length must be between3and32, the password between8and64.