/stream-39-demo-app-spring-security

Demo application for online YouTube stream #39-40 about Spring Security

Primary LanguageJava

Demo Project for Online Stream #39-40 - Spring Security

Demo project for online YouTube stream #39 and #40 about Spring Security

Access to Online Stream on YouTube

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! Слава Україні! 🇺🇦

Run the app

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

Test the app

You can test the app using provided curl commands:

Get the list of supported currencies:

curl http://localhost:8080/forex/currencies

Simple API Key

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'

Client API 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'

JWT Authentication

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.

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: