User authentication services with session management. Interact with endpoints defined at docs/api.md
See [api.md] for an overview of the available endpoints and the expected request/response format.
Or see the Swagger documentation for the endpoints at e.g. http://{URL}:{PORT}/swagger/index.html
auth
├── docs
├── internal
│ ├── database
│ ├── handlers
│ ├── middleware
│ ├── models
│ ├── repository
│ ├── server
│ ├── services
│ └── testutils
├── pkg
│ └── apperrors
│ └── config
│ └── logger
└── scripts
docs: Contains documentation files related to the authentication systeminternal: internal packages that are not meant to be used outside of theauthmoduledatabase: code related to database interactions for the authentication systemhandlers: handler functions for HTTP routesmiddleware: middleware used for user/admin authenticationmodels: models for database tablesusersandsessions, automigratedrepository: code to perform CRUD and other operations onusersandsessionstablesserver: code to setup and run API serverservices: functions for mediating logic between HTTP handler functions and repository functionstestutils: utility functions and types for testing the authentication system
pkg: packages that are meant to be used by other modulesapperrors: custom errors for testing and loggingconfig: constants for configuring auth operationslogger: configuration and setup for logging
scripts: utility scripts for local development and testing of the authentication system
The auth module expects the following environment variables to be set:
DATABASE_URL: The URL of the database to connect toAUTH_SERVER_PORT: The port to run the http server onSESSION_KEY: The secret key to encrypt the session idCORS_ALLOWED_ORIGINS: comma separated string of allowed origins e.g."http://localhost:5173,http://localhost:4173"
See example.env or the watch command in justfile for sample environment variables.
Third party packages are defined in go.mod and go.sum.
Much learned about http and async go from lessons at https://calhoun.io
Developed as part of a larger project with
- @adamleatherman
- @jkeehnast
- @ samrxh