providers/saml: fix SAML metadata import API requiring flow slug inst… (#6729)

* providers/saml: fix SAML metadata import API requiring flow slug instead of pk

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* replace format_exc_info with dict_tracebacks, and only for json logger

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-09-01 12:59:25 +02:00 committed by GitHub
parent 8f219a813b
commit a39fef11b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 11 deletions

View File

@ -13,10 +13,9 @@ from rest_framework.decorators import action
from rest_framework.fields import CharField, FileField, SerializerMethodField
from rest_framework.parsers import MultiPartParser
from rest_framework.permissions import AllowAny
from rest_framework.relations import SlugRelatedField
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.serializers import ValidationError
from rest_framework.serializers import PrimaryKeyRelatedField, ValidationError
from rest_framework.viewsets import ModelViewSet
from structlog.stdlib import get_logger
@ -168,10 +167,8 @@ class SAMLProviderImportSerializer(PassiveSerializer):
"""Import saml provider from XML Metadata"""
name = CharField(required=True)
# Using SlugField because https://github.com/OpenAPITools/openapi-generator/issues/3278
authorization_flow = SlugRelatedField(
authorization_flow = PrimaryKeyRelatedField(
queryset=Flow.objects.filter(designation=FlowDesignation.AUTHORIZATION),
slug_field="slug",
)
file = FileField()

View File

@ -89,7 +89,7 @@ class TestSAMLProviderAPI(APITestCase):
{
"file": metadata,
"name": generate_id(),
"authorization_flow": create_test_flow(FlowDesignation.AUTHORIZATION).slug,
"authorization_flow": create_test_flow(FlowDesignation.AUTHORIZATION).pk,
},
format="multipart",
)
@ -106,7 +106,7 @@ class TestSAMLProviderAPI(APITestCase):
{
"file": metadata,
"name": generate_id(),
"authorization_flow": create_test_flow().slug,
"authorization_flow": create_test_flow().pk,
},
format="multipart",
)

View File

@ -402,7 +402,6 @@ LOG_PRE_CHAIN = [
structlog.stdlib.add_logger_name,
structlog.processors.TimeStamper(),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
]
LOGGING = {
@ -412,7 +411,7 @@ LOGGING = {
"json": {
"()": structlog.stdlib.ProcessorFormatter,
"processor": structlog.processors.JSONRenderer(sort_keys=True),
"foreign_pre_chain": LOG_PRE_CHAIN,
"foreign_pre_chain": LOG_PRE_CHAIN + [structlog.processors.dict_tracebacks],
},
"console": {
"()": structlog.stdlib.ProcessorFormatter,

View File

@ -38459,8 +38459,7 @@ components:
minLength: 1
authorization_flow:
type: string
minLength: 1
description: Visible in the URL.
format: uuid
file:
type: string
format: binary