Skip to content

fix: validate authz perms with studio instead of LMS#2947

Merged
bradenmacdonald merged 2 commits intoopenedx:masterfrom
mitodl:asad/request-to-cms-for-authz-perms
Mar 30, 2026
Merged

fix: validate authz perms with studio instead of LMS#2947
bradenmacdonald merged 2 commits intoopenedx:masterfrom
mitodl:asad/request-to-cms-for-authz-perms

Conversation

@asadali145
Copy link
Copy Markdown
Contributor

Description

Calls studio API for Authz permission check instead of LMS to avoid Cross origin request

Testing instructions

  • Visit the v2 library and monitor the network tab http://studio.local.openedx.io:8001/api/authz/v1/permissions/validate/me
  • It should return 200

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 17, 2026
@openedx-webhooks
Copy link
Copy Markdown

Thanks for the pull request, @asadali145!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.56%. Comparing base (df79861) to head (1023739).
⚠️ Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2947      +/-   ##
==========================================
+ Coverage   95.51%   95.56%   +0.04%     
==========================================
  Files        1329     1349      +20     
  Lines       30557    31126     +569     
  Branches     6713     7069     +356     
==========================================
+ Hits        29186    29745     +559     
- Misses       1315     1319       +4     
- Partials       56       62       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Mar 23, 2026
@asadali145
Copy link
Copy Markdown
Contributor Author

@bradenmacdonald can you please review this PR?

Copy link
Copy Markdown
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

Makes sense to me, but I'm not super familiar with this. @rodmgwgu can you take a quick look?

Comment thread src/authz/data/api.ts Outdated

const { data }: { data: PermissionValidationResponseItem[] } = await getAuthenticatedHttpClient().post(
getApiUrl('/api/authz/v1/permissions/validate/me'),
getStudioApiUrl('/api/authz/v1/permissions/validate/me'),
Copy link
Copy Markdown
Contributor

@bradenmacdonald bradenmacdonald Mar 27, 2026

Choose a reason for hiding this comment

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

This appears to be the only use of getApiUrl, so can you just delete it entirely? Actually I think you can delete the whole utils.ts file, and just move getStudioApiUrl into this file, and/or get rid of it altogether. It's not really necessary as it's also only used in one place. If we do keep it, I think it should be refactored as auth-specific like const getAuthApiUrl = (path: string = '') => ${getConfig().STUDIO_BASE_URL}/api/authz/${path}; and kept in the api.ts file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @bradenmacdonald, I kept the unused intentionally as getStudioApiUrl was also there unused, but I have removed it now and refactored the code.

Copy link
Copy Markdown
Contributor

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Good catch, makes total sense, thanks!

@bradenmacdonald bradenmacdonald merged commit 87f8290 into openedx:master Mar 30, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants