deta / deta-cli

Legacy Deta CLI. Repository is now archived.
https://deta.space
MIT License
67 stars 13 forks source link

Problems with authorization through local server #94

Closed cofob closed 1 year ago

cofob commented 2 years ago

Problem

Many people have problems with the deta login command because it starts a local server and some browsers do not allow connections to localhost. The user may also be running the command in a WSL or in a Docker container where port forwarding to the host machine may not work.

Solution

For authorization, it is better to use the Deta server instead of the local server. For example:

  1. The user enters the deta login command
  2. The program receives a unique login ID string from server (for example UUID)
  3. Starts polling the Deta server every 5 seconds with this string (or starts a long-lived websocket connection).
  4. Outputs a link to the user like https://web.deta.sh/cli/{login ID}
  5. The user clicks on the link, logs in
  6. The program, requesting the next update from the server, receives the tokens.

Solution will require changes on the Deta backend.

Authorization was successful without local server. Optionally, you can ask the user to enter another unique string, so that the account is not logged in because of an accidental click on the link in the internet.

Yes, it will create additional load on the server, but it will be supported on all browsers with js, including containers and wsl.

This is how github cli works successfully, for example.

aavshr commented 1 year ago

sorry @cofob closing this issue as well since the repository is now being archived. You can contact us on discord or by email if you have any questions/concerns.