-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): serve SAML metadata using custom frontend
- Loading branch information
1 parent
e9c1909
commit 2d56640
Showing
6 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module: static_content.StaticContentFrontend | ||
name: idp_metadata | ||
config: | ||
file: frontend.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module: static_content.StaticContentFrontend | ||
name: sp_metadata | ||
config: | ||
file: backend.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from setuptools import setup | ||
|
||
setup( | ||
name='static_content', | ||
version='0.0.1', | ||
install_requires=[ | ||
'satosa' | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import logging | ||
|
||
import satosa.logging_util as lu | ||
import satosa.frontends.base | ||
from satosa.response import Response | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class StaticContentFrontend(satosa.frontends.base.FrontendModule): | ||
""" | ||
A simple file server for SATOSA | ||
""" | ||
|
||
def __init__(self, auth_req_callback_func, internal_attributes, config, base_url, name): | ||
super().__init__(auth_req_callback_func, internal_attributes, base_url, name) | ||
self.config = config | ||
|
||
def handle_authn_response(self, context, internal_resp, extra_id_token_claims=None): | ||
""" | ||
See super class method satosa.frontends.base.FrontendModule#handle_authn_response | ||
:type context: satosa.context.Context | ||
:type internal_response: satosa.internal.InternalData | ||
:rtype oic.utils.http_util.Response | ||
""" | ||
raise NotImplementedError() | ||
|
||
def handle_backend_error(self, exception): | ||
""" | ||
See super class satosa.frontends.base.FrontendModule | ||
:type exception: satosa.exception.SATOSAError | ||
:rtype: oic.utils.http_util.Response | ||
""" | ||
raise NotImplementedError() | ||
|
||
def register_endpoints(self, backend_names): | ||
""" | ||
See super class satosa.frontends.base.FrontendModule | ||
:type backend_names: list[str] | ||
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))] | ||
:raise ValueError: if more than one backend is configured | ||
""" | ||
url_map = [("^{}".format(self.name), self.static_content_endpoint)] | ||
return url_map | ||
|
||
def static_content_endpoint(self, context): | ||
""" | ||
""" | ||
msg = f"Static content returning {self.config['file']}" | ||
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg) | ||
logger.debug(logline) | ||
file = open(self.config['file'], 'r') | ||
msg = file.read() | ||
return Response(msg) |