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

(PXP-7166): use ras validation endpoint to validate passports #849

Closed
wants to merge 11 commits into from

Conversation

BinamB
Copy link
Contributor

@BinamB BinamB commented Nov 23, 2020

If the passport is not valid then don't add it to the database.

New Features

  • Validate RAS passports using RAS's /passport/validation endpoint.

@github-actions
Copy link

The style in this PR agrees with black. ✔️

This formatting comment was generated automatically by a script in uc-cdis/wool.

@coveralls
Copy link

coveralls commented Nov 23, 2020

Pull Request Test Coverage Report for Build 10121

  • 9 of 20 (45.0%) changed or added relevant lines in 1 file are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.06%) to 68.646%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fence/resources/openid/ras_oauth2.py 9 20 45.0%
Files with Coverage Reduction New Missed Lines %
fence/resources/openid/ras_oauth2.py 3 47.37%
Totals Coverage Status
Change from base Build 10089: -0.06%
Covered Lines: 5434
Relevant Lines: 7916

💛 - Coveralls

"""
Validate passport with RAS's validation endpoint.
TODO: Remove this once we can locally validate passports
NOTE: RAS has an option to query a single visa with the /passport/validate?visa= but not using these since we hit the limit for an http header pretty quick
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NOTE: RAS has an option to query a single visa with the /passport/validate?visa= but not using these since we hit the limit for an http header pretty quick
NOTE: RAS has an option to validate a single visa using "/passport/validate?visa=". Not using this since visas are too large (we hit the http header limit)

"""
Validate passport with RAS's validation endpoint.
TODO: Remove this once we can locally validate passports
NOTE: RAS has an option to query a single visa with the /passport/validate?visa= but not using these since we hit the limit for an http header pretty quick
Copy link
Contributor

Choose a reason for hiding this comment

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

and can you mention why we would want to validate a single visa in the first place

@@ -93,7 +110,16 @@ def get_user_id(self, code):
self.logger.info("Using {} field as username.".format(field_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.logger.info("Using {} field as username.".format(field_name))
self.logger.debug("Using {} field as username.".format(field_name))

flask.g.userinfo = userinfo
flask.g.userinfo = {}
if validation == "Valid":
self.logger.info("Passport validated")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self.logger.info("Passport validated")
self.logger.debug("Passport validated")


token = self.get_token(token_endpoint, code)
keys = self.get_jwt_keys(jwks_endpoint)
userinfo = self.get_userinfo(token, userinfo_endpoint)

validation = self.validate_passport(validation_endpoint, userinfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

this probably slows down the login flow, do we really need to validate a passport freshly obtained from RAS' userinfo endpoint?

Comment on lines +158 to +160
encoded_visas = (
userinfo.get("ga4gh_passport_v1", []) if validation == "Valid" else []
)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this 🗑️

@BinamB BinamB closed this Jun 12, 2024
@BinamB BinamB deleted the feat/add_ras_validation_endpt branch June 12, 2024 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants