Skip to content

Commit

Permalink
Merge pull request #18 from hbiarge/challenge_improvements
Browse files Browse the repository at this point in the history
Challenge improvements
  • Loading branch information
hbiarge authored Jan 31, 2019
2 parents 19df523 + d0f8ae8 commit 57c534f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<RepositoryUrl>http://github.com/xabaril/Acheve.TestHost</RepositoryUrl>
<Authors>Xabaril Contributors</Authors>
<Company>Xabaril</Company>
<Version>2.1.0</Version>
<Version>2.1.1</Version>
<Description>Achve.TestHost is a nuget package to improve TestServer experiences.
For more information see http://github.com/Xabaril/Acheve.TestHost</Description>
<Tags>TestHost;TestServer</Tags>
Expand Down
11 changes: 10 additions & 1 deletion src/Acheve.TestHost/Security/TestServerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}\"");
}
}
}
}

0 comments on commit 57c534f

Please sign in to comment.