Closed mster closed 5 years ago
This relates to the SSO conversation around accounts. Jaz to set up a meeting with accounts-eng.
(internal slack conversation) ; it sounds like we can copy the code from ncm-desktop SSO auth. We should still copy the code from nscm
to open a browser from the cli to the relevant SSO provider.
hmmm, thought I already pasted this, trying again:
from @cxreg in NodeSource Slack
GET /accounts/auth/social-signin-url?source=github&product=ncm
->{ url, nonce }
you openurl
in the browser and then usenonce
here as a long-poll request:GET /accounts/auth/retrieve-session?nonce=${nonce}
->{ session, refreshToken }
source can begithub
if the user never signs in that second one will eventually time out, or you can abort if they hit a cancel button
GET /accounts/auth/social-signin-url?source=github&product=ncm -> { url, nonce } ... etc.
The current SSO sign-in follows the pattern described above.
We should still copy the code from nscm to open a browser from the cli to the relevant SSO provider.
I took a look at the nscm
code, and it uses the open package to do this. The package uses ChildProcess
to open a url in the preferred browser.
open
does have a security vulnerability, which comes from a lack of input sanitization. This shouldn't be an issue for the tool's usage, but I wanted to bring this to attention before implementation.
We could always just make our own ¯_(ツ)_/¯
This issue will now cover the remaining issues with general authentication for the NCM-Cli tool.
The tool will support three types of authentication via:
NCM_TOKEN
)Session tokens:
ncm-cli signin [-G,-g]
Access tokens:
/accounts/auth/login
from which, the request succeeds to fails immediately. session
token and refreshToken
are returned. session
token received after successful authentication is unusable with the ncm2-api/v2
-- responding with authentication errors when verification is requested. Service tokens
NCM_TOKEN
TODO:
CI - Service Token implementation via environment variable
Referring to #4
TDLR;
session
token returned from/accounts/auth/login
(success condition) when choosing username and password sign-in is unusable with thencm2-api
.Resolution:
session
token different from the one retrieved via SSO sign-in?