fix: 🐛 cannot retry oidc authentication in desktop & admin (#2512)

* fix: 🐛 cannot retry oidc authentication in desktop & admin

✅ Closes: https://hashicorp.atlassian.net/browse/ICU-15250
This commit is contained in:
Lisbet Alvarez authored and GitHub committed 2024-10-08 10:29:21 -07:00
1 parent 64e568bd72
commit e807e1a3af
6 files changed
+18 -9

No files matched your search

@@ -3,12 +3,10 @@
* SPDX-License-Identifier: BUSL-1.1
*/
import Controller, { inject as controller } from '@ember/controller';
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class ScopesScopeAuthenticateMethodOidcController extends Controller {
@controller('scopes/scope/authenticate/method/index') authMethod;
// =services
@service session;
@@ -12,7 +12,7 @@
<p>{{t 'resources.auth-method.messages.pending.description'}}</p>
<p>
{{t 'resources.auth-method.questions.no-see-window'}}
<a href='#' role='button' {{on 'click' this.authMethod.authenticate}}>
<a href={{this.authURL}} target='_blank' rel='noreferrer noopener'>
{{t 'actions.retry'}}
</a>
</p>
@@ -16,7 +16,6 @@ module(
'controller:scopes/scope/authenticate/method/oidc',
);
assert.ok(controller);
assert.ok(controller.authMethod);
});
},
);
+3 -1
View File
@@ -34,6 +34,7 @@ const menu = require('./config/menu.js');
const appUpdater = require('./helpers/app-updater.js');
const { isMac, isLinux, isWindows } = require('./helpers/platform.js');
const fixPath = require('./utils/fixPath');
const isLocalhost = require('./utils/isLocalhost');
const config = require('../config/config.js');
const { version } = require('./cli/index.js');
const isDev = require('electron-is-dev');
@@ -160,6 +161,7 @@ const createWindow = (partition, closeWindowCB) => {
// link to the release page for the desktop app.
browserWindow.webContents.setWindowOpenHandler(({ url }) => {
if (
isLocalhost(url) ||
url.startsWith('https://developer.hashicorp.com/') ||
url.startsWith('https://releases.hashicorp.com/boundary-desktop/')
) {
@@ -262,7 +264,7 @@ app.on('ready', async () => {
appUpdater.run({ suppressNoUpdatePrompt: true });
/**
* Need for Mac OS behaviour of closing the window but not the app.
* Need for Mac OS behavior of closing the window but not the app.
* This allows to reopen the window if the user clicks Boundary icon in the dock
* while the app is not close.
* More info: https://www.electronjs.org/docs/latest/tutorial/quick-start#open-a-window-if-none-are-open-macos
+2 -3
View File
@@ -10,6 +10,7 @@ const boundaryCli = require('../cli/index.js');
const sessionManager = require('../services/session-manager.js');
const runtimeSettings = require('../services/runtime-settings.js');
const sanitizer = require('../utils/sanitizer.js');
const isLocalhost = require('../utils/isLocalhost');
const { isLinux, isMac, isWindows } = require('../helpers/platform.js');
const os = require('node:os');
const pty = require('node-pty');
@@ -46,11 +47,9 @@ handle('resetClusterUrl', async () => runtimeSettings.resetClusterUrl());
* testing workflows). Insecure URLs are allowed in dev mode.
*/
handle('openExternal', async (href) => {
const localhostRegex = /^http:\/\/(localhost|127\.0\.0\.1):\d{1,5}(?:\/|$)/i;
const isLocalhost = localhostRegex.test(href);
const isSecure = href.startsWith('https://');
if (isSecure || isLocalhost || isDev) {
if (isSecure || isLocalhost(href) || isDev) {
/**
* Launch browser to display documentation and to support arbitrary OIDC flows
* using openExternal. The protocol is validated (see above).
@@ -0,0 +1,11 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
const isLocalhost = (url) => {
const localhostRegex = /^http:\/\/(localhost|127\.0\.0\.1):\d{1,5}(?:\/|$)/i;
return localhostRegex.test(url);
};
module.exports = isLocalhost;