-
Notifications
You must be signed in to change notification settings - Fork 28
BB2-4250: Make v3_endpoints waffle switch app specific #1429
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 1 commit
eb64ae9
499d00a
0699b7d
423bb30
801d5ca
62c3d1c
5c35c40
916de16
ebd6c64
7657a4d
8345457
d89d507
0b3f054
1f83723
1e184af
ef0efae
eb306ce
73e0cb5
314ab24
8b69aea
1268a71
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 |
|---|---|---|
|
|
@@ -91,6 +91,8 @@ class AuthorizationView(DotAuthorizationView): | |
| # TODO: rename this so that it isn't the same as self.version (works but confusing) | ||
| # this needs to be here for urls.py as_view(version) calls, but don't use it | ||
| version = 0 | ||
| # Variable to help reduce the amount of times validate_v3_authorization_request is called | ||
| validate_v3_call = True | ||
| form_class = SimpleAllowForm | ||
| login_url = "/mymedicare/login" | ||
|
|
||
|
|
@@ -149,6 +151,11 @@ def dispatch(self, request, *args, **kwargs): | |
| initially create an AuthFlowUuid object for authorization | ||
| flow tracing in logs. | ||
| """ | ||
| path_info = self.request.__dict__.get('path_info') | ||
| version = get_api_version_number_from_url(path_info) | ||
| # If it is not version 3, we don't need to check anything, just return | ||
| if version == Versions.V3 and self.validate_v3_call: | ||
| self.validate_v3_authorization_request() | ||
|
||
| # TODO: Should the client_id match a valid application here before continuing, instead of after matching to FHIR_ID? | ||
| if not kwargs.get('is_subclass_approvalview', False): | ||
| # Create new authorization flow trace UUID in session and AuthFlowUuid instance, if subclass is not ApprovalView | ||
|
|
@@ -241,7 +248,11 @@ def validate_v3_authorization_request(self): | |
| try: | ||
| application = get_application_model().objects.get(client_id=client_id[0]) | ||
| application_user = get_user_model().objects.get(id=application.user_id) | ||
| if flag.id is not None and flag.is_active_for_user(application_user): | ||
|
|
||
| if flag.id is None or flag.is_active_for_user(application_user): | ||
| # Update the class variable to ensure subsequent calls to dispatch don't call this function | ||
| # more times than is needed | ||
| self.validate_v3_call = False | ||
| return | ||
| else: | ||
| raise AccessDeniedTokenCustomError( | ||
|
|
@@ -292,11 +303,6 @@ def form_valid(self, form): | |
| refresh_token_delete_cnt = 0 | ||
|
|
||
| try: | ||
| path_info = self.request.__dict__.get('path_info') | ||
| version = get_api_version_number_from_url(path_info) | ||
| # If it is not version 3, we don't need to check anything, just return | ||
| if version == Versions.V3: | ||
| self.validate_v3_authorization_request() | ||
|
|
||
| if not scopes: | ||
| # Since the create_authorization_response will re-inject scopes even when none are | ||
|
|
@@ -456,7 +462,7 @@ def validate_v3_token_call(self, request) -> None: | |
| application = get_application_model().objects.get(id=refresh_token.application_id) | ||
| application_user = get_user_model().objects.get(id=application.user_id) | ||
|
|
||
| if flag.id is not None and flag.is_active_for_user(application_user): | ||
| if flag.id is None or flag.is_active_for_user(application_user): | ||
| return | ||
| else: | ||
| raise PermissionDenied( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.