internal bool Authenticate(AuthenticationSchemes scheme, string realm, Func <IIdentity, NetworkCredential> credentialsFinder) { var chal = new AuthenticationChallenge(scheme, realm).ToString(); var retry = -1; bool auth() { retry++; if (retry > 99) { return(false); } var user = HttpUtility.CreateUser( _request.Headers["Authorization"], scheme, realm, _request.HttpMethod, credentialsFinder ); if (user != null && user.Identity.IsAuthenticated) { _user = user; return(true); } _request = sendAuthenticationChallenge(chal); return(auth()); } return(auth()); }
private static bool authenticate(TcpListenerWebSocketContext context, WebSocketSharp.Net.AuthenticationSchemes scheme, string realm, Func <IIdentity, WebSocketSharp.Net.NetworkCredential> credentialsFinder) { string chal = ((scheme == WebSocketSharp.Net.AuthenticationSchemes.Basic) ? AuthenticationChallenge.CreateBasicChallenge(realm).ToBasicString() : ((scheme != WebSocketSharp.Net.AuthenticationSchemes.Digest) ? null : AuthenticationChallenge.CreateDigestChallenge(realm).ToDigestString())); if (chal == null) { context.Close(WebSocketSharp.Net.HttpStatusCode.Forbidden); return(false); } int retry = -1; Func <bool> auth = null; auth = delegate { retry++; if (retry > 99) { context.Close(WebSocketSharp.Net.HttpStatusCode.Forbidden); return(false); } IPrincipal principal = HttpUtility.CreateUser(context.Headers["Authorization"], scheme, realm, context.HttpMethod, credentialsFinder); if (principal != null && principal.Identity.IsAuthenticated) { context.SetUser(principal); return(true); } context.SendAuthenticationChallenge(chal); return(auth()); }; return(auth()); }
public async Task <bool> CreateUser(UserModel user) { var result = await httpHelper.CreateUser(user); userModels.Append(user); return(true); }
internal bool Authenticate( AuthenticationSchemes scheme, string realm, Func <IIdentity, NetworkCredential> credentialsFinder ) { if (scheme == AuthenticationSchemes.Anonymous) { return(true); } if (scheme == AuthenticationSchemes.None) { Close(HttpStatusCode.Forbidden); return(false); } var chal = new AuthenticationChallenge(scheme, realm).ToString(); var retry = -1; Func <bool> auth = null; auth = () => { retry++; if (retry > 99) { Close(HttpStatusCode.Forbidden); return(false); } #if !NETCF || BCC || SSL var user = HttpUtility.CreateUser( _request.Headers["Authorization"], scheme, realm, _request.HttpMethod, credentialsFinder ); if (user != null && user.Identity.IsAuthenticated) { _user = user; return(true); } #endif SendAuthenticationChallenge(chal); return(auth()); }; return(auth()); }
internal bool Authenticate(WebSocketSharp.Net.AuthenticationSchemes scheme, string realm, Func <IIdentity, WebSocketSharp.Net.NetworkCredential> credentialsFinder) { bool flag1; if (scheme == WebSocketSharp.Net.AuthenticationSchemes.Anonymous) { flag1 = true; } else if (scheme != WebSocketSharp.Net.AuthenticationSchemes.None) { string str = (new AuthenticationChallenge(scheme, realm)).ToString(); int num = -1; Func <bool> func = null; func = () => { bool flag; num++; if (num <= 99) { IPrincipal principal = HttpUtility.CreateUser(this._request.Headers["Authorization"], scheme, realm, this._request.HttpMethod, credentialsFinder); if ((principal == null ? false : principal.Identity.IsAuthenticated)) { this._user = principal; flag = true; } else { this.SendAuthenticationChallenge(str); flag = func(); } } else { this.Close(WebSocketSharp.Net.HttpStatusCode.Forbidden); flag = false; } return(flag); }; flag1 = func(); } else { this.Close(WebSocketSharp.Net.HttpStatusCode.Forbidden); flag1 = false; } return(flag1); }
private static bool authenticate( TcpListenerWebSocketContext context, AuthenticationSchemes scheme, string realm, Func <IIdentity, NetworkCredential> credentialsFinder) { var chal = scheme == AuthenticationSchemes.Basic ? AuthenticationChallenge.CreateBasicChallenge(realm).ToBasicString() : scheme == AuthenticationSchemes.Digest ? AuthenticationChallenge.CreateDigestChallenge(realm).ToDigestString() : null; if (chal == null) { context.Close(HttpStatusCode.Forbidden); return(false); } var retry = -1; Func <bool> auth = null; auth = () => { retry++; if (retry > 99) { context.Close(HttpStatusCode.Forbidden); return(false); } var user = HttpUtility.CreateUser( context.Headers["Authorization"], scheme, realm, context.HttpMethod, credentialsFinder); if (user != null && user.Identity.IsAuthenticated) { context.SetUser(user); return(true); } context.SendAuthenticationChallenge(chal); return(auth()); }; return(auth()); }