This is a simple auth server written in Go. It uses a Postgres database to store user information and JWT tokens for authentication.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- Password based authentication
- Google OAuth2 authentication
- JWT token generation, validation and refresh
- User account creation and management
- Rate limiting
- Docker support for Postgres database
-
GET
/
- Home @returnsauth-server-go
-
GET
/health
- Get Health @returnsOK
-
GET
/refresh-token
- Refresh token @headerAuthorization: Bearer {token}
@returns{token}
-
GET
/auth/google
- Google OAuth2 route, starts auth flow @returns{token, account}
-
POST
/auth/register
- Register a new user @body{email, password}
@returns{token, account}
-
POST
/auth/login
- Login with email and password @body{email, password}
@returns{token, account}
-
GET
/logout
- Logout @redirects to/
-
GET
/secure/account
- Get current user account from DB @headerAuthorization: Bearer {token}
@returnsAccount{}
-
GET
/secure/account/{id}
- Get account from DB using accountId @headerAuthorization: Bearer {token}
@returnsAccount{}
build the application
make build
run the application
make run
Create DB container
make docker-run
Shutdown DB container
make docker-down
live reload the application
make watch
run the test suite
make test
clean up binary from the last build
make clean