|
|
|
@ -191,30 +191,34 @@ namespace WebSocketSharp.Net
|
|
|
|
internal bool Authenticate ()
|
|
|
|
internal bool Authenticate ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var schm = _listener.SelectAuthenticationScheme (_request);
|
|
|
|
var schm = _listener.SelectAuthenticationScheme (_request);
|
|
|
|
|
|
|
|
|
|
|
|
if (schm == AuthenticationSchemes.Anonymous)
|
|
|
|
if (schm == AuthenticationSchemes.Anonymous)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (schm == AuthenticationSchemes.None) {
|
|
|
|
if (schm == AuthenticationSchemes.None) {
|
|
|
|
_response.Close (HttpStatusCode.Forbidden);
|
|
|
|
_response.Close (HttpStatusCode.Forbidden);
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var realm = _listener.GetRealm ();
|
|
|
|
var realm = _listener.GetRealm ();
|
|
|
|
var user =
|
|
|
|
var user = HttpUtility.CreateUser (
|
|
|
|
HttpUtility.CreateUser (
|
|
|
|
_request.Headers["Authorization"],
|
|
|
|
_request.Headers["Authorization"],
|
|
|
|
schm,
|
|
|
|
schm,
|
|
|
|
realm,
|
|
|
|
realm,
|
|
|
|
_request.HttpMethod,
|
|
|
|
_request.HttpMethod,
|
|
|
|
_listener.GetUserCredentialsFinder ()
|
|
|
|
_listener.GetUserCredentialsFinder ()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user == null || !user.Identity.IsAuthenticated) {
|
|
|
|
if (user == null || !user.Identity.IsAuthenticated) {
|
|
|
|
_response.CloseWithAuthChallenge (new AuthenticationChallenge (schm, realm).ToString ());
|
|
|
|
var chal = new AuthenticationChallenge (schm, realm).ToString ();
|
|
|
|
|
|
|
|
_response.CloseWithAuthChallenge (chal);
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_user = user;
|
|
|
|
_user = user;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|