Skip to content

Commit 73f632d

Browse files
committed
fixup! PR IdentityPython#405: apply changes from review
1 parent acf7806 commit 73f632d

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/satosa/backends/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"""
44

55
from ..attribute_mapping import AttributeMapper
6+
from ..util import join_paths
7+
8+
from urllib.parse import urlparse
69

710

811
class BackendModule(object):
@@ -30,7 +33,10 @@ def __init__(self, auth_callback_func, internal_attributes, base_url, name):
3033
self.internal_attributes = internal_attributes
3134
self.converter = AttributeMapper(internal_attributes)
3235
self.base_url = base_url.rstrip("/") if base_url else ""
36+
self.base_path = urlparse(self.base_url).path.lstrip("/")
3337
self.name = name
38+
self.endpoint_baseurl = join_paths(self.base_url, self.name)
39+
self.endpoint_basepath = urlparse(self.endpoint_baseurl).path.lstrip("/")
3440

3541
def start_auth(self, context, internal_request):
3642
"""

src/satosa/frontends/saml2.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from ..response import Response
3434
from ..response import ServiceError
3535
from ..saml_util import make_saml_response
36+
from ..util import join_paths
3637
from satosa.exception import SATOSAError
3738
import satosa.util as util
3839

@@ -511,14 +512,18 @@ def _register_endpoints(self, providers):
511512
"""
512513
url_map = []
513514

514-
backend_providers = "|".join(providers)
515+
backend_providers = "(" + "|".join(providers) + ")"
515516
for endp_category in self.endpoints:
516517
for binding, endp in self.endpoints[endp_category].items():
517518
endp_path = urlparse(endp).path
518519
url_map.append(
519520
(
520-
"^{}/({})/{}$".format(self.base_path, backend_providers, endp_path),
521-
functools.partial(self.handle_authn_request, binding_in=binding)
521+
"^{}$".format(
522+
join_paths(self.base_path, backend_providers, endp_path)
523+
),
524+
functools.partial(
525+
self.handle_authn_request, binding_in=binding
526+
),
522527
)
523528
)
524529

@@ -766,14 +771,20 @@ def _register_endpoints(self, providers):
766771
"""
767772
url_map = []
768773

769-
backend_providers = "|".join(providers)
774+
backend_providers = "(" + "|".join(providers) + ")"
770775
for endp_category in self.endpoints:
771776
for binding, endp in self.endpoints[endp_category].items():
772777
endp_path = urlparse(endp).path
773778
url_map.append(
774779
(
775-
"^{}/({})/\S+/{}$".format(self.base_path, backend_providers, endp_path),
776-
functools.partial(self.handle_authn_request, binding_in=binding)
780+
"^{}$".format(
781+
join_paths(
782+
self.base_path, backend_providers, "\S+", endp_path
783+
)
784+
),
785+
functools.partial(
786+
self.handle_authn_request, binding_in=binding
787+
),
777788
)
778789
)
779790

src/satosa/micro_services/account_linking.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def register_endpoints(self):
165165
return [
166166
(
167167
"^{}$".format(
168-
join_paths(self.endpoint_basepath, self.endpoint)
168+
join_paths(self.base_path, "account_linking", self.endpoint)
169169
),
170170
self._handle_al_response,
171171
)

src/satosa/micro_services/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import logging
55
from urllib.parse import urlparse
66

7+
from ..util import join_paths
8+
79
logger = logging.getLogger(__name__)
810

911

src/satosa/micro_services/consent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def register_endpoints(self):
242242
return [
243243
(
244244
"^{}$".format(
245-
join_paths(self.endpoint_basepath, self.endpoint)
245+
join_paths(self.base_path, "consent", self.endpoint)
246246
),
247247
self._handle_consent_response,
248248
)

0 commit comments

Comments
 (0)