Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
daryllimyt committed Jan 11, 2025
2 parents 377afb4 + a227781 commit 7332d4e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tracecat/auth/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
XMLSEC_BINARY_PATH,
)
from tracecat.logger import logger
from tracecat.settings.service import get_setting

router = APIRouter(prefix="/auth/saml", tags=["auth"])

Expand Down Expand Up @@ -114,12 +115,21 @@ def parse_to_dict(self) -> dict[str, Any]:
return attributes


def create_saml_client() -> Saml2Client:
if not SAML_IDP_METADATA_URL:
async def create_saml_client() -> Saml2Client:
saml_idp_metadata_url = await get_setting(
"saml_idp_metadata_url",
default=SAML_IDP_METADATA_URL,
)
if not saml_idp_metadata_url:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="SAML SSO metadata URL has not been configured.",
)
if not isinstance(saml_idp_metadata_url, str):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="SAML SSO metadata URL is not a string.",
)

saml_settings = {
"strict": True,
Expand All @@ -146,7 +156,7 @@ def create_saml_client() -> Saml2Client:
"metadata": {
"remote": [
{
"url": SAML_IDP_METADATA_URL,
"url": saml_idp_metadata_url,
}
]
},
Expand Down

0 comments on commit 7332d4e

Please sign in to comment.