This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2019-11-07 16:02:56 +00:00
|
|
|
"""saml sp helpers"""
|
|
|
|
from django.http import HttpRequest
|
|
|
|
from django.shortcuts import reverse
|
|
|
|
|
|
|
|
from passbook.sources.saml.models import SAMLSource
|
|
|
|
|
|
|
|
|
2020-02-20 16:23:27 +00:00
|
|
|
def get_issuer(request: HttpRequest, source: SAMLSource) -> str:
|
|
|
|
"""Get Source's Issuer, falling back to our Metadata URL if none is set"""
|
|
|
|
issuer = source.issuer
|
|
|
|
if issuer is None:
|
2019-12-31 11:51:16 +00:00
|
|
|
return build_full_url("metadata", request, source)
|
2020-02-20 16:23:27 +00:00
|
|
|
return issuer
|
2019-11-07 16:02:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
def build_full_url(view: str, request: HttpRequest, source: SAMLSource) -> str:
|
|
|
|
"""Build Full ACS URL to be used in IDP"""
|
|
|
|
return request.build_absolute_uri(
|
2020-02-20 16:04:54 +00:00
|
|
|
reverse(f"passbook_sources_saml:{view}", kwargs={"source_slug": source.slug})
|
2019-12-31 11:51:16 +00:00
|
|
|
)
|