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

[PAY-2842][PAY-2780][PAY-3069] Fix authorized endpoints not supporting manager mode #8646

Merged
merged 7 commits into from
May 31, 2024

Conversation

schottra
Copy link
Contributor

@schottra schottra commented May 29, 2024

Description

This updates the auth_middleware to encapsulate some of the logic we had previously been doing outside of it and adds the ability to check authorization for a request against a user or any of their managers.

I removed all instances of abort_forbidden() in favor of using auth_middleware() with require_auth=True and then following up with the check_authorized() utility. Also fixed a few instances of using the authed_user_id for a request instead of the value passed in the URL. This results in the request returning the wrong results when called as a managed user.

Also added support to audius-cmd for creating a manager relationship, as this allowed me to test against local stack using purely cURL.

How Has This Been Tested?

Used audius-cmd against local stack to create two users and a management relationship. Then used cURL to verify that I can make requests to all endpoints which were using the abort_forbidden() pattern to ensure that:

  • Request is allowed when user_id matches authed_user_id (auth headers decode into the same user as the one passed in URL params)
  • Request is allowed when authed_user_id matches an active manager for the user_id in question
  • Request is denied with a 401 if no auth headers are passed
  • Request is denied with a 403 if auth headers correspond to a different user than user_id and said user is not a manager of user_id.

schottra added 3 commits May 29, 2024 15:57
…-pay-and-earn

* origin/main:
  Create Apps Dev Docs link updated (#8492)
  Fix typos (#8620)
  Fix album tile playback (#8637)
  [C-4451] Add feature flag and switch for edit track redesign (#8639)
  Fix copy (#8640)
  Add DPID and party name info to distro docs (#8638)
  [C-4237] Fix create notification when track is published (#8634)
  Fix chromecast support, again (#8636)
  Audius Protocol v0.6.114
  ⚠️ [C-4416, C-4418, C-4419 C-4322] Fast SSR (#8603)
  PROTO-1846: add discovery listens status to healthz (#8631)
  [QA-1226] Add missing tier info (#8635)
  Fix first track in lineup playback issue (#8632)
  [QA-1321] Show spinner for audio balance if rpc call fails (#8630)
  [C-4417] Add a buffering metric (#8619)
  Replace structuredClone with cloneDeep for native compat (#8633)
  [PROTO-1802] Add DDEX entrypoint UI deep link (#8374)
Copy link

changeset-bot bot commented May 29, 2024

⚠️ No Changeset found

Latest commit: b57f985

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

gitguardian bot commented May 29, 2024

⚠️ GitGuardian has uncovered 6 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
11080650 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.stage View secret
11080650 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.stage View secret
11080650 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.dev View secret
11080650 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.dev View secret
11080651 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.prod View secret
11080651 Triggered Generic High Entropy Secret 4d204fb packages/embed/.env.prod View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Copy link
Member

@raymondjacobson raymondjacobson left a comment

Choose a reason for hiding this comment

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

seems reasonable to me !
comments on the owner/all/authenticated enum would be super useful. not sure what they had meant at face value

packages/discovery-provider/src/utils/auth_middleware.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/utils/auth_middleware.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rickyrombo rickyrombo left a comment

Choose a reason for hiding this comment

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

Left a bunch of (non-blocking) thoughts! Let me know what you think

packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/api/v1/transactions.py Outdated Show resolved Hide resolved
packages/discovery-provider/src/utils/auth_middleware.py Outdated Show resolved Hide resolved
Copy link
Contributor

@rickyrombo rickyrombo left a comment

Choose a reason for hiding this comment

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

Nice! I like this a lot better!

@schottra schottra marked this pull request as ready for review May 30, 2024 19:00
@schottra
Copy link
Contributor Author

@rickyrombo @raymondjacobson I tried to write some tests for the access checker and ran into a bunch of issues with circular imports. I think our import structure is such that it only works if you're importing the whole flask app :-(.
I'm going to punt on those for now as I think it would require a more elaborate setup to get a handful of tests written.

schottra added 2 commits May 30, 2024 15:57
…-pay-and-earn

* origin/main:
  [C-4353] Add recent searches to search v2 (#8615)
  [QA-1335] Fix embed for non-premium tracks (#8658)
  Upgrade mobile apps to .99 (#8655)
  Fix sdk typecheck (#8656)
  [C-4427] react-native-video rough POC (#8654)
  Small fix to static image imports (#8653)
  Version Packages (#8189)
  [C-4309] Add ssr metatags (#8649)
  Audius Protocol v0.6.115
  Move EditTrackForm to edit-track component directory (#8641)
  [C-4320] Add web mobile profile page for SSR (#8642)
  [QA-1330] Fix mobile track edit button (#8644)
  [QA-1325] Fix playing icon position (#8643)
@schottra schottra changed the title [PAY-2842] Fix transactions endpoints not supporting manager mode [PAY-2842][PAY-2780] Fix transactions endpoints not supporting manager mode May 30, 2024
@schottra schottra changed the title [PAY-2842][PAY-2780] Fix transactions endpoints not supporting manager mode [PAY-2842][PAY-2780][PAY-3069] Fix authorized endpoints not supporting manager mode May 30, 2024
@schottra schottra enabled auto-merge (squash) May 30, 2024 20:29
@schottra schottra disabled auto-merge May 31, 2024 14:36
@schottra schottra merged commit 7343561 into main May 31, 2024
11 of 12 checks passed
@schottra schottra deleted the pay-2842-manager-mode-pay-and-earn branch May 31, 2024 14:37
audius-infra pushed a commit that referenced this pull request May 31, 2024
[7343561] [PAY-2842][PAY-2780][PAY-3069] Fix authorized endpoints not supporting manager mode (#8646) Randy Schott
[ddaa1b3] ⚠️ Third Party Wallet Support [PAY-2949][PAY-2948][PAY-2950] (#8611) Marcus Pasell
[c15f20d] Fix prod mediorum dockerfile to have keyfinder dependency (#8666) Michelle Brier
[7fe9451] Fix solana-relay logging, fix eslint config (#8663) Marcus Pasell
[a495f42] [C-4453] Fix notification email image and layout (#8647) Isaac Solo
[2ceae28] Audio analysis: mediorum changes (#8536) Michelle Brier
[15a34b3] [C-4353] Add recent searches to search v2 (#8615) Sebastian Klingler
[0050b29] Fix sdk typecheck (#8656) Sebastian Klingler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants