-
On the Jumphost, open
Postman
app from the desktop and then run5_Controller3.x_API_Key_Creation
collection. -
Now open up
Google Chrome
. -
Select the bookmark toolbar link: (
Controller|Login
) https://nginxcontrollerdemo.com -
Login to Controller using Admin credentials. (For credentials, refer README.md file)
-
Navigate to
Services
view within Controller by clicking on the top right NGINX button.
-
Select
dev-f1-results
and then click onEdit
button within thePublished APIS
portion on right hand pane as shown in below screenshot.
-
Inside the
Edit Published API
pane, selectRouting
tab and then click onEdit
for the menu item currently labeled asNo Security Settings
as shown in the screenshot.
-
Inside the
Edit App Component
pane, selectAuthentication
tab and then clickAdd Authentication
as shown in the screenshot.
-
Select
Test Client API keys
forIdentity Provider
field. SelectHeader
forCredential Location
field and enterapikey
for theCredential Value
field. Click onDone
to save your selections. -
Now within the
Edit App Component
pane, selectRate Limiting
tab and then enable rate limiting using thetoggle
button. Fill out the Rate limiting form with below details- Key:
Client IP Address
- Rate:
1
- Units:
Requests per second
- Excess Request Processing:
Reject immediately
- Reject Status Code:
429
- Key:
-
Click on
Submit
button at bothEdit App Component
andEdit Published API
panes to apply Authentication and Rate limiting to the published API. -
Now we would look into how we can test the newly configured Authentication and Rate Limiting features.
-
On the Jumphost, open
Visual Studio Code
app and then connect to Terminal10.1.1.7
using SSH client. -
Run the following commands and check the outputs of those commands.
-
Scenario 1: No Key provided
for i in {1..10}; do curl http://devsports.example.com/api/f1/drivers; done
Observation: response expected
401(1 request)
,429(9 request)
-
Scenario 2: Authorize using valid API key
for i in {1..10}; do curl -H "apikey: f958ce3a-7934-4b76-80f9-38bd3a14e722" http://devsports.example.com/api/f1/drivers; done
Observation: response expected
200(1 request)
,429(9 request)
-
Scenario 3: Authorize using invalid API key
for i in {1..10}; do curl -H "apikey: f958ce3a-7934-4b76-80f9-38bd3a14e722x" http://devsports.example.com/api/f1/drivers; done
Observation: response expected
403(1 request)
,429(9 request)
-
-
This concludes this demo. Return to the NGINX controller and
DELETE
the Authentication andDisable
Rate Limit fordev-f1-results
component as shown in below screenshots. -
Finally save the changes by clicking on
Submit
at bothEdit App Component
andEdit Published API
panes.