Skip to content

Commit

Permalink
disable passwordless for macOS (#495)
Browse files Browse the repository at this point in the history
Testing suggests that DSSO isn't enabled/configured for macOS at D2L, so
- we cannot test passwordless auth on macOS
- enabling it would mean a few seconds of useless waiting for D2L Mac
users and a subpar UX
  • Loading branch information
cfbao authored Oct 29, 2024
1 parent 3dcee26 commit 9698451
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
35 changes: 17 additions & 18 deletions src/D2L.Bmx/BrowserLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ internal class BrowserLauncher : IBrowserLauncher {
"Microsoft\\Edge\\Application\\msedge.exe",
"Google\\Chrome\\Application\\chrome.exe",
];
private static readonly string[] MacPaths = [
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
];

async Task<IBrowser> IBrowserLauncher.LaunchAsync( string browserPath ) {
var launchOptions = new LaunchOptions {
Expand All @@ -40,24 +36,27 @@ async Task<IBrowser> IBrowserLauncher.LaunchAsync( string browserPath ) {

bool IBrowserLauncher.TryGetPathToBrowser( [NotNullWhen( returnValue: true )] out string? path ) {
path = null;
if( OperatingSystem.IsWindows() ) {
foreach( string windowsPartialPath in WindowsPartialPaths ) {
foreach( string environmentVariable in WindowsEnvironmentVariables ) {
string? prefix = Environment.GetEnvironmentVariable( environmentVariable );
if( prefix is not null ) {
path = Path.Join( prefix, windowsPartialPath );
if( File.Exists( path ) ) {
return true;
}
if( !OperatingSystem.IsWindows() ) {
return false;
}

foreach( string windowsPartialPath in WindowsPartialPaths ) {
foreach( string environmentVariable in WindowsEnvironmentVariables ) {
string? prefix = Environment.GetEnvironmentVariable( environmentVariable );
if( prefix is not null ) {
path = Path.Join( prefix, windowsPartialPath );
if( File.Exists( path ) ) {
return true;
}
}
}
} else if( OperatingSystem.IsMacOS() ) {
path = Array.Find( MacPaths, File.Exists );
return path is not null;
}
// Okta DSSO is only supported for Windows and Mac. There's no point for us to support Linux.
// Chromium is finicky on Linux anyway.

/* We only support passwordless auth on Windows at this point, because
- Okta only supports DSSO on Windows and Mac, so Linux is out.
- D2L hasn't configured DSSO for Mac, so we can't test it on macOS either.
*/
path = null;
return false;
}
}
4 changes: 2 additions & 2 deletions src/D2L.Bmx/OktaAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ bool ignoreCache
}

if(
// `TryGetPathToBrowser` does return `false` for Linux, but excluding Linux earlier here helps
// `TryGetPathToBrowser` only returns `true` for Windows, but restricting to Windows earlier here helps
// the compiler trim more unused code (e.g. all of PuppeteerSharp)
!OperatingSystem.IsLinux()
OperatingSystem.IsWindows()
&& browserLauncher.TryGetPathToBrowser( out string? browserPath )
) {
if( !nonInteractive ) {
Expand Down

0 comments on commit 9698451

Please sign in to comment.