Select Git revision
script.py.mako
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
api_example_config.py 4.10 KiB
# Defaults for development, do not use in production!
DEBUG = True
# Name of this instance
API_SERVER_NAME = "dev"
# Prefix which is prepended to paths (which are saved in the database) before they are provided by the api
# Must include the last /
FILE_PATH_PREFIX = "https://video.fsmpi.rwth-aachen.de/files/"
# Used for all cookies
# While the frontend and api are on different subdomains, that still counts as 'same-site'
COOKIES_SAMESITE = "strict"
COOKIES_SECURE = False
COOKIES_DOMAIN = ""
# These are flask's options for the session cookie
SESSION_COOKIE_SAMESITE = COOKIES_SAMESITE
SESSION_COOKIE_SECURE = COOKIES_SECURE
SESSION_COOKIE_DOMAIN = COOKIES_DOMAIN
# Used by flask to sign the cookies
SECRET_KEY = "something random"
# Scheduler should only be disabled for unit tests
DISABLE_SCHEDULER = False
DB_DATA = "../config/db_example_data.sql"
DB_CONNECTIONS = {
# Maximum amount of concurrent open connections
"max_count": 10,
# How many connections should be readonly. Only relevant if readonly cannot be set per transaction (only applies to
# sqlite right now)
"readonly_percent": 0.75,
# Maximum time to wait for a free connection (An API request will probably fail if this times out)
"max_wait_time_sec": 10,
# Maximum amount of transaction requests which may wait concurrently. More incoming requests will fail immediately
"max_waiting_count": 25,
# Maximum amount of attempts for a read transaction if there are conflicts between the transactions
"max_read_attempts": 2,
# Maximum amount of attempts for a write transaction if there are conflicts between the transactions
"max_write_attempts": 2
}
DATABASE = {
"engine": "postgres",
"postgres": {
"host": "database",
"port": 9343,
"user": "videoag",
"password": "videoag",
"database": "videoag",
"auto_migration": True,
"ignore_no_connection": False,
},
"log_all_statements": True # TODO
}
# This is host based. It uses a simple counter. For example for a window size of one hour, every hour the specified
# amount of requests can be made
# Limits are checked and updated in the order specified. Short limits should be checked first (Otherwise the
# longer limit is used up by request which have been blocked by the shorter limit)
# id is used in diagnostics
API_GLOBAL_RATE_LIMIT = [
{
"id": "short",
"window_size_seconds": 60,
"max_request_count": 60
},
{
"id": "long",
"window_size_seconds": 60 * 60,
"max_request_count": 600
}
]
# Works the same as global but used for authentication requests
API_AUTH_RATE_LIMIT = [
{
"id": "short",
"window_size_seconds": 10 * 60,
"max_request_count": 8
},
{
"id": "long",
"window_size_seconds": 4 * 60 * 60,
"max_request_count": 24
}
]
# Absolute limit. If there are already 32 chapters (visible or not visible), no more suggestions are accepted
API_CHAPTER_SUGGESTIONS_LIMIT_PER_LECTURE = 32
# This is NOT host based but globally. It uses a sliding window. For example for a window size of 24 hours, no more than
# the specified amount of requests can be made in last 24 hours. The interval size specifies how often the window 'slides'
API_CHAPTER_SUGGESTIONS_RATE_LIMIT = {
"window_size_seconds": 24 * 60 * 60,
"interval_size_seconds": 10 * 60,
"max_request_count": 600
}
DEFAULT_CACHE_CONTROL_MAX_AGE_SECONDS = 5 * 60
API_DIAGNOSTICS_HISTORY_SIZE_MINUTES = 7 * 24 * 60
API_DIAGNOSTICS_INTERVAL_SIZE_MINUTES = 30
LIVE_CONFIG_UPDATE_INTERVAL_SECONDS = 60
# LDAP_HOST = "auth.fsmpi.rwth-aachen.de"
LDAP_PORT = 636
LDAP_GROUPS = ["fachschaft"]
# RWTH_API_KEY = ""
RWTH_IP_RANGES = ["134.130.0.0/16", "137.226.0.0/16", "134.61.0.0/16", "192.35.229.0/24", "2a00:8a60::/32"]
FSMPI_IP_RANGES = ["137.226.35.192/29", "137.226.75.0/27", "137.226.127.32/27", "137.226.231.192/26", "134.130.102.0/26", "127.0.0.1/32"]
INTERNAL_IP_RANGES = ["127.0.0.0/8", "192.168.155.0/24", "fd78:4d90:6fe4::/48"]
# Only for debugging. In percent, from 0 to 100. With this you need luck to make a request
# API_ROULETTE_MODE = 0