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

Update cross platform vpn logic for v2 credentials #6357

Closed
iccub opened this issue Nov 9, 2022 · 3 comments · Fixed by #6397
Closed

Update cross platform vpn logic for v2 credentials #6357

iccub opened this issue Nov 9, 2022 · 3 comments · Fixed by #6397

Comments

@iccub
Copy link
Contributor

iccub commented Nov 9, 2022

Description

We may (or may not) need to make changes to accomodate the SKU credentials v2

No changes required to use the new system; but we will be required to cache the subscriber credentials once we get them to avoid burning through all of the credentials for a given day. Unlike before, there are only a certain number of preallocated credentials for each day

@bsclifton
Copy link
Member

bsclifton commented Nov 9, 2022

Carried over from brave/brave-browser#26254

(notes removed; see requirements below)

@bsclifton
Copy link
Member

Thanks @iccub for walking through the code with me over video chat 😄

For reference, we made the changes needed for Desktop and Android with brave/brave-core#15702

Here are the requirements we needed to satisfy:

  1. When calling prepare_credential_presentation, we get SKU response as cookie; we need to save the expiration time also.

    guard let unescapedCredential = credential.unescape(),
    let env = environment(domain: domain),
    let sampleUrl = URL(string: "https://brave.com") else { return nil }
    guard let guardianConnectCredential =
    HTTPCookie.cookies(withResponseHeaderFields:
    ["Set-Cookie": unescapedCredential], for: sampleUrl).first?.value else {
    return nil
    }
    return (guardianConnectCredential, env)

  2. We should update code to store the Guardian "subscriber" credential to have that instead (I think it is named skusCredential right now; maybe it can be called desktopSubscriberCredential or similar). The credential itself along with expiration time are critical to store as a profile preference so we can easily look at it. It's very Important that this persists between app launches (which it appears to be doing already 😄)

    Preferences.VPN.skusCredential.value = credential
    Preferences.VPN.skusCredentialDomain.value = domain

  3. Application-wise, we should not call prepare_credential_presentation unless:
    a. We don't have a credential yet
    b. We have a credential, but it's expired (now > expiration time)

  4. We can set a timer to fire on the expiration timestamp we get back in Update Readme #1 above. When that expiration time is reached, we want to clear the stored credential and expiration time and fetch a new one

@Uni-verse
Copy link
Contributor

Uni-verse commented Dec 16, 2022

Verified using 1.46 (22.12.15.19) on the following devices(s):

iPhone 12 - iOS 16.x
iPhone XR - iOS 15.x
iPad - iPadOS 15.x

  • Verified credentials are valid if user relaunches the app
  • Verified VPN credentials are valid if user changes servers
  • Verified VPN profile is updated when changing server
Example Example Example Example Example
IMG_4244 IMG_4245 2 IMG_0070 IMG_0072 2 IMG_0073

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.