Modified a few for SetUser method
This commit is contained in:
parent
f4f50de125
commit
55527ef514
@ -115,8 +115,9 @@ namespace WebSocketSharp.Net
|
||||
return true;
|
||||
|
||||
var req = context.Request;
|
||||
if (schm == AuthenticationSchemes.Basic) {
|
||||
var authRes = req.Headers["Authorization"];
|
||||
|
||||
if (schm == AuthenticationSchemes.Basic) {
|
||||
if (authRes == null || !authRes.StartsWith ("basic", StringComparison.OrdinalIgnoreCase)) {
|
||||
context.Response.CloseWithAuthChallenge (
|
||||
AuthenticationChallenge.CreateBasicChallenge (listener.Realm).ToBasicString ());
|
||||
@ -125,7 +126,6 @@ namespace WebSocketSharp.Net
|
||||
}
|
||||
}
|
||||
else if (schm == AuthenticationSchemes.Digest) {
|
||||
var authRes = req.Headers["Authorization"];
|
||||
if (authRes == null || !authRes.StartsWith ("digest", StringComparison.OrdinalIgnoreCase)) {
|
||||
context.Response.CloseWithAuthChallenge (
|
||||
AuthenticationChallenge.CreateDigestChallenge (listener.Realm).ToDigestString ());
|
||||
@ -139,7 +139,7 @@ namespace WebSocketSharp.Net
|
||||
}
|
||||
|
||||
var realm = listener.Realm;
|
||||
context.SetUser (schm, realm, listener.UserCredentialsFinder);
|
||||
context.SetUser (authRes, schm, realm, listener.UserCredentialsFinder);
|
||||
if (req.IsAuthenticated)
|
||||
return true;
|
||||
|
||||
|
@ -44,8 +44,8 @@ using WebSocketSharp.Net.WebSockets;
|
||||
namespace WebSocketSharp.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a set of methods and properties used to access the HTTP request and response
|
||||
/// information used by the <see cref="HttpListener"/>.
|
||||
/// Provides the access to the HTTP request and response information
|
||||
/// used by the <see cref="HttpListener"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The HttpListenerContext class cannot be inherited.
|
||||
@ -160,15 +160,16 @@ namespace WebSocketSharp.Net
|
||||
#region Internal Methods
|
||||
|
||||
internal void SetUser (
|
||||
string response,
|
||||
AuthenticationSchemes scheme,
|
||||
string realm,
|
||||
Func<IIdentity, NetworkCredential> credentialsFinder)
|
||||
{
|
||||
var authRes = AuthenticationResponse.Parse (_request.Headers ["Authorization"]);
|
||||
if (authRes == null)
|
||||
var res = AuthenticationResponse.Parse (response);
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
var id = authRes.ToIdentity ();
|
||||
var id = res.ToIdentity ();
|
||||
if (id == null)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user