Skip to content

Commit

Permalink
chore(login): deprecate password-based auth (#4877)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltm authored Jun 21, 2022
1 parent f090194 commit ca1a001
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
29 changes: 15 additions & 14 deletions packages/@ionic/cli/src/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,34 @@ export class LoginCommand extends Command implements CommandPreRun {
type: 'global',
summary: 'Log in to Ionic',
description: `
Authenticate with Ionic and retrieve a user token, which is stored in the CLI config. The most secure way to log in is running ${input('ionic login')} without arguments, which will open a browser where you can submit your credentials.
Authenticate with Ionic and retrieve a user token, which is stored in the CLI config. Running ${input('ionic login')} will open a browser where you can submit your credentials.
If the ${input('IONIC_TOKEN')} environment variable is set, the CLI will automatically authenticate you. To retrieve your user token, first use ${input('ionic login <email> <password>')} to log in, then use ${input('ionic config get -g tokens.user')} to print the token. (${strong('Note')}: Tokens retrieved from the browser login are short-lived and not recommended for use with ${input('IONIC_TOKEN')}.)
${input('ionic login')} will also accept ${input('password')} through stdin, e.g.: ${input('echo "<password>" | ionic login <email>')}.
If the ${input('IONIC_TOKEN')} environment variable is set, the CLI will automatically authenticate you. Use the Dashboard to generate a Personal Access Token.
If you need to create an Ionic account, use ${input('ionic signup')} or the Ionic Website[^signup].
You can reset your password in the Dashboard[^reset-password].
If you are having issues logging in, please get in touch with our Support[^support-request].
`,
footnotes: [
{
id: 'signup',
url: 'https://ionicframework.com/signup',
},
{
id: 'reset-password',
url: 'https://dashboard.ionicframework.com/reset-password',
shortUrl: 'https://ion.link/reset-password',
},
{
id: 'support-request',
url: 'https://ion.link/support-request',
},
],
exampleCommands: ['', 'john@example.com', 'hello@example.com secret'],
exampleCommands: [''],
inputs: [
{
name: 'email',
summary: 'Your email address',
summary: 'Your email address (deprecated)',
private: true,
},
{
name: 'password',
summary: 'Your password',
summary: 'Your password (deprecated)',
private: true,
},
],
Expand All @@ -74,6 +65,16 @@ If you are having issues logging in, please get in touch with our Support[^suppo
this.env.log.nl();
}

if (!!inputs[0]) {
this.env.log.warn(
'Authenticating using email and password is deprecated. ' +
(this.env.flags.interactive
? `Please run ${input('ionic login')} without arguments to log in.`
: `Please generate a Personal Access Token and set the ${input('IONIC_TOKEN')} environment variable.`)
);
this.env.log.nl();
}

// ask for password only if the user specifies an email
const validateEmail = !!inputs[0];
const askForPassword = inputs[0] && !inputs[1];
Expand Down
7 changes: 7 additions & 0 deletions packages/@ionic/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ async function authenticateFromEnvironment(ienv: IonicEnvironment) {
if (ienv.config.get('user.email') !== email) {
debug(`${strong('IONIC_EMAIL')} mismatch with current session--attempting login`);

ienv.log.warn(
'Authenticating using email and password is deprecated. Please generate a Personal Access Token and set the ' +
strong('IONIC_TOKEN') +
' environment variable.'
);
ienv.log.nl();

try {
await ienv.session.login(email, password);
} catch (e) {
Expand Down

0 comments on commit ca1a001

Please sign in to comment.