Fixed the Identity Server discovery bug #1456 #865

pull/1488/head
tidusjar 7 years ago
parent c196dce843
commit 22aca7d2fd

@ -4,6 +4,14 @@
### **New Features** ### **New Features**
- Change the RID. [Jamie.Rees]
- Update README.md. [Jamie]
- Update README.md. [Jamie]
- Updated Changelog. [Jamie.Rees]
- Added changelog. [Jamie.Rees] - Added changelog. [Jamie.Rees]
- Update README.md. [Jamie] - Update README.md. [Jamie]
@ -76,6 +84,26 @@
### **Fixes** ### **Fixes**
- Fixed the issue with the Identity Server running on a different port, we can now use -url #865. [Jamie.Rees]
- Try again. [TidusJar]
- Publish ubuntu 16.04. [Jamie.Rees]
- Chnaged the updater job from Minutely to Hourly. [Jamie.Rees]
- Some work around the Auto Updater and other small changes #1460 #865. [Jamie.Rees]
- Missed a file. [tidusjar]
- Fixed the swagger issue. [tidusjar]
- RDP issues. [tidusjar]
- Appveyor build rdp investigation. [tidusjar]
- Working on the requests page #1457 #865. [tidusjar]
- Made the password reset email style the same as other email notifications #1456 #865. [Jamie.Rees] - Made the password reset email style the same as other email notifications #1456 #865. [Jamie.Rees]
- Fixed some bugs around the authentication #1456 #865. [Jamie.Rees] - Fixed some bugs around the authentication #1456 #865. [Jamie.Rees]

@ -12,5 +12,6 @@ namespace Ombi.Store.Entities
public enum ConfigurationTypes public enum ConfigurationTypes
{ {
Url, Url,
Port,
} }
} }

@ -13,34 +13,59 @@ namespace Ombi
public static void Main(string[] args) public static void Main(string[] args)
{ {
Console.Title = "Ombi"; Console.Title = "Ombi";
var urlArgs = "http://*:5000"; var port = 5000;
var urlArgs = $"http://*:{port}";
if (args.Length <= 0) if (args.Length <= 0)
{ {
Console.WriteLine("No URL provided, we will run on \"http://localhost:5000\""); Console.WriteLine("No URL provided, we will run on \"http://localhost:5000\"");
Console.WriteLine("Please provider the argument -url e.g. \"ombi.exe -url http://ombi.io:80/\""); //Console.WriteLine("Please provider the argument -url e.g. \"ombi.exe -url http://ombi.io:80/\"");
} }
else else
{ {
if (args[0].Contains("-url")) if (args[0].Contains("-url"))
{ {
urlArgs = args[0].Replace("-url ", string.Empty); try
{
urlArgs = args[0].Replace("-url ", string.Empty);
var index = urlArgs.IndexOf(':', urlArgs.IndexOf(':') + 1);
var portString = urlArgs.Substring(index + 1, urlArgs.Length - index - 1);
port = int.Parse(portString);
urlArgs = urlArgs.Substring(0, urlArgs.Length - portString.Length - 1);
}
catch (Exception e)
{
Console.WriteLine("Port is not defined or correctly formatted");
Console.WriteLine(e.Message);
Console.ReadLine();
Environment.Exit(1);
}
} }
} }
var urlValue = string.Empty; var urlValue = string.Empty;
using (var ctx = new OmbiContext()) using (var ctx = new OmbiContext())
{ {
var url = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Url); var url = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
if (url == null) var savedPort = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Port);
if (url == null && savedPort == null)
{ {
url = new ApplicationConfiguration url = new ApplicationConfiguration
{ {
Type = ConfigurationTypes.Url, Type = ConfigurationTypes.Url,
Value = "http://*:5000" Value = "http://*"
};
var dbPort = new ApplicationConfiguration
{
Type = ConfigurationTypes.Port,
Value = "5000"
}; };
ctx.ApplicationConfigurations.Add(url); ctx.ApplicationConfigurations.Add(url);
ctx.ApplicationConfigurations.Add(dbPort);
ctx.SaveChanges(); ctx.SaveChanges();
urlValue = url.Value; urlValue = url.Value;
port = int.Parse(dbPort.Value);
} }
else if (!url.Value.Equals(urlArgs)) else if (!url.Value.Equals(urlArgs))
{ {
@ -48,6 +73,13 @@ namespace Ombi
ctx.SaveChanges(); ctx.SaveChanges();
urlValue = url.Value; urlValue = url.Value;
} }
if (savedPort != null && !savedPort.Value.Equals(port.ToString()))
{
savedPort.Value = port.ToString() ;
ctx.SaveChanges();
}
} }
Console.WriteLine($"We are running on {urlValue}"); Console.WriteLine($"We are running on {urlValue}");
@ -56,7 +88,7 @@ namespace Ombi
.UseKestrel() .UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.UseUrls(urlValue) .UseUrls($"{urlValue}:{port}")
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();

@ -187,13 +187,18 @@ namespace Ombi
// Get the url // Get the url
var url = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Url); var url = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Url);
var port = ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == ConfigurationTypes.Port);
Console.WriteLine($"Using Url {url.Value} for Identity Server"); Console.WriteLine($"Using Url {url.Value}:{port.Value} for Identity Server");
app.UseIdentity(); app.UseIdentity();
app.UseIdentityServer(); app.UseIdentityServer();
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{ {
Authority = url.Value, #if !DEBUG
Authority = $"{url.Value}:{port.Value}",
#else
Authority = $"http://localhost:52038/",
#endif
ApiName = "api", ApiName = "api",
ApiSecret = "secret", ApiSecret = "secret",
@ -201,7 +206,8 @@ namespace Ombi
CacheDuration = TimeSpan.FromMinutes(10), // that's the default CacheDuration = TimeSpan.FromMinutes(10), // that's the default
RequireHttpsMetadata = options.Value.UseHttps, // FOR DEV set to false RequireHttpsMetadata = options.Value.UseHttps, // FOR DEV set to false
AutomaticAuthenticate = true, AutomaticAuthenticate = true,
AutomaticChallenge = true AutomaticChallenge = true,
}); });

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save