Skip to content

New auth flow#430

Open
chinmay29fynd wants to merge 17 commits into
masterfrom
new-auth-flow
Open

New auth flow#430
chinmay29fynd wants to merge 17 commits into
masterfrom
new-auth-flow

Conversation

@chinmay29fynd
Copy link
Copy Markdown
Collaborator

New auth flow

Comment thread src/lib/Auth.ts Outdated
Comment thread src/lib/Auth.ts Outdated
Copy link
Copy Markdown
Contributor

@vivek8690 vivek8690 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes on keeping this consistent with how the rest of the CLI is structured. Main one is the URL building — see inline.

Comment thread src/lib/Auth.ts Outdated
return options?.region?.trim();
}

function getPanelAuthBase(env: string, region?: string) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already keep all URLs in src/lib/api/services/url.ts, and this PR even adds the right entries there (OAUTH_CLIENT_CONFIG, OAUTH_DEVICE_AUTHORIZATION, OAUTH_DEVICE_TOKEN) with tests. But here in Auth.ts we hand-build the URLs with this helper instead of using them, so those new URLS.* entries end up unused (only the test references them), and we're duplicating AUTH_URL() and hardcoding v1.0 in a second place.

The reason for going manual looks like region support (/region/${region}/...), which getBaseURL() doesn't handle today. Can we instead add the region bit into the URLS helpers (or getBaseURL) and call URLS.OAUTH_CLIENT_CONFIG() / etc. from here? That keeps URL building in one place like the rest of the services. At the very least the non-region path should use the entries we just added.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivek8690 changes pushed

Comment thread src/lib/Auth.ts Outdated

try {
await open(verificationLink);
console.log(`Opened link to start the auth process: ${OutputFormatter.link(verificationLink)}`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These use console.log, but the success message a few lines down uses Logger.info, and the rest of the file sends informational output through Logger. Can we switch these two to Logger.info so it stays consistent (and goes through the same formatting/debug-log handling)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivek8690 changes pushed

Comment thread src/lib/Auth.ts Outdated
'Content-Type': 'application/json',
},
data: {
client_id: 'fdk-cli',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: 'fdk-cli', the urn:ietf:...:device_code grant type, and ['organization/*'] are inlined here (and repeated below for the token call, and on the skywarp side). We usually keep shared literals in helper/constants. Pulling these into named constants would match convention and keep client/server from drifting. Not blocking.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivek8690 changes pushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants