Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Add pairing implementation #9

Merged
merged 36 commits into from
Nov 19, 2021
Merged

Add pairing implementation #9

merged 36 commits into from
Nov 19, 2021

Conversation

gudgl
Copy link
Contributor

@gudgl gudgl commented Nov 2, 2021

User Story

As a supporter, I want to be able to guide the person who needs my help through the process of starting the agent. This must be possible on a phone call.

  1. I want to create a new session on my Plexus server.
  2. The plexus server returns a short pairing code like "ABC123" that can be passed on by phone.
  3. The person seeking help goes to https://pc-assist.app and downloads the PC Assist app (subject of this task) and download the version for the used OS.
  4. After starting the app, the person entered the pairing code.
  5. The app shows some confirmation message like "Do you really want to grant access to ".
  6. After confirming, the session starts.

Preconditions

A simple PHP/HTML page that serves the downloads of the PC Assist app will be created soon. (not subject of this task)

Task

Create a pairing code

Config extension

Extend the plexus.config with optional settings like

# Publish all sessions on a pairing service
PLEXUS_PAIRING_URL=https://pc-assist.app/pairing/
# Pairing codes will expire after N seconds.
PLEXUS_PAIRING_TTL=600
# The pc-assist app can show your company name before the sessions start
PLEXUS_COMPANY_NAME="The great PC support"
# The pc-assist app can load your logo from a public URL
PLEXUS_COMPANY_LOGO="https://img.icons8.com/external-wanicon-lineal-color-wanicon/64/000000/external-help-friendship-wanicon-lineal-color-wanicon.png"

Session creation

If the PLEXUS_PAIRING_URL is given

  1. The plexus server must accept the two extra fields supporter_name and supporter_avatar on session creation.
    For example:

    curl -ks https://localhost:8080/session \
          -u support:1234 \
          -F id="helping-joe" \
          -F ttl=3600 \
          -F username=admin \
          -F password=foobaz \
          -F supporter_name=Thorsten \
          -F supporter_avatar="https://avatars.githubusercontent.com/u/16852023?v=4"
    
  2. On session creation, the Plexus server must send a json POST request to {PLEXUS_PAIRING_URL} for example https://pc-assist.app/sessions/ containing the base URL of the new pairing endpoint of the Plexus server (see below).

    curl 'https://pc-assist.app/pairing/' \
    --header 'Content-Type: application/json' \
    --data-raw '{"url":"http://plexus.example.com/pairing"}'
    

    The above URL will return pairing data as follows.

    {
        "success": true,
        "code": "7auu83",
        "pairing_url": "https://pc-assist.app/pairing/7auu83",
        "redirect_url": "http://plexus.example.com/pairing/7auu83"
    }

    If you request the pairing_url you will get a 302 redirect to the redirect_url.

  3. if the pairing code has been retrieved successfully, it must be included into the response of the session creation, for example.

    {
      "ID": "helping-joe",
      "SessionURL": "https://localhost:8080/session/helping-joe",
      "AgentMSH": "https://localhost:8080/config/helping-joe:xddRGfuIOaqwBxVIWrnp",
      "AgentConfig": {
        "ServerID": "9DA17836FD0BA3193ED52896929FD021990EBA4234ED56A6057115B7C53D24F58284E34954619CAECC131FC8BE82B9EE",
        "MeshName": "plexus/helping-joe/bGVnI",
        "MeshType": 2,
        "MeshID": "mesh//i8bgwSqhUVS5ttAYX5VCqSR2dxPY@5iSLv5p1jFJG5TJKYV91PaMoTf0AHSj@Eqi",
        "MeshIDHex": "0x8BC6E0C12AA15154B9B6D0185F9542A924767713D8FB98922EFE69D631491B94C929857DD4F68CA137F40074A3F84AA2",
        "MeshServer": "wss://localhost:8080/agent/helping-joe:xddRGfuIOaqwBxVIWrnp"
      },
      "ExpiresAt": "2021-09-12T14:31:40.830231373+02:00",
      "PairingCode": "7auu83",
      "PairingUrl":"https://pc-assist.app/pairing/7auu83"
    }

Pairing creation

Now it's time to provide a pairing URL on Plexus.
If the request to the public pairing service on https://pc-assist.app has returned a pairing code and a redirect URL, store the code in the memory of the plexus server and make the redirect URL available. The PC Assist desktop app will connect there.
With the above example, the plexus server must make the URL GET https://localhost:8080/pairing/7auu83 available. It must return a json object like

{
  "AgentMSH": "https://localhost:8080/config/helping-joe:xddRGfuIOaqwBxVIWrnp",
  "ExpiresAt": "2021-09-12T14:31:40.830231373+02:00",
  "CompanyName": "The great PC support",
  "CompanyLogo": "https://img.icons8.com/external-wanicon-lineal-color-wanicon/64/000000/external-help-friendship-wanicon-lineal-color-wanicon.png",
  "SupporterName":"Thorsten",
  "SupporterAvatar":"https://avatars.githubusercontent.com/u/16852023?v=4"
}

@gudgl gudgl requested a review from jmattheis November 2, 2021 23:43
@gudgl gudgl self-assigned this Nov 2, 2021
handler/create.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
pairing/pair.go Outdated Show resolved Hide resolved
pairing/pair.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
handler/handler.go Outdated Show resolved Hide resolved
handler/pair.go Outdated Show resolved Hide resolved
pairing/pair.go Outdated Show resolved Hide resolved
pairing/config.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
handler/pcpair.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
handler/pair.go Outdated Show resolved Hide resolved
handler/pair.go Outdated Show resolved Hide resolved
handler/pair.go Outdated Show resolved Hide resolved
handler/pair.go Outdated Show resolved Hide resolved
@gudgl gudgl requested a review from jmattheis November 9, 2021 14:14
handler/pair.go Outdated Show resolved Hide resolved
@gudgl gudgl requested a review from jmattheis November 12, 2021 08:35
handler/pair.go Outdated Show resolved Hide resolved
handler/create.go Outdated Show resolved Hide resolved
pairing/config.go Outdated Show resolved Hide resolved
@gudgl gudgl requested a review from jmattheis November 17, 2021 22:53
Copy link
Contributor

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

One little remark, then you can merge & rebase it.

config/config.go Outdated Show resolved Hide resolved
@gudgl gudgl merged commit e29a72b into main Nov 19, 2021
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.

None yet

2 participants