Skip to content

Commit acf7806

Browse files
committed
Merge branch 'base-path' of github.com:bajnokk/SATOSA into base-path
2 parents 416d501 + 91c0ac2 commit acf7806

File tree

6 files changed

+9
-16
lines changed

6 files changed

+9
-16
lines changed

src/satosa/frontends/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(self, auth_req_callback_func, internal_attributes, base_url, name):
3030
self.internal_attributes = internal_attributes
3131
self.converter = AttributeMapper(internal_attributes)
3232
self.base_url = base_url or ""
33+
self.base_path = urlparse(self.base_url).path.lstrip("/")
3334
self.name = name
3435
self.endpoint_baseurl = join_paths(self.base_url, self.name)
3536
self.endpoint_basepath = urlparse(self.endpoint_baseurl).path.lstrip("/")

src/satosa/frontends/saml2.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,12 @@ def _register_endpoints(self, providers):
512512
url_map = []
513513

514514
backend_providers = "|".join(providers)
515-
base_path = urlparse(self.base_url).path.lstrip("/")
516-
if base_path:
517-
base_path = base_path + "/"
518515
for endp_category in self.endpoints:
519516
for binding, endp in self.endpoints[endp_category].items():
520517
endp_path = urlparse(endp).path
521518
url_map.append(
522519
(
523-
"^{}({})/{}$".format(base_path, backend_providers, endp_path),
520+
"^{}/({})/{}$".format(self.base_path, backend_providers, endp_path),
524521
functools.partial(self.handle_authn_request, binding_in=binding)
525522
)
526523
)
@@ -770,15 +767,12 @@ def _register_endpoints(self, providers):
770767
url_map = []
771768

772769
backend_providers = "|".join(providers)
773-
base_path = urlparse(self.base_url).path.lstrip("/")
774-
if base_path:
775-
base_path = base_path + "/"
776770
for endp_category in self.endpoints:
777771
for binding, endp in self.endpoints[endp_category].items():
778772
endp_path = urlparse(endp).path
779773
url_map.append(
780774
(
781-
"^{}({})/\S+/{}$".format(base_path, backend_providers, endp_path),
775+
"^{}/({})/\S+/{}$".format(self.base_path, backend_providers, endp_path),
782776
functools.partial(self.handle_authn_request, binding_in=binding)
783777
)
784778
)

src/satosa/micro_services/account_linking.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ def register_endpoints(self):
165165
return [
166166
(
167167
"^{}$".format(
168-
join_paths(
169-
self.base_path, "account_linking", self.endpoint
170-
)
168+
join_paths(self.endpoint_basepath, self.endpoint)
171169
),
172170
self._handle_al_response,
173171
)

src/satosa/micro_services/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __init__(self, name, base_url, **kwargs):
1616
self.name = name
1717
self.base_url = base_url
1818
self.base_path = urlparse(base_url).path.lstrip("/")
19+
self.endpoint_baseurl = join_paths(self.base_url, self.name)
20+
self.endpoint_basepath = urlparse(self.endpoint_baseurl).path.lstrip("/")
1921
self.next = None
2022

2123
def process(self, context, data):

src/satosa/micro_services/consent.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ def register_endpoints(self):
242242
return [
243243
(
244244
"^{}$".format(
245-
join_paths(
246-
self.base_path, "consent", self.endpoint
247-
)
245+
join_paths(self.endpoint_basepath, self.endpoint)
248246
),
249247
self._handle_consent_response,
250248
)

src/satosa/routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class UnknownEndpoint(ValueError):
3838
and handles the internal routing between frontends and backends.
3939
"""
4040

41-
def __init__(self, frontends, backends, micro_services, base_path=""):
41+
def __init__(self, frontends, backends, micro_services, base_path=None):
4242
"""
4343
:type frontends: dict[str, satosa.frontends.base.FrontendModule]
4444
:type backends: dict[str, satosa.backends.base.BackendModule]
@@ -70,7 +70,7 @@ def __init__(self, frontends, backends, micro_services, base_path=""):
7070
else:
7171
self.micro_services = {}
7272

73-
self.base_path = base_path
73+
self.base_path = base_path if base_path else ""
7474

7575
logger.debug("Loaded backends with endpoints: {}".format(backends))
7676
logger.debug("Loaded frontends with endpoints: {}".format(frontends))

0 commit comments

Comments
 (0)