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

Aspects Reports (embedded Superset dashboards): internal authentication error for staff and superusers #925

Open
pkolyvas opened this issue Aug 27, 2024 · 6 comments

Comments

@pkolyvas
Copy link

Issue

I followed the instructions on a bone-stock 17.0.6 tutor install (due to two different bugs in 18.0 - 18.1.3). My installation is scripted and parameterized here, so it was easy to get to a repeatable, stock install.

As per my thread here there is an internal authentication error when an educator or staff member tries to view the embedded reports dashboards on the LMS Instructor Reports tab.

Screenshot 2024-08-26 at 11 34 07 AM

Screenshot 2024-08-26 at 11 34 30 AM

Affected versions

I've run tutor 17.0.6 and every version of 18 from 18.0.0 to 18.1.3. The issue persists across all versions.

Expected behaviour

Pretty straightforward here. Following the instructions for installation should result in the reports (embedded superset dashboards) loading.

Additional details

  • Ubuntu 24.04 Server
  • amd64 arch
  • No additional customization

Originally I was worried that installing aspects before tutor had be launched the first time was causing the issue, so I experiment with installing it both during initial config and after tutor had been running with courses and users for a bit, however the authentication issue persists irrespective of the order in which it's installed.

@Ian2012
Copy link
Contributor

Ian2012 commented Aug 30, 2024

Hi @pkolyvas, can you leave the following information:

  • Configured dashboard locales: tutor config printvalue SUPERSET_DASHBOARD_LOCALES
  • Logs related to platform-plugin-aspects when you load the Aspects instructor tab.
  • Check in the requests what's returned for the guest token URL, you should see something similar to this:
    image

@bmtcril
Copy link
Contributor

bmtcril commented Oct 3, 2024

Hi @pkolyvas have you been able to sort out your issue, or can you reply to @Ian2012 's comment above? We haven't been able to reproduce this, so will have to close the issue if we don't hear back.

@pkolyvas
Copy link
Author

pkolyvas commented Oct 8, 2024

Hey - sorry we had moved on, but the issue persists. I'll try to set aside some time this week to gather the required information and update the issue. Still persistent on multiple installs with Tutor/Redwood.

@bmtcril
Copy link
Contributor

bmtcril commented Oct 10, 2024

I'm not sure if the gist is up to date, but I don't see anywhere in your setup script where you're installing or initializing Aspects. I do see Cairn in there, and if you're installing both that may be your problem. As far as I know they don't both work together.

@ghassanmas
Copy link
Member

I stumbled upon here while encountering similar problem.

The problem for us was, that we are using multi-tenant/Site configuration, such that the instructor dashboard could be accessed from a domain different than LMS_ROOT_URL . Thus request to fetch token, would fail if the origin of the page != LMS_ROOT_URL.

To fix it for us, rather than using LMS_ROOT_URL, I relied on LMS_ROOT_URL that is realted to course org. I am not sure if this would be accepted in such case. This the patch that fixes it nonetheless.

Note: applying the above patch, you need to ensure that course is being accessed from a microsite of which the org belongs to, however you could get away from that restriction, by using the origin of the request to build the guest_token_url, but probably other security measure need to be taken into consdiration such that it's accssed from a knowen host/origin i.e. ALLOWED_HOSTS.

ghassanmas added a commit to Abstract-Tech/platform-plugin-aspects that referenced this issue Nov 13, 2024
 This URL of fetching guest_token is always LMS_ROOT_URL, however
 in case multisite is being used the guest could be in a different
 url. This change ensure that cookie is being sent if the other
 site is a subdomain or shares parent domain with LMS_URL_ROOT

 This might be realted to openedx/tutor-contrib-aspects/issues/925
@ghassanmas
Copy link
Member

Also there is a simpler solutoin if microsite is just a subdomain of LMS_ROOT_URL, then this patch shall do it

diff --git a/platform_plugin_aspects/static/js/embed_dashboard.js b/platform_plugin_aspects/static/js/embed_dashboard.js
index 5555c62..1b169d0 100644
--- a/platform_plugin_aspects/static/js/embed_dashboard.js
+++ b/platform_plugin_aspects/static/js/embed_dashboard.js
@@ -30,6 +30,7 @@ async function fetchGuestToken() {
     headers: {
       "X-CSRFToken": getCookie("csrftoken"),
     },
+    credentials: 'include',
     body: body,
   }); 

This beacuse fetch by default is strict and won't include cross-domain cookies even if cookie is LAX, or cross-domain.
I just made this PR for fixing it:

I would assume this is acceptable, since in any case in MFE ecosystem RESTful requests do incldue cross-site cookie. or when ajax is being used instead of native fetch.

ghassanmas added a commit to Abstract-Tech/platform-plugin-aspects that referenced this issue Nov 14, 2024
 This URL of fetching guest_token is always LMS_ROOT_URL, however
 in case multisite is being used the guest could be in a different
 url. This change ensure that cookie is being sent if the other
 site is a subdomain or shares parent domain with LMS_URL_ROOT

 This might be realted to openedx/tutor-contrib-aspects/issues/925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

4 participants