Skip to content

Modular logistics and supply chain operating system (LSOS)

refactor for two auth flow and settings

Ronald A. Richardson270371ce9cc8
diff --git a/console/app/components/two-fa-settings.hbs b/console/app/components/two-fa-settings.hbs
index 9dd2cf17..10bb7dd7 100644
--- a/console/app/components/two-fa-settings.hbs
+++ b/console/app/components/two-fa-settings.hbs
@@ -1,11 +1,17 @@
<div class="flex items-center space-x-4">
- <label class="text-lg font-medium">Enable Two-Factor Authentication</label>
+ <label class="text-base font-medium">Enable Two-Factor Authentication</label>
<Toggle @isToggled={{this.isTwoFaEnabled}} @onToggle={{this.onTwoFaToggled}} />
</div>
{{#if this.isTwoFaEnabled}}
<div class="mt-6">
- <label class="text-lg font-medium">Choose an authentication method</label>
+ {{#if this.showEnforceOption}}
+ <div class="flex items-center space-x-4 mb-6">
+ <label class="text-base font-medium">Require Users to Set-Up 2FA</label>
+ <Toggle @isToggled={{this.isTwoFaEnforced}} @onToggle={{this.onTwoFaEnforcedToggled}} />
+ </div>
+ {{/if}}
+ <label class="text-base font-medium">Choose an authentication method</label>
<p class="text-sm text-gray-600 dark:text-gray-300 mt-1">In addition to your username and password, you'll have to enter a code (delivered via app or SMS) to sign in to your account</p>
{{#each @twoFaMethods as |method|}}
<div class="border rounded-lg px-4 py-3 mt-2 transition duration-300 {{if (eq this.selectedTwoFaMethod method.key) 'border-blue-500' 'border-gray-200 dark:border-gray-700'}}">
diff --git a/console/app/components/two-fa-settings.js b/console/app/components/two-fa-settings.js
index 95cece8d..5cbb04f3 100644
--- a/console/app/components/two-fa-settings.js
+++ b/console/app/components/two-fa-settings.js
@@ -10,7 +10,7 @@ import { inject as service } from '@ember/service';
* @property {string} DEFAULT_2FA_METHOD
* @private
*/
-const DEFAULT_2FA_METHOD = 'authenticator_app';
+const DEFAULT_2FA_METHOD = 'email';
/**
* Glimmer component for managing Two-Factor Authentication settings.
@@ -51,6 +51,23 @@ export default class TwoFaSettingsComponent extends Component {
*/
@tracked isTwoFaEnabled;
+ /**
+ * Indicates whether Two-Factor Authentication is required for all users.
+ *
+ * @property {boolean} isTwoFaEnforced
+ * @public
+ */
+ @tracked isTwoFaEnforced;
+
+ /**
+ * Indicates whether the settings should render an option to `enforce`
+ * Enforce is a flag that indicates that users either under a company or system must setup 2FA.
+ *
+ * @property {boolean} showEnforceOption
+ * @public
+ */
+ @tracked showEnforceOption;
+
/**
* Class constructor to initialize the component.
*
@@ -60,11 +77,12 @@ export default class TwoFaSettingsComponent extends Component {
* @param {Object} options.twoFaSettings - The current Two-Factor Authentication settings.
* @param {Array} options.twoFaMethods - Available Two-Factor Authentication methods.
*/
- constructor(owner, { twoFaSettings, twoFaMethods }) {
+ constructor(owner, { twoFaSettings, twoFaMethods, showEnforceOption }) {
super(...arguments);
const userSelectedMethod = isArray(twoFaMethods) ? twoFaMethods.find(({ key }) => key === twoFaSettings.method) : null;
+ this.showEnforceOption = showEnforceOption === true;
this.isTwoFaEnabled = twoFaSettings.enabled === true;
this.selectedTwoFaMethod = userSelectedMethod ? userSelectedMethod.key : DEFAULT_2FA_METHOD;
}
@@ -98,6 +116,22 @@ export default class TwoFaSettingsComponent extends Component {
}
}
+ /**
+ * Action handler for toggling Two-Factor Authentication.
+ *
+ * @method onTwoFaEnforcedToggled
+ * @param {boolean} isTwoFaEnforced - Indicates whether Two-Factor Authentication is enabled.
+ * @return {void}
+ * @public
+ */
+ @action onTwoFaEnforcedToggled(isTwoFaEnforced) {
+ this.isTwoFaEnforced = isTwoFaEnforced;
+
+ if (typeof this.args.onTwoFaEnforcedToggled === 'function') {
+ this.args.onTwoFaEnforcedToggled(...arguments);
+ }
+ }
+
/**
* Action handler for selecting a Two-Factor Authentication method.
*
diff --git a/console/app/controllers/auth/login.js b/console/app/controllers/auth/login.js
index 19abff9d..0bd0dc7d 100644
--- a/console/app/controllers/auth/login.js
+++ b/console/app/controllers/auth/login.js
@@ -110,12 +110,22 @@ export default class AuthLoginController extends Controller {
// send request to check for 2fa
try {
- let { twoFaSession, isTwoFaEnabled, isTwoFaValidated } = await this.session.checkForTwoFactor(identity);
-
- if (isTwoFaEnabled && !isTwoFaValidated) {
- return this.session.store.persist({ identity }).then(() => {
- return this.router.transitionTo('auth.two-fa', { queryParams: { token: twoFaSession } });
- });
+ let { twoFaSession, isTwoFaEnabled } = await this.session.checkForTwoFactor(identity);
+
+ if (isTwoFaEnabled) {
+ return this.session.store
+ .persist({ identity })
+ .then(() => {
+ return this.router.transitionTo('auth.two-fa', { queryParams: { token: twoFaSession } }).then(() => {
+ this.reset('success');
+ });
+ })
+ .catch((error) => {
+ this.notifications.serverError(error);
+ this.reset('error');
+
+ throw error;
+ });
}
} catch (error) {
return this.notifications.serverError(error);
diff --git a/console/app/controllers/auth/two-fa.js b/console/app/controllers/auth/two-fa.js
index 1bb683f1..0624572b 100644
--- a/console/app/controllers/auth/two-fa.js
+++ b/console/app/controllers/auth/two-fa.js
@@ -49,15 +49,6 @@ export default class AuthTwoFaController extends Controller {
*/
@tracked identity;
- /**
- * Tracked property representing the remaining time in seconds for the countdown.
- *
- * @property {number} timeRemaining
- * @tracked
- * @default 60
- */
- @tracked timeRemaining = 60;
-
/**
* Tracked property representing the client token from the validated 2fa session.
*
@@ -100,6 +91,15 @@ export default class AuthTwoFaController extends Controller {
*/
@tracked countdownReady = false;
+ /**
+ * Tracked property representing when verification code has expired.
+ *
+ * @property {Boolean} isCodeExpired
+ * @tracked
+ * @default false
+ */
+ @tracked isCodeExpired = false;
+
/**
* Query parameters for the controller.
*
@@ -107,10 +107,6 @@ export default class AuthTwoFaController extends Controller {
*/
queryParams = ['token', 'clientToken'];
- constructor() {
- super(...arguments);
- }
-
/**
* Action method for verifying the entered verification code.
*
@@ -132,9 +128,9 @@ export default class AuthTwoFaController extends Controller {
}
// Call the backend API to verify the entered verification code
- const { authToken } = await this.fetch.post('two-fa/verify-code', {
+ const { authToken } = await this.fetch.post('two-fa/verify', {
token,
- verificationCode,
+ code: verificationCode,
clientToken,
identity,
});
@@ -155,20 +151,29 @@ export default class AuthTwoFaController extends Controller {
}
}
+ /**
+ * Resends the verification code for Two-Factor Authentication.
+ * Disables the countdown timer while processing and handles success or error notifications.
+ *
+ * @returns {Promise<void>}
+ * @action
+ */
@action async resendCode() {
// disable countdown timer
this.countdownReady = false;
try {
- const { identity } = this;
- const { clientToken } = await this.fetch.post('two-fa/resend-code', {
+ const { identity, token } = this;
+ const { clientToken } = await this.fetch.post('two-fa/resend', {
identity,
+ token
});
if (clientToken) {
this.clientToken = clientToken;
this.twoFactorSessionExpiresAfter = this.getExpirationDateFromClientToken(clientToken);
this.countdownReady = true;
+ this.isCodeExpired = false;
this.notifications.success('Verification code resent successfully.');
} else {
this.notifications.error('Unable to send verification code.');
@@ -179,6 +184,45 @@ export default class AuthTwoFaController extends Controller {
}
}
+ /**
+ * Cancels the current Two-Fa session and redirects to login screen.
+ *
+ * @returns {Promise<Transition>}
+ * @memberof AuthTwoFaController
+ */
+ @action cancelTwoFactor() {
+ return this.fetch
+ .post('two-fa/invalidate', {
+ identity: this.identity,
+ token: this.token,
+ })
+ .then(({ ok }) => {
+ return this.router.transitionTo('auth.login');
+ });
+ }
+
+ /**
+ * Set that the verification code has expired and allow user to resend.
+ *
+ * @memberof AuthTwoFaController
+ */
+ @action handleCodeExpired() {
+ this.isCodeExpired = true;
+ this.countdownReady = false;
+ }
+
+ /**
+ * Handles the input of the OTP (One-Time Password) and triggers the verification process.
+ *
+ * @param {string} otpValue - The OTP value entered by the user.
+ * @returns {void}
+ * @action
+ */
+ @action handleOtpInput(otpValue) {
+ this.verificationCode = otpValue;
+ this.verifyCode();
+ }
+
/**
* Converts a base64 encoded client token to a Date representing the expiration date.
*
@@ -217,9 +261,4 @@ export default class AuthTwoFaController extends Controller {
const clientDate = new Date(utcDate.getTime() - clientTimezoneOffset * 60 * 1000);
return clientDate;
}
-
- @action handleOtpInput(otpValue) {
- this.verificationCode = otpValue;
- this.verifyCode();
- }
}
diff --git a/console/app/controllers/console/account/auth.js b/console/app/controllers/console/account/auth.js
new file mode 100644
index 00000000..f4087821
--- /dev/null
+++ b/console/app/controllers/console/account/auth.js
@@ -0,0 +1,81 @@
+import Controller from '@ember/controller';
+import { tracked } from '@glimmer/tracking';
+import { action } from '@ember/object';
+import { inject as service } from '@ember/service';
+import { task } from 'ember-concurrency-decorators';
+import getTwoFaMethods from '@fleetbase/console/utils/get-two-fa-methods';
+
+export default class ConsoleAccountAuthController extends Controller {
+ @service fetch;
+ @tracked password;
+ @tracked confirmPassword;
+ @tracked newPassword;
+ @tracked twoFaConfig = {};
+ @tracked twoFaSettings = {};
+ @tracked isSystemTwoFaEnabled = false;
+ @tracked methods = getTwoFaMethods();
+
+ constructor() {
+ super(...arguments);
+ this.loadSystemTwoFaConfig.perform();
+ this.loadUserTwoFaSettings.perform();
+ }
+
+ @action validatePassword(event) {
+ event.preventDefault();
+ }
+
+ @action changeUserPassword(event) {
+ event.preventDefault();
+ }
+
+ @action onTwoFaToggled(enabled) {
+ this.twoFaSettings = {
+ ...this.twoFaSettings,
+ enabled,
+ };
+ }
+
+ @action onTwoFaMethodSelected(method) {
+ this.twoFaSettings = {
+ ...this.twoFaSettings,
+ method,
+ };
+ }
+
+ @action saveTwoFactorAuthSettings() {
+ this.saveUserTwoFaSettings.perform(this.twoFaSettings);
+ }
+
+ @task *saveUserTwoFaSettings(twoFaSettings = {}) {
+ yield this.fetch
+ .post('users/two-fa', { twoFaSettings })
+ .then(() => {
+ this.notifications.success('2FA Settings saved successfully.');
+ })
+ .catch((error) => {
+ this.notifications.serverError(error);
+ });
+ }
+
+ @task *loadUserTwoFaSettings() {
+ const twoFaSettings = yield this.fetch.get('users/two-fa');
+
+ if (twoFaSettings) {
+ this.twoFaSettings = twoFaSettings;
+ }
+
+ return twoFaSettings;
+ }
+
+ @task *loadSystemTwoFaConfig() {
+ const twoFaConfig = yield this.fetch.get('two-fa/config');
+
+ if (twoFaConfig) {
+ this.isSystemTwoFaEnabled = twoFaConfig.enabled;
+ this.twoFaConfig = twoFaConfig;
+ }
+
+ return twoFaConfig;
+ }
+}
diff --git a/console/app/controllers/console/admin/two-fa-settings.js b/console/app/controllers/console/admin/two-fa-settings.js
index cab400c4..a7b85df8 100644
--- a/console/app/controllers/console/admin/two-fa-settings.js
+++ b/console/app/controllers/console/admin/two-fa-settings.js
@@ -2,6 +2,8 @@ import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
+import { task } from 'ember-concurrency-decorators';
+import getTwoFaMethods from '@fleetbase/console/utils/get-two-fa-methods';
/**
* Controller responsible for handling Two-Factor Authentication settings in the admin console.
@@ -38,16 +40,7 @@ export default class ConsoleAdminTwoFaSettingsController extends Controller {
* @memberof ConsoleAdminTwoFaSettingsController
* @type {Array}
*/
- @tracked methods = [
- {
- key: 'authenticator_app',
- name: 'Authenticator App',
- description: 'Get codes from an app like Authy, 1Password, Microsoft Authenticator, or Google Authenticator',
- recommended: true,
- },
- { key: 'sms', name: 'SMS', description: 'Receive a unique code via SMS' },
- { key: 'email', name: 'Email', description: 'Receive a unique code via Email' },
- ];
+ @tracked methods = getTwoFaMethods();
/**
* The 2FA settings value JSON.
@@ -57,7 +50,8 @@ export default class ConsoleAdminTwoFaSettingsController extends Controller {
*/
@tracked twoFaSettings = {
enabled: false,
- method: 'authenticator_app',
+ enforced: false,
+ method: 'email',
};
/**
@@ -75,7 +69,7 @@ export default class ConsoleAdminTwoFaSettingsController extends Controller {
*/
constructor() {
super(...arguments);
- this.loadSettings();
+ this.loadSystemTwoFaConfig.perform();
}
/**
@@ -89,33 +83,35 @@ export default class ConsoleAdminTwoFaSettingsController extends Controller {
}
/**
- * Action method triggered when a Two-Factor Authentication method is selected.
+ * Action method triggered when Two-Factor Authentication enforcement is toggled.
*
* @action
- * @param {String} method - The selected Two-Factor Authentication method.
+ * @param {Boolean} isEnabled - The new state of Two-Factor Authentication.
*/
- @action onTwoFaMethodSelected(method) {
- this.twoFaMethod = method;
+ @action onTwoFaEnforcedToggled(isEnabled) {
+ this.onTwoFaEnforcedToggled = isEnabled;
}
/**
- * Action method to load Two-Factor Authentication settings from the server.
+ * Action method triggered when a Two-Factor Authentication method is selected.
*
* @action
- * @returns {Promise}
+ * @param {String} method - The selected Two-Factor Authentication method.
*/
- @action loadSettings() {
- return this.fetch
- .get('two-fa/settings')
- .then((twoFaSettings) => {
- this.twoFaSettings = twoFaSettings;
- })
- .catch((error) => {
- this.notifications.serverError(error);
- })
- .finally(() => {
- this.isLoading = false;
- });
+ @action onTwoFaMethodSelected(method) {
+ this.twoFaMethod = method;
+ }
+
+ @task *loadSystemTwoFaConfig() {
+ const twoFaSettings = yield this.fetch.get('two-fa/config').catch((error) => {
+ this.notifications.serverError(error);
+ });
+
+ if (twoFaSettings) {
+ this.twoFaSettings = twoFaSettings;
+ }
+
+ return twoFaSettings;
}
/**
@@ -129,15 +125,16 @@ export default class ConsoleAdminTwoFaSettingsController extends Controller {
@action saveSettings() {
const twoFaSettings = {
enabled: this.isTwoFaEnabled,
+ enforced: this.isTwoFaEnforced,
method: this.twoFaMethod,
};
this.isLoading = true;
return this.fetch
- .post('two-fa/settings', { twoFaSettings })
+ .post('two-fa/config', { twoFaSettings })
.then(() => {
- this.notifications.success('2FA Settings saved successfully.');
+ this.notifications.success('2FA Configuration saved successfully.');
})
.catch((error) => {
this.notifications.serverError(error);
diff --git a/console/app/controllers/console/settings/auth.js b/console/app/controllers/console/settings/auth.js
new file mode 100644
index 00000000..af8e543a
--- /dev/null
+++ b/console/app/controllers/console/settings/auth.js
@@ -0,0 +1,3 @@
+import Controller from '@ember/controller';
+
+export default class ConsoleSettingsAuthController extends Controller {}
diff --git a/console/app/routes/auth/two-fa.js b/console/app/routes/auth/two-fa.js
index 18defca3..c2e2f0d1 100644
--- a/console/app/routes/auth/two-fa.js
+++ b/console/app/routes/auth/two-fa.js
@@ -58,13 +58,18 @@ export default class AuthTwoFaRoute extends Route {
return this.session.store.restore().then(({ identity }) => {
if (!identity) {
- this.notifications.error('Two Factor Authentication failed to start.');
+ this.notifications.error('2FA failed to initialize.');
return this.router.transitionTo('auth.login');
}
return this.fetch
- .post('two-fa/validate-session', { token, identity, clientToken })
- .then(({ clientToken }) => {
+ .post('two-fa/validate', { token, identity, clientToken })
+ .then(({ clientToken, expired }) => {
+ // handle when code expired
+ if (expired === true) {
+ return this.invalidateTwoFaSession(token, identity);
+ }
+
// clear session data after validated 2fa session
this.session.store.persist({
identity,
@@ -94,4 +99,16 @@ export default class AuthTwoFaRoute extends Route {
controller.countdownReady = true;
});
}
+
+ invalidateTwoFaSession(token, identity) {
+ this.notifications.error('2FA authentication session has expired.');
+ return this.fetch
+ .post('two-fa/invalidate', {
+ token,
+ identity,
+ })
+ .then(() => {
+ return this.router.transitionTo('auth.login');
+ });
+ }
}
diff --git a/console/app/routes/console/account/auth.js b/console/app/routes/console/account/auth.js
new file mode 100644
index 00000000..bad9dc73
--- /dev/null
+++ b/console/app/routes/console/account/auth.js
@@ -0,0 +1,3 @@
+import Route from '@ember/routing/route';
+
+export default class ConsoleAccountAuthRoute extends Route {}
diff --git a/console/app/routes/console/settings/auth.js b/console/app/routes/console/settings/auth.js
new file mode 100644
index 00000000..9852f402
--- /dev/null
+++ b/console/app/routes/console/settings/auth.js
@@ -0,0 +1,3 @@
+import Route from '@ember/routing/route';
+
+export default class ConsoleSettingsAuthRoute extends Route {}
diff --git a/console/app/templates/auth/two-fa.hbs b/console/app/templates/auth/two-fa.hbs
index cf914841..cbe51c69 100644
--- a/console/app/templates/auth/two-fa.hbs
+++ b/console/app/templates/auth/two-fa.hbs
@@ -19,10 +19,16 @@
<div class="flex items-center justify-between my-6">
<OtpInput @onInputCompleted={{this.handleOtpInput}} />
</div>
-
- <div id="otp-countdown-container" class="otp-countdown-container flex items-center justify-center h-12">
+
+ <div id="otp-countdown-container" class="otp-countdown-container flex items-center justify-center min-h-12">
{{#if this.countdownReady}}
- <Countdown @expiry={{this.twoFactorSessionExpiresAfter}} @countdownClass="text-lg" />
+ <Countdown @expiry={{this.twoFactorSessionExpiresAfter}} @countdownClass="text-lg" @onCountdownEnd={{this.handleCodeExpired}} />
+ {{/if}}
+ {{#if this.isCodeExpired}}
+ <InfoBlock>
+ <div>Your 2FA authentication code has expired. You can request another code if you need more time.</div>
+ <Button @type="primary" @wrapperClass="mt-2" @text="Resend Code" @icon="arrow-rotate-right" @onClick={{this.resendCode}} />
+ </InfoBlock>
{{/if}}
</div>
@@ -30,9 +36,12 @@
<Button @buttonType="submit" @type="primary" @text="Verify Code" @icon="check-circle" @wrapperClass="btn-block" @isLoading={{this.isLoading}} />
</div>
- <div class="text-center mt-3.5">
+ <div class="text-center flex flex-row items-center justify-center space-x-4 mt-3.5">
<a href="#" class="text-sm text-blue-500 hover:underline inline-block" {{on "click" this.resendCode}}>
Resend Code
</a>
+ <a href="#" class="text-sm text-danger hover:underline inline-block" {{on "click" this.cancelTwoFactor}}>
+ Cancel Two-Factor
+ </a>
</div>
</form>
\ No newline at end of file
diff --git a/console/app/templates/console/account.hbs b/console/app/templates/console/account.hbs
index 1340ac5c..bab2ebfe 100644
--- a/console/app/templates/console/account.hbs
+++ b/console/app/templates/console/account.hbs
@@ -2,6 +2,7 @@
<EmberWormhole @to="sidebar-menu-items">
<Layout::Sidebar::Panel @open={{true}} @title="Account">
<Layout::Sidebar::Item @route="console.account.index" @icon="user">Profile</Layout::Sidebar::Item>
+ <Layout::Sidebar::Item @route="console.account.auth" @icon="key">Auth</Layout::Sidebar::Item>
{{#each this.universe.accountMenuItems as |menuItem|}}
<Layout::Sidebar::Item @onClick={{fn this.universe.transitionMenuItem "console.account.virtual" menuItem}} @item={{menuItem}} @icon={{menuItem.icon}}>{{menuItem.title}}</Layout::Sidebar::Item>
{{/each}}
diff --git a/console/app/templates/console/account/auth.hbs b/console/app/templates/console/account/auth.hbs
new file mode 100644
index 00000000..fb423552
--- /dev/null
+++ b/console/app/templates/console/account/auth.hbs
@@ -0,0 +1,44 @@
+{{page-title "Account Auth"}}
+<Layout::Section::Header @title="Account Auth" />
+
+<Layout::Section::Body class="overflow-y-scroll h-full">
+ <div class="container mx-auto h-screen" {{increase-height-by 500}}>
+ <div class="max-w-3xl my-10 mx-auto space-y-6">
+ <ContentPanel @title="Change Password" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
+ {{#unless this.passwordsValidated}}
+ <form id="validate-password-form" aria-label="validate-password" {{on "submit" this.validatePassword}}>
+ <legend class="mb-3">Validate Current Password</legend>
+ <div class="grid grid-cols-1 lg:grid-cols-2 gap-4">
+ <InputGroup @name="Password" @type="password" @value={{this.password}} />
+ <InputGroup @name="Confirm Password" @type="password" @value={{this.confirmPassword}} />
+ </div>
+ <Button @type="primary" @buttonType="submit" @text="Continue" @icon="check" />
+ </form>
+ {{else}}
+ <form id="change-password-form" aria-label="change-password" {{on "submit" this.changeUserPassword}}>
+ <legend class="mb-3">Change Password</legend>
+ <div class="grid grid-cols-1 gap-4">
+ <InputGroup @name="Enter new Password" @type="password" @value={{this.newPassword}} />
+ </div>
+ <Button @type="primary" @buttonType="submit" @text="Confirm & Change Password" @icon="save" />
+ </form>
+ {{/unless}}
+ </ContentPanel>
+
+ {{#if this.isSystemTwoFaEnabled}}
+ <ContentPanel @title="2FA Settings" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
+ <div class="mb-3">
+ {{#if this.loadUserTwoFaSettings.isIdle}}
+ <TwoFaSettings @twoFaMethods={{this.methods}} @twoFaSettings={{this.twoFaSettings}} @onTwoFaToggled={{this.onTwoFaToggled}} @onTwoFaMethodSelected={{this.onTwoFaMethodSelected}} />
+ {{else}}
+ <div class="flex items-center justify-center p-4">
+ <Spinner @loadingMessage="Loading User 2FA Settings..." @wrapperClass="flex flex-row" @iconClass="mr-2" />
+ </div>
+ {{/if}}
+ </div>
+ <Button @type="primary" @buttonType="submit" @text="Save 2FA Settings" @icon="save" @onClick={{this.saveTwoFactorAuthSettings}} @isLoading={{this.saveUserTwoFaSettings.isRunning}} />
+ </ContentPanel>
+ {{/if}}
+ </div>
+ </div>
+</Layout::Section::Body>
\ No newline at end of file
diff --git a/console/app/templates/console/admin.hbs b/console/app/templates/console/admin.hbs
index 07fc705c..3e436953 100644
--- a/console/app/templates/console/admin.hbs
+++ b/console/app/templates/console/admin.hbs
@@ -4,7 +4,7 @@
<Layout::Sidebar::Item @route="console.admin.index" @icon="rectangle-list">Overview</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.admin.branding" @icon="palette">Branding</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.admin.notifications" @icon="bell">Notifications</Layout::Sidebar::Item>
- <Layout::Sidebar::Item @route="console.admin.two-fa-settings" @icon="shield">2FA config</Layout::Sidebar::Item>
+ <Layout::Sidebar::Item @route="console.admin.two-fa-settings" @icon="shield">2FA Config</Layout::Sidebar::Item>
{{#each this.universe.adminMenuItems as |menuItem|}}
<Layout::Sidebar::Item @onClick={{fn this.universe.transitionMenuItem "console.admin.virtual" menuItem}} @item={{menuItem}} @icon={{menuItem.icon}}>{{menuItem.title}}</Layout::Sidebar::Item>
{{/each}}
diff --git a/console/app/templates/console/admin/branding.hbs b/console/app/templates/console/admin/branding.hbs
index 5eaa022d..17a9b72d 100644
--- a/console/app/templates/console/admin/branding.hbs
+++ b/console/app/templates/console/admin/branding.hbs
@@ -5,7 +5,7 @@
<Layout::Section::Body class="overflow-y-scroll h-full">
<div class="container mx-auto h-screen" {{increase-height-by 300}}>
- <div class="max-w-3xl my-10 mx-auto space-y-">
+ <div class="max-w-3xl my-10 mx-auto space-y-6">
<ContentPanel @title="Branding" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<form class="flex flex-col" {{on "submit" this.save}}>
<div class="input-group">
diff --git a/console/app/templates/console/admin/two-fa-settings.hbs b/console/app/templates/console/admin/two-fa-settings.hbs
index f9180f5f..9170354a 100644
--- a/console/app/templates/console/admin/two-fa-settings.hbs
+++ b/console/app/templates/console/admin/two-fa-settings.hbs
@@ -7,12 +7,13 @@
<div class="container mx-auto h-screen" {{increase-height-by 1200}}>
<div class="max-w-3xl my-10 mx-auto space-y-4">
<ContentPanel @title="2FA Config" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
- <TwoFaSettings
- @twoFaMethods={{this.methods}}
- @twoFaSettings={{this.twoFaSettings}}
- @onTwoFaToggled={{this.onTwoFaToggled}}
- @onTwoFaMethodSelected={{this.onTwoFaMethodSelected}}
- />
+ {{#if this.loadSystemTwoFaConfig.isIdle}}
+ <TwoFaSettings @showEnforceOption={{true}} @twoFaMethods={{this.methods}} @twoFaSettings={{this.twoFaSettings}} @onTwoFaToggled={{this.onTwoFaToggled}} @onTwoFaEnforcedToggled={{this.onTwoFaEnforcedToggled}} @onTwoFaMethodSelected={{this.onTwoFaMethodSelected}} />
+ {{else}}
+ <div class="flex items-center justify-center p-4">
+ <Spinner @loadingMessage="Loading 2FA Config..." @wrapperClass="flex flex-row" @iconClass="mr-2" />
+ </div>
+ {{/if}}
</ContentPanel>
</div>
</div>
diff --git a/console/app/templates/console/settings/auth.hbs b/console/app/templates/console/settings/auth.hbs
new file mode 100644
index 00000000..3238cf1d
--- /dev/null
+++ b/console/app/templates/console/settings/auth.hbs
@@ -0,0 +1,2 @@
+{{page-title "Auth"}}
+{{outlet}}
\ No newline at end of file
diff --git a/console/app/utils/get-two-fa-methods.js b/console/app/utils/get-two-fa-methods.js
new file mode 100644
index 00000000..fc26f0b8
--- /dev/null
+++ b/console/app/utils/get-two-fa-methods.js
@@ -0,0 +1,12 @@
+export default function getTwoFaMethods() {
+ return [
+ // {
+ // key: 'authenticator_app',
+ // name: 'Authenticator App',
+ // description: 'Get codes from an app like Authy, 1Password, Microsoft Authenticator, or Google Authenticator',
+ // recommended: true,
+ // },
+ { key: 'sms', name: 'SMS', description: 'Receive a unique code via SMS' },
+ { key: 'email', name: 'Email', description: 'Receive a unique code via Email' },
+ ];
+}
diff --git a/console/router.map.js b/console/router.map.js
index 26dd8ddd..148569a5 100644
--- a/console/router.map.js
+++ b/console/router.map.js
@@ -26,9 +26,11 @@ Router.map(function () {
this.route('notifications');
this.route('account', function () {
this.route('virtual', { path: '/:slug/:view' });
+ this.route('auth');
});
this.route('settings', function () {
this.route('virtual', { path: '/:slug/:view' });
+ this.route('auth');
});
this.route('virtual', { path: '/:slug/:view' });
this.route('admin', function () {
diff --git a/console/tests/unit/controllers/console/account/auth-test.js b/console/tests/unit/controllers/console/account/auth-test.js
new file mode 100644
index 00000000..3c907279
--- /dev/null
+++ b/console/tests/unit/controllers/console/account/auth-test.js
@@ -0,0 +1,12 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Controller | console/account/auth', function (hooks) {
+ setupTest(hooks);
+
+ // TODO: Replace this with your real tests.
+ test('it exists', function (assert) {
+ let controller = this.owner.lookup('controller:console/account/auth');
+ assert.ok(controller);
+ });
+});
diff --git a/console/tests/unit/controllers/console/settings/auth-test.js b/console/tests/unit/controllers/console/settings/auth-test.js
new file mode 100644
index 00000000..4842aca1
--- /dev/null
+++ b/console/tests/unit/controllers/console/settings/auth-test.js
@@ -0,0 +1,12 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Controller | console/settings/auth', function (hooks) {
+ setupTest(hooks);
+
+ // TODO: Replace this with your real tests.
+ test('it exists', function (assert) {
+ let controller = this.owner.lookup('controller:console/settings/auth');
+ assert.ok(controller);
+ });
+});
diff --git a/console/tests/unit/routes/console/account/auth-test.js b/console/tests/unit/routes/console/account/auth-test.js
new file mode 100644
index 00000000..07d77cd8
--- /dev/null
+++ b/console/tests/unit/routes/console/account/auth-test.js
@@ -0,0 +1,11 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Route | console/account/auth', function (hooks) {
+ setupTest(hooks);
+
+ test('it exists', function (assert) {
+ let route = this.owner.lookup('route:console/account/auth');
+ assert.ok(route);
+ });
+});
diff --git a/console/tests/unit/routes/console/settings/auth-test.js b/console/tests/unit/routes/console/settings/auth-test.js
new file mode 100644
index 00000000..ead1c662
--- /dev/null
+++ b/console/tests/unit/routes/console/settings/auth-test.js
@@ -0,0 +1,11 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Route | console/settings/auth', function (hooks) {
+ setupTest(hooks);
+
+ test('it exists', function (assert) {
+ let route = this.owner.lookup('route:console/settings/auth');
+ assert.ok(route);
+ });
+});
diff --git a/console/tests/unit/utils/get-two-fa-methods-test.js b/console/tests/unit/utils/get-two-fa-methods-test.js
new file mode 100644
index 00000000..884379d3
--- /dev/null
+++ b/console/tests/unit/utils/get-two-fa-methods-test.js
@@ -0,0 +1,10 @@
+import getTwoFaMethods from '@fleetbase/console/utils/get-two-fa-methods';
+import { module, test } from 'qunit';
+
+module('Unit | Utility | get-two-fa-methods', function () {
+ // TODO: Replace this with your real tests.
+ test('it works', function (assert) {
+ let result = getTwoFaMethods();
+ assert.ok(result);
+ });
+});