Simple authentication and authorization server with Golang.
Run command with a pre-existing Postgres
database server:
docker run -p 8180:8080 \
-e DB_HOST=<database_host> \
-e DB_PORT=<database_port> \
-e DB_NAME=<database_name> \
-e DB_USERNAME=<database_username> \
-e DB_PASSWORD=<database_password> \
golauth/golauth
Docker compose example with database creation:
services:
postgres:
image: postgres:alpine
environment:
- POSTGRES_DB=golauth
- POSTGRES_USER=golauthuser
- POSTGRES_PASSWORD=C8HSN2mDvq5Q
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- golauthnet
golauth:
image: golauth/golauth
links:
- postgres
ports:
- '8180:8080'
environment:
- PORT=8080
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=golauth
- DB_USERNAME=golauthuser
- DB_PASSWORD=C8HSN2mDvq5Q
networks:
- golauthnet
volumes:
pgdata:
networks:
golauthnet:
Env Variable | Description |
---|---|
DB_HOST | Database hostname |
DB_PORT | Database port |
DB_NAME | Database name |
DB_USERNAME | Database username |
DB_PASSWORD | Database password |
PORT | Application port (default 8080) |
Default user is admin
and password admin123
.
curl --request POST \
--url http://localhost:8180/auth/token \
--header 'content-type: application/json' \
--data '{"username": "admin","password": "admin123"}'
or
curl --request POST \
--url http://localhost:8180/auth/token \
--header 'content-type: application/x-www-form-urlencoded' \
--data username=admin \
--data password=admin123