-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: fetching of a secured Algolia key [BB-8083] #1
feat: fetching of a secured Algolia key [BB-8083] #1
Conversation
6943b36
to
477e8ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on this, @0x29a! It was a hell of a ride getting through the steps😛. But everything worked handsomely!
I left a small comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✅
- I tested this
- I read through the code
- Includes tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@0x29a, this is awesome!
👍
- I tested this: learners cannot modify their queries to retrieve catalogs from other organizations; the behavior of this MFE does not change as long as we have the
ALGOLIA_SEARCH_API_KEY
set - I read through the code
- I checked for accessibility issues: n/a
- Includes documentation: n/a
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-secure
repository: n/a
Description
Adds a fallback mechanism, so when the
ALGOLIA_SEARCH_API_KEY
environment variable is not set, the key is fetched from the endpoint defined by theALGOLIA_SECURED_KEY_ENDPOINT
environment variable. It expects this endpoint to return a JSON like:This is intended, but not limited to, to be used with open-craft/edx-enterprise#11.
Testing steps
We're going to test this PR, open-craft/edx-enterprise#11 and open-craft/edx-platform#602 at once by creating three courses and three enterprise customers, uploading them to Algolia through
enterprise-catalog
and checking that learners are able to browse catalogs of their enterprises with the help of this MFE, but unable to access courses of enterprises they don't belong to.Prerequisites
You'll need an Algolia account. Create an application and
enterprise-catalog
index. Write down the application id, admin API key, and search API key somewhere.Installing Palm devstack
After that:
cd ../edx-platform
ENTERPRISE_ALGOLIA_SEARCH_API_KEY = '<YOUR_ALGOLIA_SEARCH_(NOT ADMIN)_API_KEY>'
to the end oflms/envs/devstack.py
.Installing edx-enterprise fork
Installing enterprise-catalog
After that:
enterprise_catalog/apps/catalog/constants.py
and add'source'
to theCONTENT_PRODUCT_SOURCE_ALLOW_LIST
set.enterprise_catalog/settings/devstack.py
:make dev.provision
.Installing frontend-app-learner-portal-enterprise
Leave this terminal open, do all the remaining steps in a separate one.
Creating test entities
ABC
,XYZ
, andPSY
for all fields, like here:Course Start Date
andEnrollment Start Date
for each course here to01/01/2019
.verified
andaudit
course modes for each course here: http://localhost:18000/admin/course_modes/coursemode/Source
name here: http://localhost:18381/admin/course_metadata/source/add/ABC
toXYZ
andPSY
for each query.XXX
,YYY
,ZZZ
. Change their slugs respectively. CheckEnable learner portal
for each.XXX
should be assigned to the query selectingABC
course,YYY
->XYZ
andZZZ
->PSY.
Indexing
Go to the
<DEVSTACK_WORKSPACE>
and replaceDEFAULT_PRODUCT_SOURCE_SLUG = ''
withDEFAULT_PRODUCT_SOURCE_SLUG = 'source'
incourse_discovery/settings/base.py
.Then, go to the
<DEVSTACK_WORKSPACE>/devstack
directory run the following to pull the data from LMS to Course Discovery:export OPENEDX_RELEASE=palm.master make discovery-shell ./manage.py refresh_course_metadata
Then:
./manage.py populate_default_product_source ./manage.py update_index --disable-change-limit exit
Now we need to copy course queries and other enterprise-related data from LMS to
enterprise-catalog
. Run the following:This will fail, but it'll create a
enterprise_catalog_worker
user here. Go here and assignenterprise_catalog_admin
role to[email protected]
, don't forget to checkApplies to all contexts
.Now, run this again:
After that you should see three of your course queries here.
Now, go to the
<DEVSTACK_WORKSPACE>/enterprise-catalog
and run the following to fetch content metadata (courses and course runs) from Course Discovery:After that you should see
Course
andCourse Run
objects for each of your courses here. If you don't, then something went wrong. Also,Json metadata
for each course should contain a non-emptyadvertised_course_run_uuid
.Now you can upload all courses to Algolia:
If everything go fine, you should see three courses in your
enterprise-catalog
Algolia index.Enrolling users
[email protected]
.XXX
enterprise customer and clickManager Learners
(example of the admin panel URL).[email protected]
user to thecourse-v1:ABC+ABC+ABC
course. SpecifyAudit
track andtest
reason for manual enrollment.enterprise_worker
user will appear here. Assign theenterprise_catalog_admin
role to the[email protected]
user here (don't forget to checkApplies to all contexts
) and try point 3 again.YYY
enterprise customer andcourse-v1:XYZ+XYZ+XYZ
course, so we have a single learner present in two different enterprises.Testing frontend-app-learner-portal-enterprise
[email protected]
.http://localhost:8734
.[email protected]
, you should be offered to choose an organization. ChooseXXX
.ABC
course here.YYY
, you should see theXYZ
course.Now, open the browser dev tools and locate a query like this:
Edit and Resend
(that's for Firefox).Body
field and clickSend
:ABC
andXYZ
courses, omitting thePSY
course.Upstream PR
openedx#887