api: allow configuring default page_size and max_page_size (#18158)

This commit is contained in:
Nuno Alves
2025-11-14 22:31:13 +00:00
parent d94117a8e3
commit eb2b8ca8e2
4 changed files with 16 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ from rest_framework import pagination
from rest_framework.response import Response
from authentik.api.v3.schema.response import PAGINATION
from authentik.lib.config import CONFIG
class Pagination(pagination.PageNumberPagination):
@@ -12,6 +13,7 @@ class Pagination(pagination.PageNumberPagination):
page_query_param = "page"
page_size_query_param = "page_size"
max_page_size = CONFIG.get("pagination.max_page_size")
def get_paginated_response(self, data):
previous_page_number = 0

View File

@@ -92,6 +92,9 @@ throttle:
device: 20/hour
default: 1000/second
pagination:
page_size: 100
outposts:
# Placeholders:
# %(type)s: Outpost type; proxy, ldap, etc

View File

@@ -205,7 +205,7 @@ SPECTACULAR_SETTINGS = {
REST_FRAMEWORK = {
"DEFAULT_PAGINATION_CLASS": "authentik.api.pagination.Pagination",
"PAGE_SIZE": 100,
"PAGE_SIZE": CONFIG.get("pagination.page_size", 100),
"DEFAULT_FILTER_BACKENDS": [
"authentik.rbac.filters.ObjectFilter",
"django_filters.rest_framework.DjangoFilterBackend",

View File

@@ -483,6 +483,16 @@ Configure how long unauthenticated sessions last for. Does not impact how long a
Defaults to `days=1`.
### `AUTHENTIK_PAGINATION__PAGE_SIZE`:ak-version[2026.2]
Configure the default number of items per page returned on paginated endpoints.
Defaults to `100`.
### `AUTHENTIK_PAGINATION__MAX_PAGE_SIZE`:ak-version[2026.2]
Configure the maximum number of items per page returned on paginated endpoints.
### `AUTHENTIK_WEB__WORKERS`
Configure how many gunicorn worker processes should be started (see https://docs.gunicorn.org/en/stable/design.html).