Feature Request - Config option to Disable new authentication flow #1

This commit is contained in:
sim0n00ps 2025-05-05 20:57:09 +01:00
parent 0eb2a6dbeb
commit 09c14be5dd
2 changed files with 45 additions and 6 deletions

View File

@ -97,6 +97,9 @@ namespace OF_DL.Entities
[ToggleableConfig]
public bool IgnoreOwnMessages { get; set; } = false;
[ToggleableConfig]
public bool DisableBrowserAuth { get; set; } = false;
}
public class CreatorConfig : IFileNameFormatConfig

View File

@ -251,6 +251,9 @@ public class Program
config = new Entities.Config
{
//Auth
DisableBrowserAuth = hoconConfig.GetBoolean("DisableBrowserAuth"),
// FFmpeg Settings
FFmpegPath = hoconConfig.GetString("External.FFmpegPath"),
@ -363,6 +366,8 @@ public class Program
{
Entities.Config jsonConfig = new Entities.Config();
var hoconConfig = new StringBuilder();
hoconConfig.AppendLine("# Auth");
hoconConfig.AppendLine($"DisableBrowserAuth = {jsonConfig.DisableBrowserAuth.ToString().ToLower()}");
hoconConfig.AppendLine("# External Tools");
hoconConfig.AppendLine("External {");
hoconConfig.AppendLine($" FFmpegPath = \"{jsonConfig.FFmpegPath}\"");
@ -542,8 +547,22 @@ public class Program
Environment.Exit(2);
}
await LoadAuthFromBrowser();
}
if (!config!.DisableBrowserAuth)
{
await LoadAuthFromBrowser();
}
else
{
AnsiConsole.MarkupLine($"\n[red]auth.json is missing. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n");
AnsiConsole.MarkupLine($"[red]You may also want to try using the browser extension which is documented here:[/]\n");
AnsiConsole.MarkupLine($"[link]https://sim0n00ps.github.io/OF-DL/docs/config/auth#browser-extension[/]\n");
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
Console.ReadKey();
Environment.Exit(2);
}
}
}
else
{
@ -558,7 +577,20 @@ public class Program
Environment.Exit(2);
}
await LoadAuthFromBrowser();
if (!config!.DisableBrowserAuth)
{
await LoadAuthFromBrowser();
}
else
{
AnsiConsole.MarkupLine($"\n[red]auth.json is missing. The file can be generated automatically when OF-DL is run in the standard, interactive mode.[/]\n");
AnsiConsole.MarkupLine($"[red]You may also want to try using the browser extension which is documented here:[/]\n");
AnsiConsole.MarkupLine($"[link]https://sim0n00ps.github.io/OF-DL/docs/config/auth#browser-extension[/]\n");
AnsiConsole.MarkupLine($"[red]Press any key to exit.[/]");
Console.ReadKey();
Environment.Exit(2);
}
}
//Added to stop cookie being filled with un-needed headers
@ -717,10 +749,10 @@ public class Program
File.Delete("auth.json");
}
if (!cliNonInteractive)
if (!cliNonInteractive && !config!.DisableBrowserAuth)
{
await LoadAuthFromBrowser();
}
await LoadAuthFromBrowser();
}
if (auth == null)
{
@ -2791,6 +2823,8 @@ public class Program
}
var hoconConfig = new StringBuilder();
hoconConfig.AppendLine("# Auth");
hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}");
hoconConfig.AppendLine("# External Tools");
hoconConfig.AppendLine("External {");
hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\"");
@ -2947,6 +2981,8 @@ public class Program
Log.Debug(configString);
var hoconConfig = new StringBuilder();
hoconConfig.AppendLine("# Auth");
hoconConfig.AppendLine($"DisableBrowserAuth = {newConfig.DisableBrowserAuth.ToString().ToLower()}");
hoconConfig.AppendLine("# External Tools");
hoconConfig.AppendLine("External {");
hoconConfig.AppendLine($" FFmpegPath = \"{newConfig.FFmpegPath}\"");