You need to have docker
and docker-compose
installed on your computer to run the service
- Clone this repository
- Run from root dir
docker-compose up -d
- auth service will start on port
3000
- movie service will start on port
3001
- mongodb will start on port
27018
To stop the service run
docker-compose down
The auth service defines two user accounts that you should use
Basic
user ( can only post up to 5 movies per month)
username: 'basic-thomas'
password: 'sR-_pcoow-27-6PAwCD8'
Premium
user (all capabilities approved)
username: 'premium-jim'
password: 'GBLtTyq3E_UNjFnpo9m6'
Decoding the auth token will give you access to basic information about the user, including its role.
{
"userId": 123,
"name": "Basic Thomas",
"role": "basic",
"iat": 1606221838,
"exp": 1606223638,
"iss": "https://www.netguru.com/",
"sub": "123"
}
To authorize user call the auth service using for example curl
. We assume
that the auth service is running of the default port 3000
.
Request
curl --location --request POST '0.0.0.0:3000/auth' \
--header 'Content-Type: application/json' \
--data-raw '{
"username": "basic-thomas",
"password": "sR-_pcoow-27-6PAwCD8"
}'
Response
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEyMywibmFtZSI6IkJhc2ljIFRob21hcyIsInJvbGUiOiJiYXNpYyIsImlhdCI6MTYwNjIyMTgzOCwiZXhwIjoxNjA2MjIzNjM4LCJpc3MiOiJodHRwczovL3d3dy5uZXRndXJ1LmNvbS8iLCJzdWIiOiIxMjMifQ.KjZ3zZM1lZa1SB8U-W65oQApSiC70ePdkQ7LbAhpUQg"
}
Base URL: http://localhost:3001/
endpoint: http://localhost:3001/movies
method: POST
payload:
{
"title": "Primer"
}
headers:
Authorization: Bearer <token>
endpoint: http://localhost:3001/movies
method: GET
headers:
Authorization: Bearer <token>