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

feat: per-user secured Algolia API keys [BB-8083] #11

Merged

Conversation

0x29a
Copy link
Member

@0x29a 0x29a commented Nov 10, 2023

Description

Adds a new endpoint that generates a secured Algolia API key capable of retrieving only data that is associated with enterprises linked to a requesting user. This is useful when you want to isolate enterprise learners, so they can't modify underlying Algolia requests to fetch the whole index content.

Testing steps

See open-craft/frontend-app-learner-portal-enterprise#1

Upstream PR

openedx#1962

@0x29a 0x29a force-pushed the 0x29a/bb8083/per-user-algolia-key branch 2 times, most recently from b0a1b23 to 4d582c2 Compare November 14, 2023 16:02
@0x29a 0x29a changed the title feat: per-user secured Algolia API keys feat: per-user secured Algolia API keys [BB-8083] Nov 14, 2023
Copy link

@CefBoud CefBoud left a 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

Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

👍

enterprise/api/v1/views.py Outdated Show resolved Hide resolved
enterprise/api/v1/views.py Outdated Show resolved Hide resolved
enterprise/api/v1/views.py Show resolved Hide resolved
enterprise/api/v1/views.py Outdated Show resolved Hide resolved
enterprise/api/v1/views.py Outdated Show resolved Hide resolved
Comment on lines +532 to +533
Returns an Algolia API key that is secured to only allow searching for
objects associated with enterprise customers that the user is linked to.
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to mention that we use this in the frontend-app-learner-portal-enterprise?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍


username = 'test_learner_portal_user'
self.create_user(username=username, is_staff=False)
self.client.login(username=username, password=TEST_PASSWORD)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: could you please add an assert for the AnonymousUser (i.e., before we log in)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done 👍

@0x29a 0x29a force-pushed the 0x29a/bb8083/per-user-algolia-key branch from b74eb6f to 87c69f5 Compare November 17, 2023 13:10
Co-authored-by: Piotr Surowiec <piotr@surowiec.it>
@0x29a 0x29a force-pushed the 0x29a/bb8083/per-user-algolia-key branch from 87c69f5 to 3c9c3dc Compare November 17, 2023 13:14
@Agrendalath Agrendalath merged commit f538e88 into opencraft-release/palm.1 Nov 21, 2023
8 checks passed
@Agrendalath Agrendalath deleted the 0x29a/bb8083/per-user-algolia-key branch November 21, 2023 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants