device-bound-sessions (981B)
1 import json 2 3 def main(request, response): 4 # Since the path to this file is .well-known, we can't use 5 # server-side substitution directly. Instead, get the value 6 # substitution would give us from `request`. 7 provider_domain = request.server.config.all_domains[''][''] 8 relying_domain = request.server.config.all_domains['']['www'] 9 10 provider_origin = f'https://{provider_domain}:{request.url_parts.port}' 11 relying_origin = f'https://{relying_domain}:{request.url_parts.port}' 12 13 host = request.headers.get('host').decode('utf-8') 14 response_body = None 15 if host.startswith(provider_domain): 16 response_body = { 17 "registering_origins": [relying_origin], 18 "relying_origins": [relying_origin], 19 } 20 elif host.startswith(relying_domain): 21 response_body = { 22 "provider_origin": provider_origin, 23 } 24 return (200, [('Content-Type', 'application/json')], 25 json.dumps(response_body))