codecentric / web-clip

A Chrome extension to extract structured data from any web page and store it to a Solid Pod.
10 stars 2 forks source link

Better login experience #9

Closed angelo-v closed 2 years ago

angelo-v commented 2 years ago

Explore how to login via chrome extension instead of the webpage domain, so that the user does not have to give permission to each and every site he or she clips

https://stackoverflow.com/questions/35770897/how-do-chromiumapp-org-extension-redirects-work-for-google-chrome

https://developer.chrome.com/docs/extensions/reference/identity/#method-launchWebAuthFlow

ejbyne commented 2 years ago

The links look interesting!

angelo-v commented 2 years ago

Insights so far:

chrome.identity.launchWebAuthFlow(
            {
              url: 'https://solidweb.me/idp/auth?client_id=<client-id>&redirect_uri=https://<app-id>.chromiumapp.org/&scope=openid&response_type=code&response_mode=query&nonce=<nonce>',
              interactive: true,
            },
            (...args) => {
              console.log('auth callback', args);
            }
          );

Follow up questions:

angelo-v commented 2 years ago

Proof of concept of the chrome.identity.launchWebAuthFlow-based auth flow is in https://github.com/codecentric/web-clip/pull/12

angelo-v commented 2 years ago

Regarding message size limits https://stackoverflow.com/a/31928402

angelo-v commented 2 years ago

does the origin based ACL work with the extension URL?

is a cross origin request from extension to webpage possible?

Where do we perform the login: popup / options page / background script?

I would personally stick to having the UI within the content page, since this looks nicer and is more flexible than the extension popup. The login and data processing and interaction with the pod can move to the background script and be triggered by a message.

if not, can we send a large amount of data from content script to popup (or wherever the auth session resides)?

obsolete, since CORS is possible

How often do we need to re-login with this procedure?

The session lives in the background script and stays active until the script is reloaded somehow, e.g. when browser is restarted, or extension is reloaded.

Does the session survive opening / closing the popup?

Yes, the session can be re-used in multiple tabs 🎉

What if the token expires?

Not tested yet, but I would guess we just need to re-login and it is save to leave this as a known unknown so far. A token from solidweb.me is valid 1 hour.

Can we use a refresh token to refresh an expired session, so the user does not have to re-login at all

The inrupt authn library does not provide a refresh token, so it is at least not straight forword. Could be a follow-up improvement, even without refresh the login experience will be already much better with the described measures.