Skip to content

Commit

Permalink
Merge pull request #239 from pdsrebelo/master
Browse files Browse the repository at this point in the history
Add a Request Prefix to Options so that we don't rely always on Request.Scheme or Request.Host.
  • Loading branch information
TerribleDev committed Jun 13, 2018
2 parents 22c830d + b4447fa commit 05cd9a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ protected override async Task<AuthenticationTicket> AuthenticateCoreAsync()
return new AuthenticationTicket(null, properties);
}

var requestPrefix = Request.Scheme + "://" + Request.Host;
var redirectUri = requestPrefix + Request.PathBase + Options.CallbackPath;
var redirectUri = GetRequestPrefix() + Request.PathBase + Options.CallbackPath;

// Build up the body for the token request
var body = new List<KeyValuePair<string, string>>
Expand Down Expand Up @@ -146,9 +145,7 @@ protected override Task ApplyResponseChallengeAsync()

if (challenge == null) return Task.FromResult<object>(null);
var baseUri =
Request.Scheme +
Uri.SchemeDelimiter +
Request.Host +
GetRequestPrefix() +
Request.PathBase;

var currentUri =
Expand Down Expand Up @@ -237,5 +234,12 @@ private async Task<bool> InvokeReplyPathAsync()

return context.IsRequestCompleted;
}

private string GetRequestPrefix()
{
return !String.IsNullOrEmpty(Options.RequestPrefix)
? Options.RequestPrefix
: Request.Scheme + Uri.SchemeDelimiter + Request.Host;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public string Caption
/// </summary>
public bool ForceVerify { get; set; }

/// <summary>
/// Gets or sets the Request prefix
/// </summary>
public string RequestPrefix { get; set; }

/// <summary>
/// Initializes a new <see cref="TwitchAuthenticationOptions" />
/// </summary>
Expand Down

0 comments on commit 05cd9a4

Please sign in to comment.