Yesterday, @heimindanger reached out to me regarding adding a feature in the new d.tube, that allows the user to choose an upload server of their choice. He mentioned that he wanted to add
@vaultec's dtube.network and
@onelovedtube's upload servers as predefined options.
As you know, I had chosen to write the uploader website from scratch, including both the client and the upload server side code, mainly for these reasons:
Currently, the /videoupload API has no authentication system in place, with CORS disabled so that the API may be called only from the same domain (preventing unauthorised users from making the call elsewhere). Same applies to /imageupload API for images in Steem article body.
In order to include @onelovedtube's upload servers as a node option to upload videos on d.tube, several changes are required:
uploadTokens as [] on app startup./uploadrequest GET API with a username parameter, which is the Steem handle of the user.uploadTokens array./videoupload API call, with the decrypted message in a URL parameter called upload_token.upload_token exist in the uploadTokens array. If it doesn't exist, reject the upload request by returning an error. If it exist, delete the upload_token string and proceed with the file upload.This will only work if the user is authenticated with Steem Keychain, or by entering their private posting key on d.tube. SteemConnect does not have a method to decrypt messages with posting keys, so this will break SteemConnect support.
DTube has plans to depreciate SteemConnect auth on their official frontend, which leaves them with Steem Keychain and private posting key auth. @onelovedtube will never ask users to enter any private keys on our own websites, which leaves us only with Steem Keychain, which can be an inconvenience to users who cannot install the Steem Keychain extension for any reasons, if we choose to depreciate SteemConnect auth.
Whenever the user logs into our uploader webpage regardless of auth method, an access token is generated and parsed into the URL to detect logins. The access token contains information such as logged in Steem username which can be submitted to server together with the upload API call, and it can be checked against the whitelist before the upload begins.
Access tokens for Steem Keychain authentication can be obtained by calling the /login API followed by /logincb API, the same way of the Keychain login system of uploader.oneloved.tube website.
On d.tube, users may be logged in by entering their private posting key, rather than using Keychain or SteemConnect. Therefore access tokens cannot be generated, which means that the user cannot verify themselves that they're in the uploader whitelist file.
Credit goes to @heimindanger for this solution
/videoupload API call, then is verified on server with Steem-JS.Looks like there is no way to verify a signature on Steem-JS according to their documentation (maybe it's not documented somehow). There's also no way to sign messages with SteemConnect.
So this is it, the 3 solutions to this auth system to the file upload APIs on #onelovedtube uploader. All of them come with issues that break an existing sign in method, so I need your ideas to decide which is the best approach to this situation. If you have any ideas regarding solutions that is better than the ones specified above, feel free to let me know in the comment section below.