prpo-auth microservice
This repository contains a source code for user management microservice used in a demo project developed under PRPO subject at UNI LJ.
Setup
Run a development database via Docker:
docker run -p 5432:5432 \
-e POSTGRES_USER=prpo \
-e POSTGRES_PASSWORD=rootroot \
-v prpo:/var/lib/postgresql/data \
-d postgres:13
Install dependencies and compile:
go mod download
make bindata
make build
Create signing keys:
./auth genkeys # this creates signing key pair under `conf` directory
Create a user from command line:
./auth createuser --email [email protected] --name username123 --password securepwd
Run the server:
./auth serve
System behaviour can be configured through configs/config.ini.
Documentation
TODO: Write an OpenAPI spec.
This microservice exposes its functionality via the following http endpoints:
/authorize
POST - Obtain JWT refresh and access tokens either via email-password pair or and old refresh token./change_password
PUT Change user's password by providing an old password./users
POST Create a new user (used for signup/register)./users/{uid}
GET Retrieve user info by providing UID from JWT token's subject field./signing_key
GET Obtain server's public signing key to verify token validity.
Excercise goal equivalents
The orinal excercise is designed for Java and JDBC. Here are some analogus goals fulfiled by this go implementation:
- A sample wiki page.
- Dependency management implemented using go modules.
- Http endpoints defined in
internal/router/routes.go
and implemented ininternal/handle/
. - Model management functions in
internal/models/
. - Database migrations defined in
configs/migrations/
.