99import apps .logging .request_logger as bb2logging
1010
1111logger = logging .getLogger (bb2logging .HHS_SERVER_LOGNAME_FMT .format (__name__ ))
12-
12+ SCOPES_SUPPORTED = ["profile" , "patient/Patient.read" , "patient/ExplanationOfBenefit.read" , "patient/Coverage.read" ]
13+ CODE_CHALLENGE_METHODS_SUPPORTED = ["S256" ]
14+ CAPABILITIES = [
15+ "client-confidential-symmetric" ,
16+ "sso-openid-connect" ,
17+ "launch-standalone" ,
18+ "permission-offline" ,
19+ "permission-patient" ,
20+ "permission-v1"
21+ ]
1322
1423@require_GET
1524def openid_configuration (request ):
@@ -22,6 +31,17 @@ def openid_configuration(request):
2231 data = build_endpoint_info (data , issuer = issuer , v2 = v2 )
2332 return JsonResponse (data )
2433
34+ @require_GET
35+ def smart_on_fhir_configuration (request ):
36+ """
37+ Views that returns smart_configuration.
38+ """
39+ data = OrderedDict ()
40+ issuer = base_issuer (request )
41+ v2 = request .path .endswith ('smart-configuration-v2' ) or request .path .endswith ('smartConfigV2' )
42+ data = build_smart_config_endpoint (data , issuer = issuer , v2 = v2 )
43+ return JsonResponse (data )
44+
2545
2646def base_issuer (request ):
2747 """
@@ -84,3 +104,20 @@ def build_endpoint_info(data=OrderedDict(), v2=False, issuer=""):
84104 data ["fhir_metadata_uri" ] = issuer + \
85105 reverse ('fhir_conformance_metadata' if not v2 else 'fhir_conformance_metadata_v2' )
86106 return data
107+
108+ def build_smart_config_endpoint (data = OrderedDict (), v2 = False , issuer = "" ):
109+ """
110+ construct the smart config endpoint response. Takes in
111+ issuer should be http: or https:// prefixed url.
112+
113+ :param data:
114+ :return:
115+ """
116+
117+ data = build_endpoint_info (data , issuer = issuer , v2 = v2 )
118+
119+ data ["scopes_supported" ] = SCOPES_SUPPORTED
120+ data ["code_challenge_methods_supported" ] = CODE_CHALLENGE_METHODS_SUPPORTED
121+ data ["capabilities" ] = CAPABILITIES
122+
123+ return data
0 commit comments