Skip to content

Commit b261f84

Browse files
authored
Added v3 auth endpoints (#1335)
1 parent 29d37b4 commit b261f84

File tree

5 files changed

+92
-1
lines changed

5 files changed

+92
-1
lines changed

apps/authorization/v3/urls.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.urls import include, path, re_path
2+
from rest_framework.routers import DefaultRouter
3+
from apps.authorization.views import ExpireDataAccessGrantView, AuthorizedGrants
4+
from waffle.decorators import waffle_switch
5+
6+
router = DefaultRouter()
7+
router.register(r"tokens", AuthorizedGrants, basename="token")
8+
9+
urlpatterns = [
10+
path("", include((router.urls, "authorization"), namespace="token_management_v3")),
11+
re_path(
12+
r"^expire_authenticated_user/(?P<patient_id>[\-0-9]+)/$",
13+
waffle_switch("expire_grant_endpoint", "v3_endpoints")(ExpireDataAccessGrantView.as_view()),
14+
name="expire_access_grant",
15+
),
16+
]

apps/dot_ext/v3/urls.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from django.urls import path, re_path
2+
from oauth2_provider import views as oauth2_views
3+
from waffle.decorators import waffle_switch
4+
5+
from apps.dot_ext import views
6+
7+
8+
app_name = "oauth2_provider_v3"
9+
10+
11+
base_urlpatterns = [
12+
path("authorize/", waffle_switch("v3_endpoints")(views.AuthorizationView.as_view(version=3)), name="authorize-v3"),
13+
re_path(
14+
r"^authorize/(?P<uuid>[\w-]+)/$",
15+
waffle_switch("v3_endpoints")(views.ApprovalView.as_view(version=3)),
16+
name="authorize-instance-v3",
17+
),
18+
path("token/", waffle_switch("v3_endpoints")(views.TokenView.as_view()), name="token-v3"),
19+
path("revoke_token/", waffle_switch("v3_endpoints")(views.RevokeTokenView.as_view()), name="revoke-token-v3"),
20+
path("revoke/", waffle_switch("v3_endpoints")(views.RevokeView.as_view()), name="revoke-v3"),
21+
path("introspect/", waffle_switch("v3_endpoints")(views.IntrospectTokenView.as_view()), name="introspect-v3"),
22+
]
23+
24+
25+
management_urlpatterns = [
26+
# Application management views
27+
path("applications/", waffle_switch("v3_endpoints")(oauth2_views.ApplicationList.as_view()), name="list-v3"),
28+
path(
29+
"applications/register/",
30+
waffle_switch("v3_endpoints")(views.ApplicationRegistration.as_view()),
31+
name="register-v3",
32+
),
33+
re_path(
34+
r"^applications/(?P<pk>[\w-]+)/$",
35+
waffle_switch("v3_endpoints")(oauth2_views.ApplicationDetail.as_view()),
36+
name="detail-v3",
37+
),
38+
re_path(
39+
r"^applications/(?P<pk>[\w-]+)/delete/$",
40+
waffle_switch("v3_endpoints")(views.ApplicationDelete.as_view()),
41+
name="delete-v3",
42+
),
43+
re_path(
44+
r"^applications/(?P<pk>[\w-]+)/update/$",
45+
waffle_switch("v3_endpoints")(views.ApplicationUpdate.as_view()),
46+
name="update-v3",
47+
),
48+
# Token management views
49+
path(
50+
"authorized_tokens/",
51+
waffle_switch("v3_endpoints")(oauth2_views.AuthorizedTokensListView.as_view()),
52+
name="authorized-token-list-v3",
53+
),
54+
re_path(
55+
r"^authorized_tokens/(?P<pk>[\w-]+)/delete/$",
56+
waffle_switch("v3_endpoints")(oauth2_views.AuthorizedTokenDeleteView.as_view()),
57+
name="authorized-token-delete-v3",
58+
),
59+
]
60+
61+
62+
urlpatterns = base_urlpatterns + management_urlpatterns

apps/fhir/server/authentication.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,14 @@ def search_fhir_id_by_identifier(search_identifier, request=None):
7878

7979
# Build URL with patient ID search by identifier.
8080
ver = "v{}".format(request.session.get('version', 1))
81+
# Temp fixed to v2
82+
if ver == "v3":
83+
ver = "v2"
8184
url = f"{get_resourcerouter().fhir_url}/{ver}/fhir/Patient/_search"
8285

86+
# Temp reset to requested version
87+
ver = "v{}".format(request.session.get('version', 1))
88+
8389
max_retries = 3
8490
retries = 0
8591
env = os.environ.get('TARGET_ENV')

apps/mymedicare_cb/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ def callback(request, version=2):
133133
user=request.user)
134134

135135
# Only go back to app authorization
136-
url_map_name = 'oauth2_provider_v2:authorize-instance-v2' if version == 2 else 'oauth2_provider:authorize-instance'
136+
if version == 3:
137+
url_map_name = 'oauth2_provider_v3:authorize-instance-v3'
138+
elif version == 2:
139+
url_map_name = 'oauth2_provider_v2:authorize-instance-v2'
140+
else:
141+
url_map_name = 'oauth2_provider:authorize-instance'
137142
auth_uri = reverse(url_map_name, args=[approval.uuid])
138143

139144
_, _, auth_path, _, _ = urlsplit(auth_uri)

hhs_oauth_server/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
path("v3/fhir/", include("apps.fhir.bluebutton.v3.urls")),
4242
path("v2/o/", include("apps.dot_ext.v2.urls")),
4343
path("v2/o/", include("apps.authorization.v2.urls")),
44+
path("v3/o/", include("apps.dot_ext.v3.urls")),
45+
path("v3/o/", include("apps.authorization.v3.urls")),
4446
path("docs/", include("apps.docs.urls")),
4547
re_path(r"^" + ADMIN_REDIRECTOR + "admin/metrics/", include("apps.metrics.urls")),
4648
re_path(r"^" + ADMIN_REDIRECTOR + "admin/", admin.site.urls),

0 commit comments

Comments
 (0)