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-6339): RAS visa validation #933

Merged
merged 18 commits into from
Jun 16, 2021
Merged

(PXP-6339): RAS visa validation #933

merged 18 commits into from
Jun 16, 2021

Conversation

vpsx
Copy link
Contributor

@vpsx vpsx commented Jun 9, 2021

Jira Ticket: PXP-6339

minor version bump to 5.2.0

New Features

Breaking Changes

Bug Fixes

Improvements

Dependency updates

Deployment changes

  • By default Fence will allow only visas issued by RAS staging, RAS prod, and itself; if a different set of allowed visa issuers is needed, edit the GA4GH_VISA_ISSUER_ALLOWLIST config value. Otherwise, no action needed.

@github-actions
Copy link

github-actions bot commented Jun 9, 2021

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 Jun 9, 2021

Pull Request Test Coverage Report for Build 11239

  • 48 of 72 (66.67%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.08%) to 71.044%

Changes Missing Coverage Covered Lines Changed/Added Lines %
fence/blueprints/login/ras.py 5 17 29.41%
fence/resources/openid/ras_oauth2.py 41 53 77.36%
Files with Coverage Reduction New Missed Lines %
fence/resources/openid/ras_oauth2.py 1 53.44%
Totals Coverage Status
Change from base Build 11233: -0.08%
Covered Lines: 6178
Relevant Lines: 8696

💛 - Coveralls

@vpsx vpsx force-pushed the feat/visa-validate branch 2 times, most recently from c774b71 to 5ff476c Compare June 10, 2021 16:08
@vpsx vpsx changed the title Feat/visa validate (PXP-6339): RAS visa validation Jun 10, 2021
)
continue # Not raise: If visa malformed, does not make sense to retry

# See if pkey is in cronjob cache; if not, update cache.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: Most of this code is very similar to the code from this recent authutils commit.

The authutils utils rely on keeping a public key cache in the flask app context, and the cronjob runs without one, so this code is here.

The plan is to implement a more persistent cache than this, so here I have taken the simplest and dumbest approach of just repeating much of the authutils code instead of refactoring authutils.

decoded_visa = validate_jwt(
encoded_visa,
public_key,
# Embedded token must not contain aud claim
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 based on the AAI spec?

Copy link
Contributor Author

@vpsx vpsx Jun 10, 2021

Choose a reason for hiding this comment

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

@@ -134,7 +134,7 @@ def test_update_visa_token(
},
}

headers = {"kid": kid_2}
headers = {"kid": kid}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I couldn't tell if there was a particular reason to be using a different key for the second visa, so figured I'd just use the same one to reduce noise/readability and make it more evident what is being tested. But if I simply missed something, I can definitely switch this back.

Same goes for the rest of this file!

@@ -824,6 +824,9 @@ ASSUME_ROLE_CACHE_SECONDS: 1800

# RAS refresh_tokens expire in 15 days
RAS_REFRESH_EXPIRATION: 1296000
# List of JWT issuers from which Fence will accept GA4GH visas
GA4GH_VISA_ISSUER_WHITELIST: []
Copy link
Contributor

Choose a reason for hiding this comment

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

can this populate itself with the "issuers" from well-known for configured logins on startup? might be overkill, but would be really convenient to not have to keep this up to date. Or, maybe even just adding the RAS issuer and ourselves into the default 🤷‍♂️ ?

Copy link
Contributor

Choose a reason for hiding this comment

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

def post_process(self):
post process of cfg could maybe shoot out requests to get issuers and populate this, idk, maybe that is overkill. Not all IDPs are GA4GH brokers. But I think "hard coding" RAS and us in the default would make sense and be more convenient for deployments

Copy link
Contributor Author

@vpsx vpsx Jun 10, 2021

Choose a reason for hiding this comment

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

Oh I figured more explicit was better for a visa whitelist but I can look into this--do you mean like, on app startup, maybe during the client init, hit all of the configured idps' well-known endpoints and add(?) the "issuer" values to this config value?
(Edit: 🤦‍♂️ only saw the first comment, GH didn't refresh with the second)(I'm slightly leaning towards the second approach, partly because the first approach might become sort of an anti-feature if we ever want to exclude an idp from being a visa issuer, partly just because KISS)

Otherwise if taking the second approach--that sounds fine; would you use stsstg or prod RAS or both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, very good points. For the second approach, we should probably add both? whatever issuers RAS has for staging and prod

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! Minor suggestion, I've been trying to move towards "ALLOWLIST" vs "WHITELIST" but up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Word! Thank you 🙏

Copy link
Contributor

@Avantol13 Avantol13 left a comment

Choose a reason for hiding this comment

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

see comments

@vpsx vpsx force-pushed the feat/visa-validate branch 3 times, most recently from b4d02cf to a868796 Compare June 15, 2021 15:49
@PlanXCyborg PlanXCyborg added test-apis-dbgapTest test-google-googleDataAccessTest setting label to retry specific feature and removed test-google-googleDataAccessTest setting label to retry specific feature labels Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants