Skip to content

Commit e016fa5

Browse files
alex-dzedaclewellyn-navajimmyfagan
authored
BB2-4729: Parsing updates (#1549)
* parsing id token updates * add test * fix lint issues * updated styling, added address parsing * reactivate iat, ial, and auth checks * Remove patient launch scope if applicable, adjust expiration to one hour * Pull scopes into constants * fix status codes and uncomment iat/ial * keep the bots happy (remove str(e)) --------- Co-authored-by: clewellyn-nava <connorlewellyn@navapbc.com> Co-authored-by: jimmyfagan <jimmyfagan@navapbc.com>
1 parent b1a4018 commit e016fa5

12 files changed

Lines changed: 1118 additions & 857 deletions

File tree

apps/authorization/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def update_expiration_date(self):
4848
) + relativedelta(months=+13)
4949
self.save()
5050

51-
def update_expiration_date_one_day(self) -> None:
51+
def update_expiration_date_one_hour(self) -> None:
5252
self.expiration_date = datetime.now().replace(
5353
tzinfo=pytz.UTC
54-
) + relativedelta(hours=+24)
54+
) + relativedelta(hours=+1)
5555
self.save()
5656

5757
def has_expired(self):
@@ -121,7 +121,7 @@ def create_or_update_data_access_grant_client_credential_flow(user, application)
121121
beneficiary=user,
122122
application=application,
123123
)
124-
data_access_grant.update_expiration_date_one_day()
124+
data_access_grant.update_expiration_date_one_hour()
125125
return data_access_grant
126126

127127

apps/capabilities/management/commands/create_blue_button_scopes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from apps.capabilities.constants import FHIR_PREFIX_CREATE_BLUE_BUTTON_SCOPES
88
from apps.capabilities.models import ProtectedCapability
99

10-
from apps.constants import HHS_SERVER_LOGNAME_FMT
10+
from apps.constants import HHS_SERVER_LOGNAME_FMT, LAUNCH_SCOPE, OPENID_SCOPE
1111

1212
logger = logging.getLogger(HHS_SERVER_LOGNAME_FMT.format(__name__))
1313

@@ -45,7 +45,7 @@ def create_openid_capability(group, title='Openid profile permissions.'):
4545
# Currently inert, but should be required with profile for profile information
4646
c = None
4747
description = 'Enables user authentication and provides a unique identifier with basic profile info.'
48-
scope_string = 'openid'
48+
scope_string = OPENID_SCOPE
4949
pr = []
5050

5151
if not ProtectedCapability.objects.filter(slug=scope_string).exists():
@@ -269,7 +269,7 @@ def create_launch_capability(group, FHIR_PREFIX_CREATE_BLUE_BUTTON_SCOPES, title
269269

270270
c = None
271271
description = 'Launch with FHIR Patient context.'
272-
smart_scope_string = 'launch/patient'
272+
smart_scope_string = LAUNCH_SCOPE
273273
pr = []
274274

275275
if not ProtectedCapability.objects.filter(slug=smart_scope_string).exists():

apps/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@
104104
],
105105
}
106106

107+
COVERAGE_SCOPE = "patient/Coverage.rs"
108+
PATIENT_SCOPE = "patient/Patient.rs"
109+
EOB_SCOPE = "patient/ExplanationOfBenefit.rs"
110+
OPENID_SCOPE = "openid"
111+
LAUNCH_SCOPE = "launch/patient"
112+
107113
OPERATION_OUTCOME = 'OperationOutcome'
108114

109115
USER_TYPE_BENEFICIARY = 'BEN'

apps/dot_ext/constants.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from apps.constants import LAUNCH_SCOPE, OPENID_SCOPE
23

34
# REGEX of paths that should be updated with auth flow info in hhs_oauth_server.request_logging.py
45
AUTH_FLOW_REQUEST_LOGGING_PATHS_REGEX = ('(^/v[1|2|3]/o/authorize/.*'
@@ -83,15 +84,15 @@
8384
'patient/Coverage.r',
8485
'patient/Coverage.s',
8586
'patient/Coverage.rs',
86-
'launch/patient',
87-
'openid'
87+
LAUNCH_SCOPE,
88+
OPENID_SCOPE
8889
]
8990
V2_SCOPES_ALL_CONDENSED = [
9091
'patient/Patient.rs',
9192
'patient/ExplanationOfBenefit.rs',
9293
'patient/Coverage.rs',
93-
'launch/patient',
94-
'openid'
94+
LAUNCH_SCOPE,
95+
OPENID_SCOPE
9596
]
9697
V2_SCOPES_NON_DEMOGRAPHIC = [
9798
'patient/ExplanationOfBenefit.r',
@@ -100,14 +101,14 @@
100101
'patient/Coverage.r',
101102
'patient/Coverage.s',
102103
'patient/Coverage.rs',
103-
'launch/patient',
104-
'openid'
104+
LAUNCH_SCOPE,
105+
OPENID_SCOPE
105106
]
106107
V2_SCOPES_NON_DEMOGRAPHIC_CONDENSED = [
107108
'patient/ExplanationOfBenefit.rs',
108109
'patient/Coverage.rs',
109-
'launch/patient',
110-
'openid'
110+
LAUNCH_SCOPE,
111+
OPENID_SCOPE
111112
]
112113

113114
# Scope to base URL PATH mapping.

apps/dot_ext/oauth2_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def my_token_expires_in(request):
3030
# oauth2_settings.ACCESS_TOKEN_EXPIRE_SECONDS
3131
# or one hour if the one_hour_token_expiry switch is active
3232
if expires_in is None:
33-
if switch_is_active("one_hour_token_expiry"):
33+
if switch_is_active("one_hour_token_expiry") or (grant_type[0] and grant_type[0] == CLIENT_CREDENTIALS):
3434
one_hour_delta = timedelta(hours=1)
3535
seconds_in_one_hour = int(one_hour_delta.total_seconds())
3636
expires_in = seconds_in_one_hour

0 commit comments

Comments
 (0)