Skip to content

Commit

Permalink
Merge pull request #313 from Jackabomb/oauth-uri-localhost-301
Browse files Browse the repository at this point in the history
Changed OidcBrowser url from 127.0.0.1 to localhost. Fixes #301.
  • Loading branch information
Kyrodan authored Jun 25, 2024
2 parents 569f41f + 1f43911 commit 0651943
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions KeeAnywhere/OAuth2/OidcSystemBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

Expand All @@ -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
Expand Down

0 comments on commit 0651943

Please sign in to comment.