Variables are stored in .env file.
DATABASE_URL
- PostgresSQL database URLSECRET_KEY
- secret key for JWT token generationSERVER_IP
- server IP in ListenAndServeSERVER_PORT
server port in ListenAndServeMAILTRAP_USERNAME
- username from MailtrapMAILTRAP_PASSWORD
- password from MailtrapFROM_EMAIL
- the email we use to send emails in Mailtrap
Dockerfile for server, server and database are deployed with docker-compose.yml.
Tests are in database_test.go, services_test.go and handlers_test.go.
80%+ coverage.
Documentation is in docs.go, swagger.json and swagger.yaml.
- /create - the CreateTokens handler generates JWT access and refresh tokens using user's email and guid.
- /refresh - the RefreshTokens handler refreshes access and refresh tokens using the refresh token received in the X-Refresh-Token header.
Database stores:
- token id (the same for access and refresh tokens)
- bcrypt hash of JWT refresh token sign
- status (used, unused, blocked and so on).
When the IP address changes, the email is sent via Mailtrap.