public static IAppBuilder UseApiKeyAuthentication(this IAppBuilder self, ApiKeyAuthenticationOptions options)
        {
            if (self == null)
            {
                throw new ArgumentNullException("self");
            }

            self.Use(typeof(ApiKeyAuthenticationMiddleware), self, options);
            self.UseStageMarker(PipelineStage.Authenticate);
            return self;
        }
            public static async Task<TestableApiKeyAuthenticationHandler> CreateAsync(ApiKeyAuthenticationOptions options)
            {
                // Always use passive mode for tests
                options.AuthenticationMode = AuthenticationMode.Passive;

                var handler = new TestableApiKeyAuthenticationHandler();

                var ctxt = Fakes.CreateOwinContext();

                // Grr, have to make an internal call to initialize...
                await (Task)(typeof(AuthenticationHandler<ApiKeyAuthenticationOptions>)
                    .InvokeMember(
                        "Initialize",
                        BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
                        Type.DefaultBinder,
                        handler,
                        new object[] { options, ctxt }));
                return handler;
            }
Example #3
0
            public static async Task <TestableApiKeyAuthenticationHandler> CreateAsync(ApiKeyAuthenticationOptions options)
            {
                // Always use passive mode for tests
                options.AuthenticationMode = AuthenticationMode.Passive;

                var handler = new TestableApiKeyAuthenticationHandler();

                var ctxt = Fakes.CreateOwinContext();

                // Grr, have to make an internal call to initialize...
                await(Task)(typeof(AuthenticationHandler <ApiKeyAuthenticationOptions>)
                            .InvokeMember(
                                "Initialize",
                                BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod,
                                Type.DefaultBinder,
                                handler,
                                new object[] { options, ctxt }));
                return(handler);
            }