sources/saml: handle internal error

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-06 20:10:37 +02:00
parent ef63e35ad2
commit d51ecc4554
3 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,6 @@
"""Event notification tasks""" """Event notification tasks"""
from guardian.shortcuts import get_anonymous_user from guardian.shortcuts import get_anonymous_user
from structlog import get_logger from structlog.stdlib import get_logger
from authentik.core.models import User from authentik.core.models import User
from authentik.events.models import ( from authentik.events.models import (

View File

@ -13,7 +13,7 @@ from django.db.models.query_utils import Q
from django.db.utils import IntegrityError from django.db.utils import IntegrityError
from rest_framework.exceptions import ValidationError from rest_framework.exceptions import ValidationError
from rest_framework.serializers import BaseSerializer, Serializer from rest_framework.serializers import BaseSerializer, Serializer
from structlog import BoundLogger, get_logger from structlog.stdlib import BoundLogger, get_logger
from authentik.flows.models import Flow, FlowStageBinding, Stage from authentik.flows.models import Flow, FlowStageBinding, Stage
from authentik.flows.transfer.common import ( from authentik.flows.transfer.common import (

View File

@ -11,7 +11,8 @@ from django.utils.http import urlencode
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views import View from django.views import View
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from xmlsec import VerificationError from structlog.stdlib import get_logger
from xmlsec import InternalError, VerificationError
from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes from authentik.flows.challenge import Challenge, ChallengeResponse, ChallengeTypes
from authentik.flows.models import in_memory_stage from authentik.flows.models import in_memory_stage
@ -44,6 +45,7 @@ from authentik.stages.consent.stage import (
PLAN_CONTEXT_TITLE = "title" PLAN_CONTEXT_TITLE = "title"
PLAN_CONTEXT_URL = "url" PLAN_CONTEXT_URL = "url"
PLAN_CONTEXT_ATTRS = "attrs" PLAN_CONTEXT_ATTRS = "attrs"
LOGGER = get_logger()
class AutosubmitStageView(ChallengeStageView): class AutosubmitStageView(ChallengeStageView):
@ -125,7 +127,11 @@ class InitiateView(View):
final_url = urlunparse(res) final_url = urlunparse(res)
return redirect(final_url) return redirect(final_url)
# As POST Binding we show a form # As POST Binding we show a form
saml_request = nice64(auth_n_req.build_auth_n()) try:
saml_request = nice64(auth_n_req.build_auth_n())
except InternalError as exc:
LOGGER.warning(str(exc))
return bad_request_message(request, str(exc))
injected_stages = [] injected_stages = []
plan_kwargs = { plan_kwargs = {
PLAN_CONTEXT_TITLE: _("Redirecting to %(app)s..." % {"app": source.name}), PLAN_CONTEXT_TITLE: _("Redirecting to %(app)s..." % {"app": source.name}),