Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ private async Task<RemoteAppAuthenticationResult> GetRemoteAppAuthenticationResu
await processor.ProcessAsync(_remoteAppAuthResult, Context);
}

// Different authentication schemes may challenge in different ways in the remote
// app, so make a best effort to forward the effects of these challenges by forwarding
// configured headers (like Location, perhaps). Additionally, the act of authentication may
// reissue an authentication cookie, for example, so headers (i.e. Set-Cookie) will need
// to be propagated for authenticate calls too.
foreach (var header in _remoteAppAuthResult.ResponseHeaders)
{
Context.Response.Headers.Append(header.Key, header.Value);
}

if (_remoteAppAuthResult.StatusCode == 400)
{
LogInvalidApiKey();
Expand Down Expand Up @@ -84,15 +94,8 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop
{
var authResult = await GetRemoteAppAuthenticationResultAsync();

// Propagate headers and status code back to the caller
// Different authentication schemes may challenge in different ways in the remote
// app, so make a best effort to forward the effects of these challenges by forwarding
// configured headers (like Location, perhaps) and status code (like 302 or 401, for example).
// Propagate status code back to the caller to forward the effect of the challenge as best we can.
Context.Response.StatusCode = authResult.StatusCode;
foreach (var header in authResult.ResponseHeaders)
{
Context.Response.Headers.Append(header.Key, header.Value);
}
}

[LoggerMessage(EventId = 0, Level = LogLevel.Error, Message = "Failed to authenticate using the remote app due to invalid or missing API key")]
Expand Down