Skip to content

Commit

Permalink
fixup! PR IdentityPython#405: apply changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
bajnokk committed Jun 13, 2023
1 parent acf7806 commit 73f632d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/satosa/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"""

from ..attribute_mapping import AttributeMapper
from ..util import join_paths

from urllib.parse import urlparse


class BackendModule(object):
Expand Down Expand Up @@ -30,7 +33,10 @@ def __init__(self, auth_callback_func, internal_attributes, base_url, name):
self.internal_attributes = internal_attributes
self.converter = AttributeMapper(internal_attributes)
self.base_url = base_url.rstrip("/") if base_url else ""
self.base_path = urlparse(self.base_url).path.lstrip("/")
self.name = name
self.endpoint_baseurl = join_paths(self.base_url, self.name)
self.endpoint_basepath = urlparse(self.endpoint_baseurl).path.lstrip("/")

def start_auth(self, context, internal_request):
"""
Expand Down
23 changes: 17 additions & 6 deletions src/satosa/frontends/saml2.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ..response import Response
from ..response import ServiceError
from ..saml_util import make_saml_response
from ..util import join_paths
from satosa.exception import SATOSAError
import satosa.util as util

Expand Down Expand Up @@ -511,14 +512,18 @@ def _register_endpoints(self, providers):
"""
url_map = []

backend_providers = "|".join(providers)
backend_providers = "(" + "|".join(providers) + ")"
for endp_category in self.endpoints:
for binding, endp in self.endpoints[endp_category].items():
endp_path = urlparse(endp).path
url_map.append(
(
"^{}/({})/{}$".format(self.base_path, backend_providers, endp_path),
functools.partial(self.handle_authn_request, binding_in=binding)
"^{}$".format(
join_paths(self.base_path, backend_providers, endp_path)
),
functools.partial(
self.handle_authn_request, binding_in=binding
),
)
)

Expand Down Expand Up @@ -766,14 +771,20 @@ def _register_endpoints(self, providers):
"""
url_map = []

backend_providers = "|".join(providers)
backend_providers = "(" + "|".join(providers) + ")"
for endp_category in self.endpoints:
for binding, endp in self.endpoints[endp_category].items():
endp_path = urlparse(endp).path
url_map.append(
(
"^{}/({})/\S+/{}$".format(self.base_path, backend_providers, endp_path),
functools.partial(self.handle_authn_request, binding_in=binding)
"^{}$".format(
join_paths(
self.base_path, backend_providers, "\S+", endp_path
)
),
functools.partial(
self.handle_authn_request, binding_in=binding
),
)
)

Expand Down
2 changes: 1 addition & 1 deletion src/satosa/micro_services/account_linking.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def register_endpoints(self):
return [
(
"^{}$".format(
join_paths(self.endpoint_basepath, self.endpoint)
join_paths(self.base_path, "account_linking", self.endpoint)
),
self._handle_al_response,
)
Expand Down
2 changes: 2 additions & 0 deletions src/satosa/micro_services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
from urllib.parse import urlparse

from ..util import join_paths

logger = logging.getLogger(__name__)


Expand Down
2 changes: 1 addition & 1 deletion src/satosa/micro_services/consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def register_endpoints(self):
return [
(
"^{}$".format(
join_paths(self.endpoint_basepath, self.endpoint)
join_paths(self.base_path, "consent", self.endpoint)
),
self._handle_consent_response,
)
Expand Down

0 comments on commit 73f632d

Please sign in to comment.