REST API (and CLI tool) to generate secure passwords written in Go.
- Allow specification of minimum length
- Allow specification of number of special characters
- Allow specification of number of numeric characters
- Allow generation of multiple passwords in one go
- Unit tested (table-driven testing)
- Automated Kubernetes deployment
To use the command-line (CLI) tool:
# Build the tool for your platform
go build .
# Start REST API Server at http:localhost:8080
./go-password-generator
# Generate a single 8-character password with 2 special characters and 2 numerals
./go-password-generator generatePassword
To generate passwords via the REST API, you need to first startup the server:
./go-password-generator
Then make a POST
request to http://localhost:8080/api/v1/password with a JSON body like:
{
"min_length": 8,
"special_characters_count": 2,
"numbers_count": 2,
"pwds_to_create": 3
}
A sample curl request is:
curl --request POST \
--url http://localhost:8080/api/v1/password \
--header 'Content-Type: application/json' \
--data '{
"min_length": 8,
"special_chars_count": 2,
"numbers_count": 1,
"pwds_to_create": 3
}'
To generate passwords with the CLI tool:
# Generate 5 8-character passwords with 2 special characters and 1 numeral each
./go-password-generator generatePassword -m 8 -c 2 -n 1 -p 5
# To get usage help
./go-password-generator help
To run tests:
go test ./...
A deployment setup for Kubernetes has been assembled in ansible playbook deploy.yaml. This playbook:
- builds a docker image for the application
- publishes the docker image to GitHub Container Registry
- generates Kubernetes Deployment, Service, and Ingress configs
- applies generated configs