Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/wellknown/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from waffle.decorators import waffle_switch
from .views import (
openid_configuration,
smart_configuration,
ApplicationListView,
ApplicationLabelView,
PublicApplicationListView,
Expand All @@ -10,6 +11,7 @@

urlpatterns = [
path("openid-configuration", openid_configuration, name="openid-configuration"),
path("smart-configuration", smart_configuration, name="smart-configuration"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .well-known/smart-configuration should be relative to the base path of the server, eg v2/fhir/.well-known/smart-configuration for v2, v1/fhir/.well-known/smart-configuration for v1, per environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean. I'll have to do a bit more digging around to get it to have that pattern. Would we want to change openid-configuration to follow that pattern as well? It seems like it's the only one to have this current pattern. Swagger link for convenience: https://sandbox.bluebutton.cms.gov/docs/openapi#/v2/openIdConfig

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good team discussion topic. imo the value of a well-known url is that you can automatically discover it. As it stands today, I'd see the same problem for the OIDC config, since openid-configuration-v2 isn't really well-known.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I'll socialize this with the other engineers and see about making this happen

path(
"applications",
waffle_switch("wellknown_applications")(ApplicationListView.as_view()),
Expand All @@ -28,6 +30,9 @@
path(
"openid-configuration-v2", openid_configuration, name="openid-configuration-v2"
),
path(
"smart-configuration-v2", smart_configuration, name="smart-on-fhir-configuration-v2"
),
path(
"applications-v2",
waffle_switch("wellknown_applications")(ApplicationListView.as_view()),
Expand Down
2 changes: 1 addition & 1 deletion apps/wellknown/views/__init__.py
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
45 changes: 45 additions & 0 deletions apps/wellknown/views/openid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
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 = [
Copy link
Contributor

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

Copy link
Contributor Author

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.

"client-confidential-symmetric",
"sso-openid-connect",
"launch-standalone",
"permission-offline",
"permission-patient",
"permission-v1"
]


@require_GET
Expand All @@ -23,6 +33,18 @@ def openid_configuration(request):
return JsonResponse(data)


@require_GET
def smart_configuration(request):
"""
Views that returns smart_configuration.
"""
data = OrderedDict()
issuer = base_issuer(request)
v2 = request.path.endswith('smart-configuration-v2') or request.path.endswith('smartConfigV2')
data = build_smart_config_endpoint(data, issuer=issuer, v2=v2)
return JsonResponse(data)


def base_issuer(request):
"""
define the base url for issuer
Expand Down Expand Up @@ -84,3 +106,26 @@ def build_endpoint_info(data=OrderedDict(), v2=False, issuer=""):
data["fhir_metadata_uri"] = issuer + \
reverse('fhir_conformance_metadata' if not v2 else 'fhir_conformance_metadata_v2')
return data


def build_smart_config_endpoint(data=OrderedDict(), v2=False, 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, v2=v2)
del(data["userinfo_endpoint"])
del(data["ui_locales_supported"])
del(data["service_documentation"])
del(data["op_tos_uri"])
del(data["fhir_metadata_uri"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll want to add this in:

Suggested change
del(data["fhir_metadata_uri"])
del(data["fhir_metadata_uri"])
data["grant_types_supported"].remove("refresh_token")

Spec says for grant_types_supported:

The options are “authorization_code” (when SMART App Launch is supported) and “client_credentials” (when SMART Backend Services is supported).


data["scopes_supported"] = SCOPES_SUPPORTED
data["code_challenge_methods_supported"] = CODE_CHALLENGE_METHODS_SUPPORTED
data["capabilities"] = CAPABILITIES

return data
Loading