Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Fixed Opening Authenticated Documents in private and non-private mode. #1218

Closed
wants to merge 1 commit into from

Conversation

Brandon-T
Copy link
Collaborator

@Brandon-T Brandon-T commented Jul 9, 2019

  • Fixed a background thread issue.
  • Fixed opening Authenticated documents in Private-Browsing mode when it opens in a new tab.
  • Fixed opening Authenticated documents and attempting to share, or print them.
  • Added Ephemeral Cookie Storage (in memory only.. once a tab is closed, all information is lost) for tabs to support opening Authenticated documents.
  • Made TemporaryDocument URLSession use the ephemeral cookie storage.

Fixes: #1144

Discovered Problem(s):

  • Private Tabs do NOT share session & cookies amongst its child tabs.. For example, if I open a Bank website on TabA and log in, then I go to statements and it happens to open in TabB (target=__blank), it will ask for re-authentication because cookies & session from TabA did not pass on to child TabB.

  • Session and Cookies not shared amongst NSURLSession. When WKWebView makes a request to a banking website, it stores the cookies and session internal in the WKWebsiteDataStore.instance.httpCookieStorage.. when downloading a document, we are downloading with NSURLSession and the cookies are not passed along. Therefore, when downloading opening documents in the webview, it displays fine, but when attempting to print (at which point it "downloads with NSURLSession"), it will download a redirected HTML "login" page instead of the document requested because the session information wasn't passed along.

Solution:

  • When creating a new WebView from a parent one (IE: new tab), pass the cookies along to the new tab's website data store. (Same behaviour as Brave, Firefox, and Chrome Desktop).
    However, if two tabs are completely independent of each other, the cookies should NOT be shared!

  • When downloading a document, store the cookies in MEMORY only (ephemeral storage), and pass it along to the child-tabs and TemporaryDocument. This allows the TemporaryDocument to request the pdf/image/etc.. We should probably be using NSURLSession(configuration: .ephemeral) as well.. instead of .default.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • My patch or PR title has a standard commit message that looks like Fix #123: This fixes the shattered coffee cup! (or No Bug: <message> if no relevant ticket)
  • Unit Tests are updated to cover new or changed functionality
  • User-facing strings use NSLocalizableString()
  • New files have MPL-2.0 license header.

Test Plan:

Screenshots:

Reviewer Checklist:

  • PR is linked to an issue via Zenhub.
  • Issues are assigned to at least one epic.
  • Issues include necessary QA labels:
    • QA/(Yes|No)
    • release-notes/(include|exclude)
    • bug / enhancement
  • Necessary security reviews have taken place.
  • Adequate test coverage exists to prevent regressions.
  • Adequate test plan exists for QA to validate (if applicable)

@Brandon-T Brandon-T changed the title Fixed a background thread issue. Fixed Opening Authenticated Documents in private and non-private mode. Jul 9, 2019
Fixed opening Authenticated documents in Private-Browsing mode when it opens in a new tab.
Fixed opening Authenticated documents and attempting to share, or print them.
Added Ephemeral Cookie Storage (in memory only.. once a tab is closed, all information is lost) for tabs to support opening Authenticated documents.
Made TemporaryDocument URLSession use the ephemeral cookie storage.
@Brandon-T Brandon-T force-pushed the feature/WebStorage branch from 4574902 to 9853eda Compare July 10, 2019 14:30
@danishjafri88
Copy link
Contributor

This fix is not viable for the mentioned problems as discussed with @Brandon-T & @jumde.

Problem 1. Will be solved by keeping same nonPersistent websiteDataStore for all tabs in private mode which will be purged on exiting private mode.

Problem 2. There are lot of other cases where cookie sharing will not work like basic web authentication. There is also an inherent problem of double download of the same resource(excess bandwidth is consumed plus will take extra time to be used for sharing).
Current solution we came up with is to extract the resource directly from the webpage.

Closing this pr.

@jhreis jhreis deleted the feature/WebStorage branch August 7, 2019 06:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Print button is unresponsive for Online PDF bank statements
2 participants