mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-08-19 09:30:21 +00:00
fix(api): enforce POST on SAML ACS endpoint (#12393)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
`/api/v1/accounts/saml/{organization_slug}/acs/` rejects non-POST requests before SAML response processing
|
||||
@@ -14673,6 +14673,37 @@ class TestSAMLConfigurationViewSet:
|
||||
assert not SAMLConfiguration.objects.filter(id=config.id).exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestSAMLACSView:
|
||||
def test_get_is_not_allowed(self, client, saml_setup):
|
||||
response = client.get(
|
||||
reverse(
|
||||
"saml_acs",
|
||||
kwargs={"organization_slug": saml_setup["domain"]},
|
||||
)
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED
|
||||
assert response.headers["Allow"] == "POST"
|
||||
assert "saml-acs-session" not in response.cookies
|
||||
|
||||
def test_post_is_forwarded_to_allauth(self, client, saml_setup):
|
||||
response = client.post(
|
||||
reverse(
|
||||
"saml_acs",
|
||||
kwargs={"organization_slug": saml_setup["domain"]},
|
||||
),
|
||||
data={"SAMLResponse": "test-saml-response"},
|
||||
)
|
||||
|
||||
assert response.status_code == status.HTTP_302_FOUND
|
||||
assert response.url == reverse(
|
||||
"saml_finish_acs",
|
||||
kwargs={"organization_slug": saml_setup["domain"]},
|
||||
)
|
||||
assert "saml-acs-session" in response.cookies
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestTenantFinishACSView:
|
||||
def test_dispatch_skips_if_user_not_authenticated(self, monkeypatch):
|
||||
|
||||
@@ -46,6 +46,7 @@ from api.v1.views import (
|
||||
from django.http import JsonResponse
|
||||
from django.urls import include, path
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST
|
||||
from drf_spectacular.views import SpectacularRedocView
|
||||
from rest_framework_nested import routers
|
||||
|
||||
@@ -194,7 +195,7 @@ urlpatterns = [
|
||||
),
|
||||
path(
|
||||
"accounts/saml/<organization_slug>/acs/",
|
||||
ACSView.as_view(),
|
||||
require_POST(ACSView.as_view()),
|
||||
name="saml_acs",
|
||||
),
|
||||
path(
|
||||
|
||||
Reference in New Issue
Block a user