This repository was archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathread_registration.py
More file actions
46 lines (36 loc) · 1.39 KB
/
read_registration.py
File metadata and controls
46 lines (36 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging
from oidcmsg import oidc
from oidcmsg.message import Message
from oidcmsg.oauth2 import ResponseMessage
from oidcservice.service import Service
LOGGER = logging.getLogger(__name__)
class RegistrationRead(Service):
msg_type = Message
response_cls = oidc.RegistrationResponse
error_msg = ResponseMessage
synchronous = True
service_name = 'registration_read'
http_method = 'GET'
default_authn_method = 'client_secret_basic'
def get_endpoint(self):
try:
return self.service_context.get('registration_response')["registration_client_uri"]
except KeyError:
return ''
def get_authn_header(self, request, authn_method, **kwargs):
"""
Construct an authorization specification to be sent in the
HTTP header.
:param request: The service request
:param authn_method: Which authentication/authorization method to use
:param kwargs: Extra keyword arguments
:return: A set of keyword arguments to be sent in the HTTP header.
"""
headers = {}
if authn_method == "client_secret_basic":
LOGGER.debug("Client authn method: %s", authn_method)
headers["Authorization"] = "Bearer {}".format(
self.service_context.get('registration_response')[
"registration_access_token"]
)
return headers