Added LinkedInAuthenticationOptions.Proxy host for web applications running behind a proxy. This allows the middleware to authenticate for the proxy request host instead of the application request host. (#213)
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Owin.Security.Providers.LinkedIn
|
||||
return new AuthenticationTicket(null, properties);
|
||||
}
|
||||
|
||||
var requestPrefix = Request.Scheme + "://" + Request.Host;
|
||||
var requestPrefix = Request.Scheme + "://" + this.GetHostName();
|
||||
var redirectUri = requestPrefix + Request.PathBase + Options.CallbackPath;
|
||||
|
||||
// Build up the body for the token request
|
||||
@@ -173,7 +173,7 @@ namespace Owin.Security.Providers.LinkedIn
|
||||
var baseUri =
|
||||
Request.Scheme +
|
||||
Uri.SchemeDelimiter +
|
||||
Request.Host +
|
||||
this.GetHostName() +
|
||||
Request.PathBase;
|
||||
|
||||
var currentUri =
|
||||
@@ -271,5 +271,15 @@ namespace Owin.Security.Providers.LinkedIn
|
||||
|
||||
return context.IsRequestCompleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets proxy host name from <see cref="LinkedInAuthenticationOptions"/> if it is set.
|
||||
/// If proxy host name is not set, gets application request host name.
|
||||
/// </summary>
|
||||
/// <returns>Host name.</returns>
|
||||
private string GetHostName()
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(Options.ProxyHost) ? Request.Host.ToString() : Options.ProxyHost;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,16 @@ namespace Owin.Security.Providers.LinkedIn
|
||||
/// </summary>
|
||||
public PathString CallbackPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the middleware host name.
|
||||
/// The middleware processes the <see cref="CallbackPath"/> on this host name instead of the application's request host.
|
||||
/// If this is not set, the application's request host will be used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Use this property when running behind a proxy.
|
||||
/// </remarks>
|
||||
public string ProxyHost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get or sets the text that the user can display on a sign in user interface.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user