Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/utils.py
Show All 16 Lines | |||||
from prometheus_client.registry import CollectorRegistry | from prometheus_client.registry import CollectorRegistry | ||||
from django.http import HttpRequest, QueryDict | from django.http import HttpRequest, QueryDict | ||||
from django.urls import reverse as django_reverse | from django.urls import reverse as django_reverse | ||||
from rest_framework.authentication import SessionAuthentication | from rest_framework.authentication import SessionAuthentication | ||||
from swh.web.common.exc import BadInputExc | from swh.web.common.exc import BadInputExc | ||||
from swh.web.common.typing import QueryParameters | from swh.web.common.typing import QueryParameters | ||||
from swh.web.config import get_config | from swh.web.config import ORIGIN_VISIT_TYPES, get_config | ||||
SWH_WEB_METRICS_REGISTRY = CollectorRegistry(auto_describe=True) | SWH_WEB_METRICS_REGISTRY = CollectorRegistry(auto_describe=True) | ||||
swh_object_icons = { | swh_object_icons = { | ||||
"alias": "mdi mdi-star", | "alias": "mdi mdi-star", | ||||
"branch": "mdi mdi-source-branch", | "branch": "mdi mdi-source-branch", | ||||
"branches": "mdi mdi-source-branch", | "branches": "mdi mdi-source-branch", | ||||
"content": "mdi mdi-file-document", | "content": "mdi mdi-file-document", | ||||
▲ Show 20 Lines • Show All 234 Lines • ▼ Show 20 Lines | return { | ||||
"DJANGO_SETTINGS_MODULE": os.environ["DJANGO_SETTINGS_MODULE"], | "DJANGO_SETTINGS_MODULE": os.environ["DJANGO_SETTINGS_MODULE"], | ||||
"status": config["status"], | "status": config["status"], | ||||
"swh_web_staging": any( | "swh_web_staging": any( | ||||
[ | [ | ||||
server_name in site_base_url | server_name in site_base_url | ||||
for server_name in config["staging_server_names"] | for server_name in config["staging_server_names"] | ||||
] | ] | ||||
), | ), | ||||
"visit_types": ORIGIN_VISIT_TYPES, | |||||
} | } | ||||
class EnforceCSRFAuthentication(SessionAuthentication): | class EnforceCSRFAuthentication(SessionAuthentication): | ||||
""" | """ | ||||
Helper class to enforce CSRF validation on a DRF view | Helper class to enforce CSRF validation on a DRF view | ||||
when a user is not authenticated. | when a user is not authenticated. | ||||
""" | """ | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |