diff --git a/KeeAnywhere/OAuth2/OidcSystemBrowser.cs b/KeeAnywhere/OAuth2/OidcSystemBrowser.cs index f2b57d3..90b43e3 100644 --- a/KeeAnywhere/OAuth2/OidcSystemBrowser.cs +++ b/KeeAnywhere/OAuth2/OidcSystemBrowser.cs @@ -35,20 +35,24 @@ private static bool CreateListener(out string redirectUri, out HttpListener list ports = Enumerable.Range(49215, 16321); } + string[] hosts = { "127.0.0.1", "localhost" }; foreach (var port in ports) { - redirectUri = CreateRedirectUri(port); - listener = new HttpListener(); - listener.Prefixes.Add(redirectUri); - try + foreach (var host in hosts) { - listener.Start(); + redirectUri = CreateRedirectUri(host, port); + listener = new HttpListener(); + listener.Prefixes.Add(redirectUri); + try + { + listener.Start(); - return true; - } - catch - { - // nothing to do here -- the listener disposes itself when Start throws + return true; + } + catch + { + // nothing to do here -- the listener disposes itself when Start throws + } } } @@ -58,9 +62,9 @@ private static bool CreateListener(out string redirectUri, out HttpListener list return false; } - private static string CreateRedirectUri(int port) + private static string CreateRedirectUri(string host, int port) { - return "http://127.0.0.1:" + port + "/"; + return "http://" + host + ":" + port + "/"; } public string RedirectUri