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

docs: fix for domain sharding results in failed requests with "Missing Authorization Header" #24481

Merged

Conversation

ved-kashyap-samsung
Copy link
Contributor

@ved-kashyap-samsung ved-kashyap-samsung commented Jun 22, 2023

SUMMARY

Fixes #23295

Same issue discussion on domain sharding feature implementation PR - #5039

After enabling the domain sharding as follows

ENABLE_CORS = True
CORS_OPTIONS = {
  'supports_credentials': True,
  'allow_headers': '*',
  'resources': '*',
  'origins': ['https://dashboards.mydomain.com','https://dashboards1.mydomain.com','https://dashboards2.mydomain.com','https://dashboards3.mydomain.com']
}
SUPERSET_WEBSERVER_DOMAINS=['dashboards.mydomain.com','dashboards1.mydomain.com','dashboards2.mydomain.com','dashboards3.mydomain.com']

All 4 webserver domains are set via DNS A record to the same IP address.

When navigating to a dashboard, I can see in the Edge devtools, that the /api/v1/chart/data requests are sent to all webserver domains. However, they all fail with "401" (unauthenticated). I can also see, that some of the requests have a response set to {"msg":"Missing Authorization Header"}.

EXPECTED RESULT

Domain sharding uses the 4 configured webserver domains for requesting data - and uses the session cookie of original domain for authentication.

ACTUAL RESULT

The authentication of the non-original webserver domains does not work and the requests are not authenticated.

TESTING INSTRUCTIONS

Please verify changes from my fork.
After setting the SESSION_COOKIE_DOMAIN to main domain in superset_config.py authrization should work on all the domain shards.

ADDITIONAL INFORMATION

domain sharding authorization issue fix
@ved-kashyap-samsung
Copy link
Contributor Author

@graceguo-supercat @michellethomas @john-bodley @timifasubaa @kristw @williaster Please check this issue of Missing Authorization Header in domain sharding and its fix. I have tested in my local setup , it is working as expected. Please approve so that people can get insights on this kind of issue.

@ved-kashyap-samsung
Copy link
Contributor Author

ved-kashyap-samsung commented Jun 22, 2023

ROOT CAUSE ANALYSIS - Actually session in superset is managed using cookies. So, session cookie must be sent automatically in any API request through request headers. Also, cookies are automatically sent to subdomains on a domain(TLD). So, following are two solutions. You can choose either.

  1. set SESSION_COOKIE_DOMAIN = 'mydomain.com' in superset_config.py
    This should take care of setting cookie in every request header and hence authorization will be done.

  2. Other solution is to create domain shards which should be subdomains of main domain like below.
    SUPERSET_WEBSERVER_DOMAINS=['dashboards.mydomain.com','1.dashboards.mydomain.com','2.dashboards.mydomain.com','3.dashboards.mydomain.com']

Note: Please delete all the session cookies for your superset top level domain and subdomains intially so that previously session cookies don't change the desired behaviour.

@ved-kashyap-samsung
Copy link
Contributor Author

@graceguo-supercat @michellethomas @john-bodley @timifasubaa @kristw @williaster Please check this issue of Missing Authorization Header in domain sharding and its fix. I have tested in my local setup , it is working as expected. Please approve so that people can get insights on this kind of issue.

Can anyone please review this.

@ved-kashyap-samsung
Copy link
Contributor Author

@rusackas Can you please review this PR.

Co-authored-by: Evan Rusackas <evan@preset.io>
@ved-kashyap-samsung
Copy link
Contributor Author

@rusackas All checks have passed for this PR. Can you please review again.

@ved-kashyap-samsung
Copy link
Contributor Author

ved-kashyap-samsung commented Sep 21, 2023

@rusackas All checks have passed for this PR. Can you please review again.

@rusackas For reminder as I see no updates on this PR for long time. Can you please check once.
@graceguo-supercat @michellethomas @john-bodley @timifasubaa @kristw @williaster

Copy link
Member

@john-bodley john-bodley left a comment

Choose a reason for hiding this comment

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

@ved-kashyap-samsung apologies for missing the previous pings. Thanks for improving the documentation. I've made a couple of suggestions based on how we (Airbnb) have it configured.

docs/docs/installation/networking-settings.mdx Outdated Show resolved Hide resolved
docs/docs/installation/networking-settings.mdx Outdated Show resolved Hide resolved
docs/docs/installation/networking-settings.mdx Outdated Show resolved Hide resolved
ved-kashyap-samsung and others added 3 commits October 4, 2023 23:34
added meaningful sub domain names as example

Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
updated session cookie domain example

Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
fixing additional spaces

Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
@ved-kashyap-samsung
Copy link
Contributor Author

ved-kashyap-samsung commented Oct 4, 2023

@ved-kashyap-samsung apologies for missing the previous pings. Thanks for improving the documentation. I've made a couple of suggestions based on how we (Airbnb) have it configured.

No problem and thanks for your valubale suggestions. I have incorporated suggested changes and looking forward for this PR to be merged. Thanks again!

@john-bodley john-bodley merged commit 87c8e87 into apache:master Oct 4, 2023
28 checks passed
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
…g Authorization Header" (apache#24481)

Co-authored-by: Evan Rusackas <evan@preset.io>
Co-authored-by: John Bodley <4567245+john-bodley@users.noreply.github.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Domain sharding results in failed requests with "Missing Authorization Header"
4 participants