Java (8+) installed
Git client (optional)
Curl or tool to make http requests e.g. postman, chrome browser, etc.
Start by cloning this repository in your local machine
git clone https://github.com/mostrovoi/relevant-cover.git
This project uses gradle as build tool. Go to relevant-cover folder and run
./gradlew bootRun
This will start up a server listening in port 8100
This server is a sample test using JWT tokens as authentication mechanism for a REST api. There are 2 endpoints available
/login
/users/{username}
You should POST a request to http://localhost:8100/login with your username and password in the body payload e.g with curl.:
curl -i -H "Content-Type: application/json" -X POST -d '{
"username": "xxxx",
"password": "xxxx"
}' http://localhost:8100/login
Where xxxx is your actual user and password. This operation, if succesful, will return a Bearer token in the response. This token should be used for all operations requiring authorization
There is the endpoint /users/{username} which will retrieve the details of a user. e.g.:
curl -H "Authorization: Bearer xxx.yyy.zzz" http://localhost:8100/users/xxxx
Here, you should copy the token obtained before and replace xxx by the user you want to get info from.
This demo uses an in-memory database already populated with 2 users:
user | password |
---|---|
oscar | oscar |
bruno | bruno |
You can try out the demo with this data. Feedback welcome!