Skip to content

Repository files navigation

payroll-api

A multi-tenant payroll and employee-directory service. Companies manage their own staff records; company admins run payroll.

Running it

go run .

Listens on 127.0.0.1:8088. Set ADDR to change that. No dependencies, no database — the store is in memory and reseeds on every start.

go test ./...

Authenticating

curl -s -X POST 127.0.0.1:8088/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"jane@acme.test","password":"password"}'

Returns a bearer token valid for 15 minutes. Send it on every other endpoint:

curl -s 127.0.0.1:8088/whoami -H "Authorization: Bearer <token>"

Endpoints

Method Path
GET /health
POST /auth/login
GET /whoami
GET /companies/{companyId}/employees
GET /companies/{companyId}/employees/{employeeId}
PATCH /companies/{companyId}/employees/{employeeId}
POST /companies/{companyId}/payroll

Seed data

Every account has the password password.

Company Employee Role
Acme (c_acme) e_janejane@acme.test employee
Acme e_johnjohn@acme.test manager
Acme e_alicealice@acme.test company admin
Globex (c_globex) e_bobbob@globex.test employee
Globex e_carolcarol@globex.test manager
Globex e_davedave@globex.test company admin
Platform (c_platform) e_samsam@payroll.test platform admin

Jane reports to John, who reports to Alice. Bob reports to Carol, who reports to Dave.

Layout

File Contents
main.go Entry point and routing
auth.go Token issuing, verification, request authentication
handlers.go Endpoint handlers
store.go Domain types and the in-memory store
api_test.go Endpoint tests

About

source code for sincere fellowship security session/lab

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages