- Run
docker compose up -d dbto run the couchbase server. - Go to
localhost:8091to access the Couchbase server in order to setup the cluster:- Click
Setup New Cluster; - Cluster name can be whatever you want, like
SimpleAuthDB; - Admin username and password should be
Administratorandpasswordrespecively. If you want to setup different credentials, the username and password on theconfig.example.jsonshould also be changed accordingly. ClickNext: Accept Terms; - Accept terms and conditions and click
Finish With Defaults
- Click
- Run
docker compose up -dto run the api. It takes some time to start up full because it takes some time to initialize the database.
To register a user, send a POST request to:
http://localhost:8080/register
With the following data:
{
"username": "sfmelo",
"email": "sfmelo@realemail.com",
"password": "password123"
}The response should have a 201 CREATED status.
To login, send a POST request to:
http://localhost:8080/login
While having the username and password in Basic authentication.
The response should be a token that should be saved:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNmbWVsbyIsImVtYWlsIjoic2ZtZWxvQHJlYWxlbWFpbC5jb20iLCJleHAiOjE2ODE4NTg0ODR9._0LCEJlPhAZJVUReLpBekR-5a8up4JRBuSKcN_kl784"
}This token has, by default, 15 minutes before expiring. This time can be changed in the config.example.json.
To verify if a user is logged in, send a GET request to:
http://localhost:8080/verify
While having the token previously obtained in the login section in the Bearer Token.
If the user is logged in, the response should have a 200 ACCEPTED status code, otherwise an error is returned.