Skip to content
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

ABDM API for related mobile app #32332

Closed
wants to merge 115 commits into from
Closed

Conversation

akashkj
Copy link
Contributor

@akashkj akashkj commented Nov 11, 2022

Product Description

Reopened PR of #32194

Changes include:

  1. Expose API to be consumed by ABDM android application. These API endpoints internally communicate with the ABDM server to return the processed response to the caller ABDM android app.
  2. Authenticate new APIs with a custom token, which are having validity for ABDM API only.
  3. Provide ABDM auth token to the CommCare mobile app user on every sync. There is the future scope of adding validity to the token.

Technical Summary

https://docs.google.com/document/d/1gbQcAC3H4kj22iMCMMKSYMVO5_7kt56qiS8OWkd6e34/edit

Feature Flag

RESTORE_ADD_ABDM_TOKEN

Safety Assurance

Safety story

Manual testing in the local environment and dev instance of CommCare HQ deployed on Mumbai region.

Automated test coverage

[TODO]Automated unit tests

QA Plan

https://dimagi-dev.atlassian.net/browse/QA-4549

Migrations

  • The migrations in this code can be safely applied first independently of the code

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@dimagimon dimagimon added the reindex/migration Reindex or migration will be required during or before deploy label Nov 11, 2022
@akashkj akashkj marked this pull request as draft November 11, 2022 06:43
@akashkj akashkj added awaiting QA QA in progress. Do not merge product/custom Change will only impact users on a single project labels Nov 11, 2022
@akashkj akashkj marked this pull request as ready for review November 11, 2022 06:51
@akashkj akashkj added QA Passed and removed awaiting QA QA in progress. Do not merge labels Nov 11, 2022
@akashkj akashkj requested a review from mkangia November 11, 2022 07:20
@akashkj akashkj changed the title Akj/abdm api for mobile app ABDM API for related mobile app Nov 11, 2022
Copy link
Contributor

@mkangia mkangia left a comment

Choose a reason for hiding this comment

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

Took a first pass. Need to understand it better to review properly. Will offline.

@@ -0,0 +1,44 @@
import logging
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the motivation behind having a module called "milestone_one"? I understand this is the first for 3 stages in terms of implementations but does it need to reflect in code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All milestones have different usecases and if there is need to add or remove certain usecases, based on certifications received, it will be easier to locate the code milestone wise.

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 a README for milestone one? To explain things like

  1. what is ABHA?
  2. what is the ABDM mobile app?
  3. what interaction happen between CommCare App and HQ?
  4. A quick summary of how ABDM mobile app works with the CommCare App or a link if its written elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can we take that as supplementary change for another PR as I believe that should be more formal and researched. We will require to pick content from mobile app's doc.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool.



def generate_aadhar_otp(aadhaar_number):
generate_aadhar_otp_url = "v1/registration/aadhaar/generateOtp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these URLs be constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved


def required_request_params(params: List[str]):
"""
A version of the requires_privilege decorator which raises an Http404
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand the reference to requires_privilege function here. Is that needed?
The name of the function seems good enough to me to signify what it does, so does not look like it needs any documentation at all too.

Copy link
Contributor Author

@akashkj akashkj Nov 24, 2022

Choose a reason for hiding this comment

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

Yes, it is copy paste residue, was removed.

def wrapped(request, *args, **kwargs):
if not (params and isinstance(params, List)):
error_msg = f"Request {request} could not be validated as validation input not provided."
logger.warning(error_msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed? Guessing this was added during development?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kept to audit invalid requests. Any harm in retaining?

Copy link
Contributor

Choose a reason for hiding this comment

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

this would be in the logs where it would get removed from time to time. You would need something permanent if its for audit later.

settings.py Outdated
@@ -2015,6 +2020,9 @@ def _pkce_required(client_id):

REST_FRAMEWORK = {
'DATETIME_FORMAT': '%Y-%m-%dT%H:%M:%S.%fZ',
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
Copy link
Contributor

Choose a reason for hiding this comment

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

what all does this impact outside of the abdm app?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is removed.

@@ -65,6 +66,7 @@
'util.TransientBounceEmail',
'registration.AsyncSignupRequest',
'users.UserHistory',
'custom.abdm.models.ABDMUser',
Copy link
Contributor

Choose a reason for hiding this comment

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

why should this be ignored?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems strange that this is included in dump but ignored during deletion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected, it should be included in deletion flow.

"""
A version of the requires_privilege decorator which raises an Http404
if PermissionDenied is raised.
Checks if the parameters provided in the decorator(a list of strings) are present in the DRF request.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Are these sensitive enough that they should be present in the request header and not in the params?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are in the POST body of request. Do you mean something else, which I misinterpreted?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay.
I think its the term parameters that is being used. I would always think of these as params that are a part of the URL.
A better name could be required_request_data or required_request_post_data. Not sure what a better name could be for params.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CONTRIBUTING.rst Outdated
Contributing to CommCareHQ
==========================
===========================
Contributing to CommCare HQ
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think we need CommCareHQ only.

Copy link
Contributor

Choose a reason for hiding this comment

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

This commit looks like things went wrong here?

@akashkj akashkj removed the QA Passed label May 31, 2023
@dimagimon dimagimon added the Risk: Medium Change affects files that have been flagged as medium risk. label Jul 10, 2023
@ajeety4
Copy link
Contributor

ajeety4 commented Jul 10, 2023

Updated this m1 branch with abdm-audit to account of m1 changes that were addressed recently.

@snopoke
Copy link
Contributor

snopoke commented Jul 12, 2023

I'm not sure what's up with the PR diff but I'm seeing changes from other branches. Perhaps try merge master?

@ajeety4
Copy link
Contributor

ajeety4 commented Jul 12, 2023

I'm not sure what's up with the PR diff but I'm seeing changes from other branches. Perhaps try merge master?

Yes we did integrated some changes from other branches.
Also, as we plan to separate out this work on a independent repostory (later to be integrated as an HQ extension probably) I am going to close this PR.

@mkangia
Copy link
Contributor

mkangia commented Jul 12, 2023

Hey @snopoke

we don't intend to merge this into master. This PR is just to see the changes we have made for an long on-going integration effort.
We would extract this piece out entirely of HQ through extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/custom Change will only impact users on a single project reindex/migration Reindex or migration will be required during or before deploy Risk: Medium Change affects files that have been flagged as medium risk.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants