Skip to content

Commit

Permalink
Add a Request Prefix to TwitchAuthenticationOptions so that we don't …
Browse files Browse the repository at this point in the history
…rely always on Request.Scheme or Request.Host.
  • Loading branch information
Pedro Rebelo committed Jun 4, 2018
1 parent 22c830d commit c9dd2cc
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 c9dd2cc

Please sign in to comment.