These are two RESTful HTTP APIs for creating and verifying user accounts and passwords. The APIs are packaged in a Docker container and hosted on Docker Hub. This README provides an overview of the project, instructions for running the container with Docker, and details on using the APIs.
.
├── Dockerfile
├── README.md
├── api
│ ├── api.go
│ ├── api_test.go
│ ├── main_test.go
│ ├── routes.go
│ └── server.go
├── db
│ └── db.go
├── docker-compose.yml
├── docs
│ ├── docs.go
│ ├── swagger.json
│ └── swagger.yaml
├── errors
│ └── errors.go
├── go.mod
├── go.sum
├── main.go
├── models
│ ├── account.go
│ ├── account_test.go
│ └── models.go
├── services
│ └── account.go
└── utils
├── hash.go
├── random.go
└── validation.go
This API allows you to create a new user account with a desired username and password.
- Endpoint:
/v1/signup
- HTTP Method:
POST
{
"username": "string", // length: 3~32
"password": "string" // length: 8~32, with 1 lowercase letter, 1 uppercase letter and 1 number
}
{
"success": true, // boolean, true or false
"reason": "string" // reason for failure if applicable
}
This API allows you to verify if a given username and password combination is valid.
- Endpoint:
/v1/login
- HTTP Method:
POST
{
"username": "string", // length: 3~32
"password": "string" // length: 8~32, with 1 lowercase letter, 1 uppercase letter and 1 number
}
{
"success": true, // boolean, true or false
"reason": "string" // reason for failure if applicable
}
To use the Account Management APIs, there are three options for you to deploy them. Follow these steps:
Install Docker before deployment.
wget https://github.com/ushio0107/api_account_management/releases/download/v1.0/release_v1.0.tar.gz
./start.sh
Choose deployment method:
1. Pull Docker image from Docker Hub and run
2. Clone repo and run using Docker Compose
3. Run docker-compose up to deploy
Enter your choice (1/3):
Both of two options are provided in ./start.sh
./start.sh
> Choose deployment method:
> 1. Pull Docker image from Docker Hub and run
> 2. Clone repo and run using Docker Compose
> Enter your choice (1/2):
docker network create <YOUR_NETWORK>
# Pull Docker image
docker pull ushio0107/account_management_api
docker pull mongo:4.4
# Run Docker
docker run --name mongo \
--network <YOUR_NETWORK>
-e MONGO_INITDB_ROOT_USERNAME=<DB_USERNAME> \
-e MONGO_INITDB_ROOT_PASSWORD=<DB_PASSWORD> \
-v ./data:/data/db \
-p 27017:27017 \
-d mongo:4.4
docker run --network <YOUR_NETWORK> -e <YourEnvironmentVariable> ushio0107/account_management_api
git clone [email protected]:ushio0107/api_account_management.git
cd api_account_management
vi .env # Set your environment variable if need.
docker-compose up
You can also modify the docker-compose.yml
to make the container api
deployed by Dockerfile
not the image from Docker hub
.
api:
container_name: account_api
build:
# build from Dockerfile
context: .
dockerfile: Dockerfile
# image: ushio0107/account_management_api
The APIs are documented by Swagger, starts the container of the APIs and accesses the link below to access the APIs.
Click the button Try it out
, then input the parameter.
For detailed information on how to use the APIs, including sample request and response, please refer to the link.
The source code for the solution is available on GitHub at github.com/ushio0107/api_account_management
.