diff --git a/build/dependencies.props b/build/dependencies.props index 8c02f26..25b8482 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -27,7 +27,7 @@ http://github.com/xabaril/Acheve.TestHost Xabaril Contributors Xabaril - 2.1.0 + 2.1.1 Achve.TestHost is a nuget package to improve TestServer experiences. For more information see http://github.com/Xabaril/Acheve.TestHost TestHost;TestServer diff --git a/src/Acheve.TestHost/Security/TestServerHandler.cs b/src/Acheve.TestHost/Security/TestServerHandler.cs index 719cbd2..b74ab56 100644 --- a/src/Acheve.TestHost/Security/TestServerHandler.cs +++ b/src/Acheve.TestHost/Security/TestServerHandler.cs @@ -138,7 +138,16 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop Response.StatusCode = 401; - Response.Headers.Append(HeaderNames.WWWAuthenticate, Scheme.Name); + if (string.IsNullOrEmpty(eventContext.Error)) + { + Response.Headers.Append(HeaderNames.WWWAuthenticate, Scheme.Name); + } + else + { + // https://tools.ietf.org/html/rfc6750#section-3.1 + // WWW-Authenticate: Bearer realm="example", error="invalid_token", error_description="The access token expired" + Response.Headers.Append(HeaderNames.WWWAuthenticate, $"{Scheme.Name} realm=\"test\", error=\"{eventContext.Error}\""); + } } } }