-
Notifications
You must be signed in to change notification settings - Fork 28
adding smart on fhir configuration endpoint #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c086578
af7ce06
e585d92
2b414fb
83109af
e5ebec8
910390d
9f323b0
c389c2b
b6c5e3c
29a14c3
8850518
98862ea
84e7332
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| from .openid import openid_configuration, base_issuer, build_endpoint_info # NOQA | ||
| from .openid import openid_configuration, smart_configuration, base_issuer, build_endpoint_info # NOQA | ||
| from .application import ApplicationListView, ApplicationLabelView # NOQA | ||
| from .public_applications import ApplicationListView as PublicApplicationListView # NOQA |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,17 @@ | |
| import apps.logging.request_logger as bb2logging | ||
|
|
||
| logger = logging.getLogger(bb2logging.HHS_SERVER_LOGNAME_FMT.format(__name__)) | ||
| SCOPES_SUPPORTED = ["profile", "patient/Patient.read", "patient/ExplanationOfBenefit.read", "patient/Coverage.read"] | ||
| CODE_CHALLENGE_METHODS_SUPPORTED = ["S256"] | ||
| CAPABILITIES = [ | ||
| "client-confidential-symmetric", | ||
| "sso-openid-connect", | ||
| "launch-standalone", | ||
| "permission-offline", | ||
| "permission-patient", | ||
| "permission-v1", | ||
| "authorize-post" | ||
| ] | ||
|
|
||
|
|
||
| @require_GET | ||
|
|
@@ -18,8 +29,18 @@ def openid_configuration(request): | |
| """ | ||
| data = OrderedDict() | ||
| issuer = base_issuer(request) | ||
| v2 = request.path.endswith('openid-configuration-v2') or request.path.endswith('openidConfigV2') | ||
| data = build_endpoint_info(data, issuer=issuer, v2=v2) | ||
| data = build_endpoint_info(data, issuer=issuer) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With OIDC v2 feeding through the normal endpoint now, can you also update the swagger page to remove the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there already a follow up ticket to add the smart config to the swagger doc? If so, we can save this adjustment for that if that's preferred, if not, we should either make a ticket, or include the smart config updates to swagger docs as part of this PR. |
||
| return JsonResponse(data) | ||
|
|
||
|
|
||
| @require_GET | ||
| def smart_configuration(request): | ||
| """ | ||
| Views that returns smart_configuration. | ||
| """ | ||
| data = OrderedDict() | ||
| issuer = base_issuer(request) | ||
| data = build_smart_config_endpoint(data, issuer=issuer) | ||
| return JsonResponse(data) | ||
|
|
||
|
|
||
|
|
@@ -50,7 +71,7 @@ def base_issuer(request): | |
| return issuer | ||
|
|
||
|
|
||
| def build_endpoint_info(data=OrderedDict(), v2=False, issuer=""): | ||
| def build_endpoint_info(data=OrderedDict(), issuer=""): | ||
| """ | ||
| construct the data package | ||
| issuer should be http: or https:// prefixed url. | ||
|
|
@@ -60,12 +81,12 @@ def build_endpoint_info(data=OrderedDict(), v2=False, issuer=""): | |
| """ | ||
| data["issuer"] = issuer | ||
| data["authorization_endpoint"] = issuer + \ | ||
| reverse('oauth2_provider:authorize' if not v2 else 'oauth2_provider_v2:authorize-v2') | ||
| data["revocation_endpoint"] = issuer + reverse('oauth2_provider:revoke') | ||
| reverse('oauth2_provider_v2:authorize-v2') | ||
| data["revocation_endpoint"] = issuer + reverse('oauth2_provider_v2:revoke-token-v2') | ||
| data["token_endpoint"] = issuer + \ | ||
| reverse('oauth2_provider:token' if not v2 else 'oauth2_provider_v2:token-v2') | ||
| reverse('oauth2_provider_v2:token-v2') | ||
| data["userinfo_endpoint"] = issuer + \ | ||
| reverse('openid_connect_userinfo' if not v2 else 'openid_connect_userinfo_v2') | ||
| reverse('openid_connect_userinfo_v2') | ||
| data["ui_locales_supported"] = ["en-US", ] | ||
| data["service_documentation"] = getattr(settings, | ||
| 'DEVELOPER_DOCS_URI', | ||
|
|
@@ -82,5 +103,29 @@ def build_endpoint_info(data=OrderedDict(), v2=False, issuer=""): | |
|
|
||
| data["response_types_supported"] = ["code", "token"] | ||
| data["fhir_metadata_uri"] = issuer + \ | ||
| reverse('fhir_conformance_metadata' if not v2 else 'fhir_conformance_metadata_v2') | ||
| reverse('fhir_conformance_metadata_v2') | ||
| return data | ||
|
|
||
|
|
||
| def build_smart_config_endpoint(data=OrderedDict(), issuer=""): | ||
| """ | ||
| construct the smart config endpoint response. Takes in output of build_endpoint_info since they share many fields | ||
| issuer should be http: or https:// prefixed url. | ||
|
|
||
| :param data: | ||
| :return: | ||
| """ | ||
|
|
||
| data = build_endpoint_info(data, issuer=issuer) | ||
| del (data["userinfo_endpoint"]) | ||
| del (data["ui_locales_supported"]) | ||
| del (data["service_documentation"]) | ||
| del (data["op_tos_uri"]) | ||
| del (data["fhir_metadata_uri"]) | ||
| data["grant_types_supported"].remove("refresh_token") | ||
|
|
||
| data["scopes_supported"] = SCOPES_SUPPORTED | ||
| data["code_challenge_methods_supported"] = CODE_CHALLENGE_METHODS_SUPPORTED | ||
| data["capabilities"] = CAPABILITIES | ||
|
|
||
| return data | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add "authorize-post"? looks like that one would also fit within the existing, supported capabilities of BB2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add that now.