Skip to content

Commit 2367e84

Browse files
Merge pull request #158 from skoranda/ping_frontend
First commit of the ping frontend
2 parents 3416276 + 4de80a8 commit 2367e84

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

doc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ for information on how to obtain them.
407407
A list of all user attributes released by Facebook can be found [here](https://developers.facebook.com/docs/graph-api/reference/v2.5/user),
408408
which should be used when configuring the attribute mapping (see above).
409409

410+
### Ping frontend for simple heartbeat monitoring
411+
412+
The ping frontend responds to a query with a simple
413+
200 OK and is intended to be used as a simple heartbeat monitor,
414+
for example by a load balancer. The default configuration file can
415+
be found [here](../example/plugins/frontends/ping_frontend.yaml.example).
416+
410417
### Micro services
411418

412419
Additional behaviour can be configured in the proxy through so called *micro services*. There are two different types
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module:
2+
ping.PingFrontend
3+
name:
4+
ping
5+
config:

src/satosa/frontends/ping.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import satosa.micro_services.base
2+
from satosa.logging_util import satosa_logging
3+
4+
from satosa.response import Response
5+
6+
import logging
7+
8+
logger = logging.getLogger(__name__)
9+
10+
class PingFrontend(satosa.frontends.base.FrontendModule):
11+
"""
12+
SATOSA frontend that responds to a query with a simple
13+
200 OK, intended to be used as a simple heartbeat monitor.
14+
"""
15+
logprefix = "PING:"
16+
17+
def __init__(self, auth_req_callback_func, internal_attributes, config, base_url, name):
18+
super().__init__(auth_req_callback_func, internal_attributes, base_url, name)
19+
20+
self.config = config
21+
22+
def handle_authn_response(self, context, internal_resp, extra_id_token_claims=None):
23+
"""
24+
See super class method satosa.frontends.base.FrontendModule#handle_authn_response
25+
:type context: satosa.context.Context
26+
:type internal_response: satosa.internal_data.InternalResponse
27+
:rtype oic.utils.http_util.Response
28+
"""
29+
raise NotImplementedError()
30+
31+
def handle_backend_error(self, exception):
32+
"""
33+
See super class satosa.frontends.base.FrontendModule
34+
:type exception: satosa.exception.SATOSAError
35+
:rtype: oic.utils.http_util.Response
36+
"""
37+
raise NotImplementedError()
38+
39+
def register_endpoints(self, backend_names):
40+
"""
41+
See super class satosa.frontends.base.FrontendModule
42+
:type backend_names: list[str]
43+
:rtype: list[(str, ((satosa.context.Context, Any) -> satosa.response.Response, Any))]
44+
:raise ValueError: if more than one backend is configured
45+
"""
46+
url_map = [("^{}".format(self.name), self.ping_endpoint)]
47+
48+
return url_map
49+
50+
def ping_endpoint(self, context):
51+
"""
52+
"""
53+
logprefix = PingFrontend.logprefix
54+
satosa_logging(logger, logging.DEBUG, "{} ping returning 200 OK".format(logprefix), context.state)
55+
56+
msg = " "
57+
58+
return Response(msg)

0 commit comments

Comments
 (0)