Skip to content

akto-api-security/flask-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Steps to add flask middleware

  1. Copy and paste the middleware.py file in your project directory. Add confluent_kafka to your requirements.txt file
  2. In your application, where you are initializing flask app, import the middleware.py file and add the following line of code.
from middleware import setup_middleware

app = Flask(__name__)
setup_middleware(app)
  1. Add the following environment variables for the middleware to start working.
KAFKA_URL=your_kafka_url:9092 # Get the service/load balancer dns of akto-runtime
AKTO_ACCOUNT_ID=your_account_id # For on-prem setup, this will be 1000000, for cloud setup, grab the account id from Settings > About
MAX_PAYLOAD_SIZE=100000 # This is an optional parameter, default value is 100000. Request payloads greater than this size will be ignored
KAFKA_BATCH_SIZE=999900 # This is an optional parameter, default value is 999900. This is the number of requests that will be batched together before sending to kafka
KAFKA_BATCH_TIMEOUT=10000 # This is an optional parameter, default value is 10000. This is the time in milliseconds after which the batch will be sent to kafka
  1. Add confluent_kafka dependency in your requirements.txt file.
  2. Now you can start your application and the middleware will start working.

You can refer the sample_app.py to see how the middleware is integrated with a flask application.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •