bufbuild / buf

The best way of working with Protocol Buffers.
https://buf.build
Apache License 2.0
8.5k stars 248 forks source link

Add a `buf login` browser-based auth flow #753

Open lrewega opened 2 years ago

lrewega commented 2 years ago

I think there is an opportunity to provide a better login experience that removes the need for a user to generate a token and paste it into their terminal. For example:

Note that in this flow, the CLI and IdP do not interact at all. There are several assumptions baked into this about what sort of secrets/sessions are shared between the CLI and BSR -- I have several ideas -- but I am more interested in what folks think about this concept.

There would also have to be some way to fallback the current approach e.g. --[no-]launch-browser, etc.

[^0]: there is an implicit assumption in this design that the CLI first performs some sort of handshake or establishes some other relationship with the BSR such that it can wait around for the token to be minted or not[^1]. Some sort of identifier must be included in the URL sent to the browser so the BSR can correlate the CLI and browser sessions[^2]. [^1]: in the case where a token was not minted, either the CLI can wait for the NACK from the BSR or can time out if the URL+identifier wasn't accessed in some short amount of time (O(seconds)) [^2]: because avoiding state is desirable, we could transmit some sort of magic-wormhole-like pre-shared-key such that no new state would be necessary from the perspective of the BSR.

amckinney commented 2 years ago

For reference, there's some prior art that acts very similar to what you're describing in https://github.com/bufbuild/core/pull/399.