Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable passwordless for macOS #495

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading