Skip to content
Open
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 @@ -483,10 +483,18 @@ private IHost CreateHttpHost(ServiceStartOptions serverOptions)
HttpRequest request = context.Request;
string resourceMetadataUrl = $"{request.Scheme}://{request.Host}/.well-known/oauth-protected-resource";

context.Response.StatusCode = 401;

var header = $"Bearer realm=\"{request.Host}\", resource_metadata=\"{resourceMetadataUrl}\"";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing CHANGELOG entry

if (!string.IsNullOrEmpty(context.Error))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing regression test

header += $", error=\"{context.Error}\"";
if (!string.IsNullOrEmpty(context.ErrorDescription))
header += $", error_description=\"{context.ErrorDescription}\"";

// Modify the WWW-Authenticate header to include resource_metadata
context.Response.Headers.WWWAuthenticate =
$"Bearer realm=\"{request.Host}\", resource_metadata=\"{resourceMetadataUrl}\"";
context.Response.Headers.WWWAuthenticate = header;
}
context.HandleResponse();
return Task.CompletedTask;
}
};
Expand Down
Loading