Demo project for online YouTube stream #39 and #40 about Spring Security
To get a link to online stream on YouTube please do the following:
- 💰 Make any donation to support my volunteering initiative to help Ukrainian Armed Forces by means described on my website
- 📧 Write me an email indicating donation amount and time
- 📺 I will reply with the link to the stream on YouTube.
Thank you in advance for your support! Слава Україні! 🇺🇦
First, you need to start the Postgres database using provided docker-compose.yml
file:
docker-compose up
Then, you can start the application using Gradle:
./gradlew bootRun
You can test the app using provided curl
commands:
Get the list of supported currencies:
curl http://localhost:8080/forex/currencies
Get the exchange rate using general simple x-api-key
:
curl 'http://localhost:8080/forex?from=USD&to=EUR' -H 'x-api-key: valid-key'
Get the exchange rate using client's key x-client-api-key
:
curl 'http://localhost:8080/forex?from=USD&to=EUR' -H 'x-client-api-key: key1'
curl 'http://localhost:8080/forex?from=USD&to=UAH' -H 'x-client-api-key: key3'
curl 'http://localhost:8080/forex?from=USD&to=CHF' -H 'x-client-api-key: key4'
First, obtain the JWT token by supplying username and password in JSON format to the auth endpoint:
curl -X POST http://localhost:8080/auth -H 'Content-Type: application/json' \
-d '{"username": "user1", "password": "qwerty"}'
Then use the received token to access the protected endpoint:
curl 'http://localhost:8080/forex?from=USD&to=EUR' -H 'Authorization: Bearer <jwt token>'
JWT token is valid for 2 minutes. This can be changed in application.yml
file.
For further reference, please consider the following sections:
The following guides illustrate how to use some features concretely: