Skip to content

Commit

Permalink
Update mailsync to use OAuth for Outlook, outlook.office.com as the s…
Browse files Browse the repository at this point in the history
…cope
  • Loading branch information
bengotow committed Sep 12, 2024
1 parent 9d4bd33 commit 033799f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 9 deletions.
18 changes: 10 additions & 8 deletions app/internal_packages/onboarding/lib/onboarding-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ export const GMAIL_CLIENT_ID =
// Note: This is not a security risk for the end-user -- it just means someone could "fork" Mailspring and re-use it's
// Client ID and Secret. For now, it seems we're on the honor code - Please don't do this.
//
export const GMAIL_CLIENT_SECRET = process.env.MS_GMAIL_CLIENT_SECRET || crypto
.createDecipheriv(
'aes-256-ctr',
"don't-be-ev1l-thanks--mailspring",
Buffer.from('wgvAx+N05nHqhFxJ9I07jw==', 'base64')
)
.update(Buffer.from('1EyEGYVh3NBNIbYEdpdMvOzCH7+vrSciGeYZ1F+W6W+yShk=', 'base64'))
.toString('utf8');
export const GMAIL_CLIENT_SECRET =
process.env.MS_GMAIL_CLIENT_SECRET ||
crypto
.createDecipheriv(
'aes-256-ctr',
"don't-be-ev1l-thanks--mailspring",
Buffer.from('wgvAx+N05nHqhFxJ9I07jw==', 'base64')
)
.update(Buffer.from('1EyEGYVh3NBNIbYEdpdMvOzCH7+vrSciGeYZ1F+W6W+yShk=', 'base64'))
.toString('utf8');

export const GMAIL_SCOPES = [
'https://mail.google.com/', // email
Expand Down
2 changes: 2 additions & 0 deletions app/internal_packages/onboarding/lib/onboarding-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import AccountSettingsPageIMAP from './page-account-settings-imap';
import AccountOnboardingSuccess from './page-account-onboarding-success';
import InitialPreferencesPage from './page-initial-preferences';
import InitialSubscriptionPage from './page-initial-subscription';
import AccountSettingsPageOutlook from './page-account-settings-outlook';

const PageComponents = {
welcome: WelcomePage,
Expand All @@ -24,6 +25,7 @@ const PageComponents = {
'account-settings': AccountSettingsPage,
'account-settings-gmail': AccountSettingsPageGmail,
'account-settings-o365': AccountSettingsPageO365,
'account-settings-outlook': AccountSettingsPageOutlook,
'account-settings-imap': AccountSettingsPageIMAP,
'account-onboarding-success': AccountOnboardingSuccess,
'initial-preferences': InitialPreferencesPage,
Expand Down
4 changes: 4 additions & 0 deletions app/internal_packages/onboarding/lib/onboarding-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class OnboardingStore extends MailspringStore {
this._pageStack = ['account-choose', 'account-settings-gmail'];
} else if (this._account.provider === 'office365') {
this._pageStack = ['account-choose', 'account-settings-o365'];
} else if (this._account.provider === 'outlook') {
this._pageStack = ['account-choose', 'account-settings-outlook'];
} else if (this._account.provider === 'imap') {
this._pageStack = ['account-choose', 'account-settings', 'account-settings-imap'];
} else {
Expand Down Expand Up @@ -84,6 +86,8 @@ class OnboardingStore extends MailspringStore {
? 'account-settings-gmail'
: provider === 'office365'
? 'account-settings-o365'
: provider === 'outlook'
? 'account-settings-outlook'
: 'account-settings';

// Don't carry over any type-specific account information
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

import { Account } from 'mailspring-exports';
import { buildO365AccountFromAuthResponse, buildO365AuthURL } from './onboarding-helpers';

import OAuthSignInPage from './oauth-signin-page';
import * as OnboardingActions from './onboarding-actions';
import AccountProviders from './account-providers';

export default class AccountSettingsPageOutlook extends React.Component<{ account: Account }> {
static displayName = 'AccountSettingsPageOutlook';

_authUrl = buildO365AuthURL();

onSuccess(account) {
OnboardingActions.finishAndAddAccount(account);
}

render() {
const providerConfig = AccountProviders.find(a => a.provider === this.props.account.provider);
const goBack = () => OnboardingActions.moveToPreviousPage();

return (
<OAuthSignInPage
serviceName="Outlook"
providerAuthPageUrl={this._authUrl}
providerConfig={providerConfig}
buildAccountFromAuthResponse={buildO365AccountFromAuthResponse}
onSuccess={this.onSuccess}
onTryAgain={goBack}
/>
);
}
}
1 change: 1 addition & 0 deletions app/internal_packages/onboarding/styles/onboarding.less
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
}
.page.account-setup.google,
.page.account-setup.office,
.page.account-setup.outlook,
.page.account-setup.AccountOnboardingSuccess {
.logo-container {
padding-top: 160px;
Expand Down
2 changes: 1 addition & 1 deletion mailsync

0 comments on commit 033799f

Please sign in to comment.