[Modify] Polish it
This commit is contained in:
parent
1732e8b093
commit
ad38a23eb9
@ -191,17 +191,18 @@ 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,
|
||||||
@ -210,11 +211,14 @@ namespace WebSocketSharp.Net
|
|||||||
);
|
);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user