private Dictionary <string, string> GetServerVariables(AuthenticationContext FilterContext) { Dictionary <string, string> server_variables = new Dictionary <string, string>(); try { // read headers var context = FilterContext.HttpContext; if (context != null) { var request = context.Request; if (request != null) { server_variables = new Dictionary <string, string>(request.ServerVariables.Count); foreach (var key in request.ServerVariables.AllKeys) { server_variables.Add(key.ToLower(), request.ServerVariables[key]); } } } } catch (Exception ex) { AuthenticationHandler.OnError(ex); } return(server_variables); }
public override void OnMessage(string message) { if (!IsAuthenticated) { var handler = new AuthenticationHandler(SiteId); var result = handler.ProcessMessage(message); IsAuthenticated = handler.IsAuthenticated; Send(result); } else { var authen = JsonConvert.DeserializeObject <PiRequestModel>(message); switch (authen.RequestType) { case "siteStatus": var siteStatusHandler = new SiteStatusHandler(SiteId); var siteStatusResult = siteStatusHandler.ProcessMessage(message); Send(siteStatusResult); break; case "switchUpdate": var switchUpdateHandler = new SwitchUpdateHandler(SiteId); var result = switchUpdateHandler.ProcessMessage(message); WebSocketSession.SendToClients(result); break; case "liveSwtiches": WebSocketSession.SendToClients(message); break; } } }
public void Should_CreatePipeline_Without_CompressionHandler() { using (AuthenticationHandler authenticationHandler = (AuthenticationHandler)GraphClientFactory.CreatePipeline(handlers)) using (RetryHandler retryHandler = (RetryHandler)authenticationHandler.InnerHandler) using (RedirectHandler redirectHandler = (RedirectHandler)retryHandler.InnerHandler) #if iOS using (NSUrlSessionHandler innerMost = (NSUrlSessionHandler)redirectHandler.InnerHandler) #elif macOS using (Foundation.NSUrlSessionHandler innerMost = (Foundation.NSUrlSessionHandler)redirectHandler.InnerHandler) #endif { Assert.NotNull(authenticationHandler); Assert.NotNull(retryHandler); Assert.NotNull(redirectHandler); Assert.NotNull(innerMost); Assert.IsType <AuthenticationHandler>(authenticationHandler); Assert.IsType <RetryHandler>(retryHandler); Assert.IsType <RedirectHandler>(redirectHandler); #if iOS Assert.IsType <NSUrlSessionHandler>(innerMost); #elif macOS Assert.IsType <Foundation.NSUrlSessionHandler>(innerMost); #endif } }
public async Task Registry_Get_Manifest_With_Auth(string image, bool insecure, bool skipTlsVerify) { var registryName = ImageHelper.GetRegistryName(image); var registryUrl = ImageHelper.GetRegistryBaseUrl(image, insecure); var authHandler = new AuthenticationHandler(registryName, null, _registryLogger); var registry = new Registry(registryUrl, _registryLogger, authHandler, skipTlsVerify); var imageName = ImageHelper.GetImageName(image); var imageRef = ImageHelper.GetImageReference(image); var manifest = await registry.GetManifest(imageName, imageRef); Assert.IsNotNull(manifest); Assert.IsNotNull(manifest.layers); Assert.IsTrue(manifest.layers.Any()); Assert.IsNotNull(manifest.layers.First().digest); Assert.IsNotNull(manifest.config); Assert.IsNotNull(manifest.config.digest); try { Assert.AreEqual(ImageV1.MimeType, manifest.config.mediaType); } catch { Assert.AreEqual(ImageV1.AltMimeType, manifest.config.mediaType); } }
/// <summary> /// Configure OCS/OMF Services /// </summary> private static IOmfIngressService ConfigureOcsOmf(Uri address, string tenantId, string namespaceId, string clientId, string clientSecret) { var deviceAuthenticationHandler = new AuthenticationHandler(address, clientId, clientSecret); var deviceBaseOmfIngressService = new OmfIngressService(address, null, HttpCompressionMethod.None, deviceAuthenticationHandler); return(deviceBaseOmfIngressService.GetOmfIngressService(tenantId, namespaceId)); }
private static AuthenticationHandler GetDefaultAuthenticationHandler() { var authConfig = new AuthenticationConfiguration { RequireSsl = false, InheritHostClientIdentity = false }; #region Basic Authentication authConfig.AddBasicAuthentication((userName, password) => { return(userName == password); }); #endregion //#region SWT //authConfig.Handler.AddSimpleWebToken( // "SWT", // Constants.Issuer, // Constants.Realm, // "Dc9Mpi3jbooUpBQpB/4R7XtUsa3D/ALSjTVvK8IUZbg="); //#endregion #region SAML2 tokens var registry = new ConfigurationBasedIssuerNameRegistry(); registry.AddTrustedIssuer("D263DDCF598E716F0037380796A4A62DF017ADB8", "TEST"); var saml2Config = new SecurityTokenHandlerConfiguration(); saml2Config.AudienceRestriction.AllowedAudienceUris.Add(new Uri("https://test")); saml2Config.IssuerNameRegistry = registry; saml2Config.CertificateValidator = X509CertificateValidator.None; authConfig.AddSaml2(saml2Config, AuthenticationOptions.ForAuthorizationHeader("Saml2"), null); #endregion var authHandler = new AuthenticationHandler(authConfig); return(authHandler); }
public void Setup() { this.testHttpMessageHandler = new MockRedirectHandler(); handlers[0] = new RetryHandler(); handlers[1] = new RedirectHandler(); handlers[2] = new AuthenticationHandler(authenticationProvider.Object); }
public async Task RunAuthentication( TestContext ctx, [WebTestFeatures.SelectProxyKind(IncludeSSL = true)] ProxyKind kind, HttpServer server, [AuthenticationType] AuthenticationType authType, Handler handler, CancellationToken cancellationToken) { var authHandler = new AuthenticationHandler(authType, handler); HttpOperation operation; if (kind == ProxyKind.Unauthenticated) { operation = new TraditionalOperation(server, authHandler, true, HttpOperationFlags.AbortAfterClientExits, HttpStatusCode.ProxyAuthenticationRequired, WebExceptionStatus.ProtocolError); } else { operation = new TraditionalOperation(server, authHandler, true); } try { await operation.Run(ctx, cancellationToken).ConfigureAwait(false); } finally { operation.Dispose(); } }
public AuthenticationHandlerTests() { testHttpMessageHandler = new MockRedirectHandler(); mockAuthenticationProvider = new MockAuthenticationProvider(); authenticationHandler = new AuthenticationHandler(mockAuthenticationProvider.Object, testHttpMessageHandler); invoker = new HttpMessageInvoker(authenticationHandler); }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationModule"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authenticationRequiredHandler">Delegate used to determine if authentication is required (may be null).</param> protected AuthenticationModule( AuthenticationHandler authenticator, AuthenticationRequiredHandler authenticationRequiredHandler) { Check.Require(authenticator, "authenticator"); _authenticationRequiredHandler = authenticationRequiredHandler; _authenticator = authenticator; }
public async Task <HttpResponseMessage> GetIP() { return(await CreateHttpResponseAsync(Request, async() => { return Request.CreateResponse(HttpStatusCode.OK, "Your IP:" + AuthenticationHandler.GetClientIPAddressHashed(Request)); })); }
protected virtual async Task <HttpResponseMessage> CallApi( string action, Dictionary <string, object> values, CancellationToken cancellationToken ) { var uri = GetApiUri(action); uri = Helpers.AppendQueryParametersToUri(uri, values); var request = new HttpRequestMessage( HttpMethod, uri ); request = await AuthenticationHandler.HandleRequest( action, uri, HttpClient, request, cancellationToken ); var response = await HttpClient.SendAsync( request, cancellationToken ); if (!response.IsSuccessStatusCode) { throw new YourlsException($"Remote API call was unsuccessful, StatusCode: {response.StatusCode}"); } return(response); }
public async Task AuthHandler_ShouldRetryUnauthorizedGetRequestUsingAuthHandlerOption() { DelegatingHandler authHandler = new AuthenticationHandler(null, testHttpMessageHandler); using (HttpMessageInvoker msgInvoker = new HttpMessageInvoker(authHandler)) using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "http://example.com/bar")) using (var unauthorizedResponse = new HttpResponseMessage(HttpStatusCode.Unauthorized)) using (var expectedResponse = new HttpResponseMessage(HttpStatusCode.OK)) { httpRequestMessage.Properties.Add(typeof(GraphRequestContext).ToString(), new GraphRequestContext { MiddlewareOptions = new Dictionary <string, IMiddlewareOption>() { { typeof(AuthenticationHandlerOption).ToString(), new AuthenticationHandlerOption { AuthenticationProvider = mockAuthenticationProvider.Object } } } }); testHttpMessageHandler.SetHttpResponse(unauthorizedResponse, expectedResponse); var response = await msgInvoker.SendAsync(httpRequestMessage, new CancellationToken()); Assert.NotSame(response.RequestMessage, httpRequestMessage); Assert.Same(response, expectedResponse); Assert.Null(response.RequestMessage.Content); } }
/// <exception cref="Javax.Servlet.ServletException"/> public override void Init(FilterConfig filterConfig) { base.Init(filterConfig); AuthenticationHandler handler = GetAuthenticationHandler(); AbstractDelegationTokenSecretManager dtSecretManager = (AbstractDelegationTokenSecretManager )filterConfig.GetServletContext().GetAttribute(DelegationTokenSecretManagerAttr); if (dtSecretManager != null && handler is DelegationTokenAuthenticationHandler) { DelegationTokenAuthenticationHandler dtHandler = (DelegationTokenAuthenticationHandler )GetAuthenticationHandler(); dtHandler.SetExternalDelegationTokenSecretManager(dtSecretManager); } if (handler is PseudoAuthenticationHandler || handler is PseudoDelegationTokenAuthenticationHandler) { SetHandlerAuthMethod(SaslRpcServer.AuthMethod.Simple); } if (handler is KerberosAuthenticationHandler || handler is KerberosDelegationTokenAuthenticationHandler) { SetHandlerAuthMethod(SaslRpcServer.AuthMethod.Kerberos); } // proxyuser configuration Configuration conf = GetProxyuserConfiguration(filterConfig); ProxyUsers.RefreshSuperUserGroupsConfiguration(conf, ProxyuserPrefix); }
public GraphClientFactoryTests() { this.testHttpMessageHandler = new MockRedirectHandler(); handlers[0] = new RetryHandler(); handlers[1] = new RedirectHandler(); handlers[2] = new AuthenticationHandler(); }
//Gambiarra por agora.... public async Task UserAuthenticate() { //Prompting for user authentication userHandler = await AuthenticationHandler.CredentialsAuthMode(); userCommands = new CommandList(userHandler); }
private static void ConfigureHttp( HttpConfiguration config, StatelessServiceContext serviceContext) { var exceptionHandler = new CustomExceptionHandler(serviceContext); config.Services.Replace(typeof(IExceptionHandler), exceptionHandler); var authenticationHandler = new AuthenticationHandler(serviceContext); config.MessageHandlers.Add(authenticationHandler); var traceHandler = new TraceHandler(serviceContext); config.MessageHandlers.Add(traceHandler); var serializer = config.Formatters.JsonFormatter; serializer.SerializerSettings.Formatting = Formatting.Indented; serializer.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.Clear(); var jsonFormatter = new JsonMediaTypeFormatter(); jsonFormatter.SupportedMediaTypes.Remove(new MediaTypeHeaderValue("text/json")); config.Formatters.Add(jsonFormatter); config.MapHttpAttributeRoutes(); }
protected void Application_AuthenticateRequest(Object sender, EventArgs e) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie == null) { AuthenticationHandler.SignOut(); authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; //можно считывать из Reponse } FormsAuthenticationTicket authTicket; try { authTicket = FormsAuthentication.Decrypt(authCookie.Value); } catch (ArgumentException) { AuthenticationHandler.SignOut(); authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; authTicket = FormsAuthentication.Decrypt(authCookie.Value); } if (authTicket.Expired) { AuthenticationHandler.SignOut(); authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; authTicket = FormsAuthentication.Decrypt(authCookie.Value); } FormsIdentity id = new FormsIdentity(authTicket); Context.User = new GenericPrincipal(id, authTicket.UserData.Split(new char[] { ',', ' ' })); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AuthenticationHandler handler, JwtSettings jwtSettings) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); } app.UseExceptionHandler(ApiGlobalExceptionHandler()); var validationParameters = new TokenValidationParameters { IssuerSigningKey = jwtSettings.SecurityKey, ValidAudience = jwtSettings.Audience, ValidIssuer = jwtSettings.Issuer }; var jwtBearerOptions = new JwtBearerOptions { Events = handler, TokenValidationParameters = validationParameters }; app.UseJwtBearerAuthentication(jwtBearerOptions); app.UseCors("CorsPolicy"); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseMvc(); }
public static HealthChecksBuilder AddHealthChecks(this HttpConfiguration httpConfiguration, string healthEndpoint = "health") { var hcBuilder = new HealthChecksBuilder(); var dependencyResolver = httpConfiguration.DependencyResolver; var hcConfig = hcBuilder.HealthCheckConfig; // Service Instances var healthChecksService = new HealthCheckService(dependencyResolver, hcConfig.HealthChecksDependencies); var authenticationService = new AuthenticationService(hcConfig); // Handler Instances var authenticationHandler = new AuthenticationHandler(hcConfig, authenticationService); var healthCheckHandler = new HealthCheckHandler(hcConfig, healthChecksService); // ChainOfResponsibility authenticationHandler.SetNextHandler(healthCheckHandler); httpConfiguration.Routes.MapHttpRoute( name: "health_check", routeTemplate: healthEndpoint, defaults: new { check = RouteParameter.Optional }, constraints: null, handler: authenticationHandler ); return(hcBuilder); }
public static void UserToView(Controller controller) { User user = AuthenticationHandler.CurrentUser(controller.HttpContext.Session); controller.ViewBag.User = user; controller.ViewBag.SignedIn = user.RoleID != 0; }
public async Task GetDiscoveryDocumentAsync() { var issuer = "http://test.openiddict.com"; var mockConfiguration = GetMockConfiguration(issuer: issuer); var mockHttpClientFactory = GetMockHttpClientFactory((mockHttp) => { mockHttp.Expect($"{issuer}/.well-known/openid-configuration") .Respond("application/json", @" { ""issuer"": """ + issuer + @""", ""authorization_endpoint"": ""TestAuthorizationEndpoint"", ""token_endpoint"": ""TestTokenEndpoint"", ""scopes_supported"": [ ""scope1"", ""scope2"" ] }"); }); var mockHttpContext = A.Fake <HttpContext>(); StringValues ignored = StringValues.Empty; A.CallTo(() => mockHttpContext.Request.Headers.TryGetValue("Authorization", out ignored)) .Returns(false); var mockHttpContextAccessor = A.Fake <IHttpContextAccessor>(); A.CallTo(() => mockHttpContextAccessor.HttpContext) .Returns(mockHttpContext); var authorizationHandler = new AuthenticationHandler(mockConfiguration, mockHttpClientFactory, mockHttpContextAccessor); var discoveryDocument = await authorizationHandler.GetDiscoveryDocumentAsync(); Assert.AreEqual(issuer, discoveryDocument.Issuer); Assert.AreEqual("TestAuthorizationEndpoint", discoveryDocument.AuthorizationEndpoint); Assert.AreEqual("TestTokenEndpoint", discoveryDocument.TokenEndpoint); CollectionAssert.AreEqual(new[] { "scope1", "scope2" }, discoveryDocument.ScopesSupported.ToList()); }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationModule"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authenticationRequiredHandler">Delegate used to determine if authentication is required (may be null).</param> protected AuthenticationModule( AuthenticationHandler authenticator, AuthenticationRequiredHandler authenticationRequiredHandler) { Check.Require(authenticator, "authenticator"); _authenticationRequiredHandler = authenticationRequiredHandler; _authenticator = authenticator; }
public void BartIngressTest() { Program.LoadConfiguration(); // Verify timestamp is within last minute var verifyTimestamp = DateTime.UtcNow.AddMinutes(-1); // Test requires that specific stations are chosen for BartApiOrig and BartApiDest, "all" is not allowed var streamId = $"BART_{Program.Settings.BartApiOrig}_{Program.Settings.BartApiDest}"; try { Program.RunIngress(); // Wait for data to be processed by OCS Thread.Sleep(5000); // Edge Data Store and PI Web API process OMF before sending a response, and will return an error code if there is a problem // In this test, the call to RunIngress above will result in an exception if there is a failure on either of those endpoints // OCS does not validate OMF before sending a success response, so the test must check that the messages were successful using var ocsAuthenticationHandler = new AuthenticationHandler(Program.Settings.OcsUri, Program.Settings.OcsClientId, Program.Settings.OcsClientSecret); var ocsSdsService = new SdsService(Program.Settings.OcsUri, null, HttpCompressionMethod.GZip, ocsAuthenticationHandler); var ocsDataService = ocsSdsService.GetDataService(Program.Settings.OcsTenantId, Program.Settings.OcsNamespaceId); var ocsValue = ocsDataService.GetLastValueAsync <BartStationEtd>(streamId).Result; Assert.True(ocsValue.TimeStamp > verifyTimestamp); } finally { // Delete type and containers Program.Cleanup(); } }
public static HealthChecksBuilder AddHealthChecks(this HttpConfiguration httpConfiguration, string healthEndpoint = "health") { System.Diagnostics.Debug.WriteLine("Iniciei"); // ToDo: Era para isso estar aqui mesmo? var healthChecksBuilder = new HealthChecksBuilder(); var healthChecksService = new HealthCheckService(healthChecksBuilder); var authenticationService = new AuthenticationService(healthChecksBuilder); var dependencyHandler = new DependencyHandler(httpConfiguration, healthChecksBuilder); var authenticationHandler = new AuthenticationHandler(authenticationService); var healthCheckHandler = new HealthCheckHandler(healthChecksService); dependencyHandler.SetNextHandler(authenticationHandler); authenticationHandler.SetNextHandler(healthCheckHandler); httpConfiguration.Routes.MapHttpRoute( name: "health_check", routeTemplate: healthEndpoint, defaults: new { check = RouteParameter.Optional }, constraints: null, handler: dependencyHandler ); return(healthChecksBuilder); }
public async Task GetDiscoveryDocumentAsync_ResponseCode404_Throws() { var tenantId = "TestTenant"; var issuer = "http://test.openiddict.com"; var scopeApiPath = "http://somewhere.else.com/scope/{{tenantId}}"; var mockConfiguration = GetMockConfiguration(issuer: issuer, scopeApiPath: scopeApiPath); var mockHttpClientFactory = GetMockHttpClientFactory((mockHttp) => { mockHttp.Expect($"{issuer}/.well-known/openid-configuration") .Respond(System.Net.HttpStatusCode.NotFound, "application/json", string.Empty); }); var mockHttpContext = A.Fake <HttpContext>(); StringValues ignored = StringValues.Empty; A.CallTo(() => mockHttpContext.Request.Headers.TryGetValue("Authorization", out ignored)) .Returns(false); var mockHttpContextAccessor = A.Fake <IHttpContextAccessor>(); A.CallTo(() => mockHttpContextAccessor.HttpContext) .Returns(mockHttpContext); var authorizationHandler = new AuthenticationHandler(mockConfiguration, mockHttpClientFactory, mockHttpContextAccessor); var exception = await Assert.ThrowsExceptionAsync <AuthenticationException>(() => authorizationHandler.GetDiscoveryDocumentAsync()); Assert.AreEqual("Could not fetch discovery document at URL: http://test.openiddict.com/.well-known/openid-configuration", exception.Message); }
public void Setup() { mockAuthenticationProvider = new MockAuthenticationProvider(); testHttpMessageHandler = new MockRedirectHandler(); authenticationHandler = new AuthenticationHandler(mockAuthenticationProvider.Object, testHttpMessageHandler); invoker = new HttpMessageInvoker(authenticationHandler); }
public async Task GetScopesForTenantAsync() { var tenantId = "TestTenant"; var issuer = "http://test.openiddict.com"; var clientId = "TestClientId"; var scopeApiPath = "http://somewhere.else.com/scope/{{tenantId}}?clientId={{clientId}}"; var mockConfiguration = GetMockConfiguration(issuer: issuer, clientId: clientId, scopeApiPath: scopeApiPath); var mockHttpClientFactory = GetMockHttpClientFactory((mockHttp) => { mockHttp.Expect($"http://somewhere.else.com/scope/{tenantId}?clientId={clientId}") .Respond("application/json", @"[ ""scope1"", ""scope2"" ]"); }); var mockHttpContext = A.Fake <HttpContext>(); StringValues ignored = StringValues.Empty; A.CallTo(() => mockHttpContext.Request.Headers.TryGetValue("Authorization", out ignored)) .Returns(false); var mockHttpContextAccessor = A.Fake <IHttpContextAccessor>(); A.CallTo(() => mockHttpContextAccessor.HttpContext) .Returns(mockHttpContext); var authorizationHandler = new AuthenticationHandler(mockConfiguration, mockHttpClientFactory, mockHttpContextAccessor); var scope = await authorizationHandler.GetScopesForTenantAsync(tenantId); Assert.AreEqual("scope1 scope2", scope); }
public void SendAsync_AddsAcceptHeader() { var innerHandler = new Mock <HttpClientHandler>(); var authProvider = new Mock <ITokenProvider>(); var testObject = new AuthenticationHandler(authProvider.Object) { InnerHandler = innerHandler.Object }; var request = new HttpRequestMessage(); innerHandler.Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .Returns(Task.FromResult(new HttpResponseMessage())); authProvider.Setup(x => x.GetBearerToken()) .Returns(Task.FromResult("token value")); new HttpMessageInvoker(testObject) .SendAsync(request, CancellationToken.None) .Wait(); Assert.NotNull(request.Headers.Authorization); Assert.AreEqual("Bearer", request.Headers.Authorization.Scheme); Assert.AreEqual("token value", request.Headers.Authorization.Parameter); }
public void setAuthenticationParamsForInvalidAccount() { ConnectionManager connMgr = ConnectionManager.Instance; AuthenticationHandler authHandler = new AuthenticationHandler("incomplete-credentials_api1.paypal.com"); HttpWebRequest httpRequest = connMgr.GetConnection("http://paypal.com"); authHandler.SetAuthenticationParams(httpRequest, ""); }
public async Task MartinTest2(TestContext ctx, HttpServer server, CancellationToken cancellationToken) { var handler = HelloWorldHandler.GetSimple(); var authHandler = new AuthenticationHandler(AuthenticationType.NTLM, handler); using (var operation = new TraditionalOperation(server, authHandler, true)) await operation.Run(ctx, cancellationToken).ConfigureAwait(false); }
public static IHandler Build() { var okHandler = new OkHandler(); var putHandler = new PutHandler(); var notFoundHandler = new NotFoundHandler(putHandler); var methodIsSupportedHandler = new MethodIsSupportedHandler(okHandler); var resourceExistsHandler = new ResourceExistsHandler(methodIsSupportedHandler, notFoundHandler); var endpointExistsHandler = new EndpointExistsHandler(resourceExistsHandler); var optionsHandler = new OptionsHandler(endpointExistsHandler); var authorizationHandler = new AuthorizationHandler(optionsHandler); var authenticationHandler = new AuthenticationHandler(authorizationHandler); return authenticationHandler; }
private async Task DoInsert(string username, string password, string email, bool isLogin) { Account account = new Account { Username = username, Password = password, Email = email }; using (AuthenticationHandler handler = new AuthenticationHandler()) { using (MobileServiceClient client = ClientFactory.CreateClient(handler)) { var table = client.GetTable<Account>(); Dictionary<string, string> parameters = new Dictionary<string, string> { { "login", isLogin.ToString().ToLower()} }; await table.InsertAsync(account, parameters); } } }
/// <summary> /// Initializes a new instance of the <see cref="BasicAuthentication"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> public BasicAuthentication(AuthenticationHandler authenticator) : base(authenticator) { }
/// <summary> /// Initializes a new instance of the <see cref="BasicAuthentication"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authenticationRequiredHandler">Delegate used to determine if authentication is required (may be null).</param> public BasicAuthentication(AuthenticationHandler authenticator, AuthenticationRequiredHandler authenticationRequiredHandler) : base(authenticator, authenticationRequiredHandler) { }
public void setAuthenticationHandler( AuthenticationHandler authenticationHandler) { this.authenticationHandler = authenticationHandler; }
/// <summary> /// Called after an asynchronous web services search has /// completed. /// </summary> void DiscoveryCompleted(IAsyncResult result) { AsyncDiscoveryState state = (AsyncDiscoveryState)result.AsyncState; WebServiceDiscoveryClientProtocol protocol = state.Protocol; // Check that we are still waiting for this particular callback. bool wanted = false; lock (this) { wanted = Object.ReferenceEquals(discoveryClientProtocol, protocol); } if (wanted) { DiscoveredWebServicesHandler handler = new DiscoveredWebServicesHandler(DiscoveredWebServices); try { DiscoverAnyAsync asyncDelegate = (DiscoverAnyAsync)((AsyncResult)result).AsyncDelegate; DiscoveryDocument doc = asyncDelegate.EndInvoke(result); if (!state.Credential.IsDefaultAuthenticationType) { AddCredential(state.Uri, state.Credential); } Invoke(handler, new object[] {protocol}); } catch (Exception ex) { if (protocol.IsAuthenticationRequired) { HttpAuthenticationHeader authHeader = protocol.GetAuthenticationHeader(); AuthenticationHandler authHandler = new AuthenticationHandler(AuthenticateUser); Invoke(authHandler, new object[] {state.Uri, authHeader.AuthenticationType}); } else { LoggingService.Error("DiscoveryCompleted", ex); Invoke(handler, new object[] {null}); } } } }
/// <summary> /// Initializes a new instance of the <see cref="AuthenticationModule"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> protected AuthenticationModule(AuthenticationHandler authenticator) : this(authenticator, null) { }
/// <summary> /// Initializes a new instance of the <see cref="BasicAuthentication"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authRequiredDelegate">Delegate used to determine if authentication is required (may be null).</param> public BasicAuthentication(AuthenticationHandler authenticator, AuthRequiredDelegate authRequiredDelegate) : base(authenticator, authRequiredDelegate) { }
/// <summary> /// Initializes a new instance of the <see cref="DigestAuthentication"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authenticationRequiredHandler">Delegate used to determine if authentication is required (may be null).</param> public DigestAuthentication(AuthenticationHandler authenticator, AuthenticationRequiredHandler authenticationRequiredHandler) : base(authenticator, authenticationRequiredHandler) { }
/// <summary> /// Initializes a new instance of the <see cref="DigestAuthentication"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> public DigestAuthentication(AuthenticationHandler authenticator) : base(authenticator) { }
/// <summary> /// Initializes a new instance of the <see cref="AuthModule"/> class. /// </summary> /// <param name="authenticator">Delegate used to provide information used during authentication.</param> /// <param name="authRequiredDelegate">Delegate used to determine if authentication is required (may be null).</param> protected AuthModule(AuthenticationHandler authenticator, AuthRequiredDelegate authRequiredDelegate) { Check.Require(authenticator, "authenticator"); _authRequiredDelegate = authRequiredDelegate; _authenticator = authenticator; }