*: use request.query_params instead of accessing the django request

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-05 10:51:56 +01:00
parent 680ef641fb
commit 2b78c4ba86
3 changed files with 4 additions and 5 deletions

View File

@ -192,7 +192,7 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet):
secret=certificate, secret=certificate,
type="certificate", type="certificate",
).from_http(request) ).from_http(request)
if "download" in request._request.GET: if "download" in request.query_params:
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html # Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
response = HttpResponse( response = HttpResponse(
certificate.certificate_data, content_type="application/x-pem-file" certificate.certificate_data, content_type="application/x-pem-file"
@ -223,7 +223,7 @@ class CertificateKeyPairViewSet(UsedByMixin, ModelViewSet):
secret=certificate, secret=certificate,
type="private_key", type="private_key",
).from_http(request) ).from_http(request)
if "download" in request._request.GET: if "download" in request.query_params:
# Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html # Mime type from https://pki-tutorial.readthedocs.io/en/latest/mime.html
response = HttpResponse(certificate.key_data, content_type="application/x-pem-file") response = HttpResponse(certificate.key_data, content_type="application/x-pem-file")
response[ response[

View File

@ -123,7 +123,7 @@ class SAMLProviderViewSet(UsedByMixin, ModelViewSet):
raise Http404 raise Http404
try: try:
metadata = MetadataProcessor(provider, request).build_entity_descriptor() metadata = MetadataProcessor(provider, request).build_entity_descriptor()
if "download" in request._request.GET: if "download" in request.query_params:
response = HttpResponse(metadata, content_type="application/xml") response = HttpResponse(metadata, content_type="application/xml")
response[ response[
"Content-Disposition" "Content-Disposition"

View File

@ -10,7 +10,6 @@ from structlog.stdlib import get_logger
from authentik.core.exceptions import PropertyMappingExpressionException from authentik.core.exceptions import PropertyMappingExpressionException
from authentik.events.models import Event, EventAction from authentik.events.models import Event, EventAction
from authentik.lib.utils.errors import exception_to_string
from authentik.lib.utils.time import timedelta_from_string from authentik.lib.utils.time import timedelta_from_string
from authentik.providers.saml.models import SAMLPropertyMapping, SAMLProvider from authentik.providers.saml.models import SAMLPropertyMapping, SAMLProvider
from authentik.providers.saml.processors.request_parser import AuthNRequest from authentik.providers.saml.processors.request_parser import AuthNRequest
@ -106,7 +105,7 @@ class AssertionProcessor:
# Value error can be raised when assigning invalid data to an attribute # Value error can be raised when assigning invalid data to an attribute
Event.new( Event.new(
EventAction.CONFIGURATION_ERROR, EventAction.CONFIGURATION_ERROR,
message=f"Failed to evaluate property-mapping: {exception_to_string(exc)}", message=f"Failed to evaluate property-mapping: {str(exc)}",
mapping=mapping, mapping=mapping,
).from_http(self.http_request) ).from_http(self.http_request)
continue continue