Skip to content

implements Rate limiting logic to database access and API calls using Redis for the purpose between two completely independent websites using API key for authentication, authorization and metering.

Notifications You must be signed in to change notification settings

nurj20/Rate-Limiting-With-API-Key-And-Redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rate Lmiting/ Metering Database Access By Creating And Using Your Own API Key

This project shows you how to rate limit access to your critical resources by API key; create this API key, pass this API key as custom HTTP header for authentication and authorization. This key is also used as Redis key to limit the number of time this resource can be accessed within certain time frame. You also learn how to communicate between two different domains and pass critical credentials betweeen them.

Frontend Domain

uses HTML, CSS, JS and FETCH API requests to another domain (backend damain) to first register with it, get API key, and pass that key for the request to actually access actor data from its database. The API key is stored and reterived from SessionStorage (builtin storage/API within all the browsers).

Backend Domain

PHP, Redis for caching, and a package to interact with Redis Cleint named Predis.

Database

MySQL 8.0 databse is used for this project. It comes pre-packaged with many databases; the specific database used in this project is named sakila and the specific table that is accessed from there is named actor. This project does not depend on this particular database and table; you can use your own database if you like.. all you need to take care of change the relevant database query in the project. You also need to create a another table for user registeration with only three fields (id, email and api_key).

About

implements Rate limiting logic to database access and API calls using Redis for the purpose between two completely independent websites using API key for authentication, authorization and metering.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published